Commit 5d0e539a authored by Sakthivel Velumani's avatar Sakthivel Velumani

Added HARQ stats to ulsim

parent 540d717e
......@@ -148,6 +148,10 @@ int main(int argc, char **argv)
cpuf = get_cpu_freq_GHz();
int msg3_flag = 0;
uint8_t rv_index = 0;
float roundStats[50];
float effRate;
float eff_tp_check = 0.7;
uint8_t snrRun;
UE_nr_rxtx_proc_t UE_proc;
FILE *scg_fd=NULL;
......@@ -276,6 +280,9 @@ int main(int argc, char **argv)
printf("Setting SNR0 to %f\n", snr0);
break;
case 't':
eff_tp_check = (float)atoi(optarg)/100;
break;
/*
case 'r':
ricean_factor = pow(10,-.1*atof(optarg));
......@@ -374,6 +381,7 @@ int main(int argc, char **argv)
printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-R N_RB_DL\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-P Print ULSCH performances\n");
exit(-1);
......@@ -579,13 +587,19 @@ int main(int argc, char **argv)
printf("\n");
//for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0));
snrRun = 0;
for (SNR = snr0; SNR < snr1; SNR += snr_step) {
varArray_t *table_rx=initVarArray(1000,sizeof(double));
int error_flag = 0;
n_false_positive = 0;
effRate = 0;
n_errors = 0;
for (trial = 0; trial < n_trials; trial++) {
uint8_t round = 0;
int error_flag;
crc_status = 1;
crc_status = 1;
errors_scrambling = 0;
errors_decoding = 0;
while (round<max_rounds && crc_status) {
ulsch_ue[0]->harq_processes[harq_pid]->round = round;
gNB->ulsch[0][0]->harq_processes[harq_pid]->round = round;
......@@ -733,7 +747,6 @@ int main(int argc, char **argv)
if (input_fd == NULL) {
if (SNR==snr0) {
// set FAPI parameters for UE, put them in the scheduled response and call
nr_ue_scheduled_response(&scheduled_response);
......@@ -758,24 +771,14 @@ int main(int argc, char **argv)
txlev_float = (double)txlev/scale; // output of signal_energy is fixed point representation
//AWGN
}
}
else n_trials = 1;
sigma_dB = 10*log10(txlev_float)-SNR;
sigma = pow(10,sigma_dB/10);
printf("txlev_float %f, sigma_dB %f\n",10*log10(txlev_float),sigma_dB);
if(n_trials==1) printf("txlev_float %f, sigma_dB %f\n",10*log10(txlev_float),sigma_dB);
n_errors = 0;
n_false_positive = 0;
errors_scrambling = 0;
errors_decoding = 0;
error_flag = 0;
//----------------------------------------------------------
//------------------------ add noise -----------------------
//----------------------------------------------------------
......@@ -846,7 +849,7 @@ int main(int argc, char **argv)
} else {
crc_status = 0;
}
printf("end of round %d rv_index %d\n",round, rv_index);
if(n_trials==1) printf("end of round %d rv_index %d\n",round, rv_index);
round++;
} // round
......@@ -896,12 +899,17 @@ int main(int argc, char **argv)
if (n_trials==1)
printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %u\n" "\x1B[0m", frame, trial, errors_decoding);
}
roundStats[snrRun] += ((float)round);
if (!crc_status) effRate += ((float)TBS)/round;
} // trial loop
roundStats[snrRun]/=((float)n_trials);
effRate /= n_trials;
printf("*****************************************\n");
printf("SNR %f: n_errors (negative CRC) = %d/%d, false_positive %d/%d, errors_scrambling %u/%u\n", SNR, n_errors, n_trials, n_false_positive, n_trials, errors_scrambling, available_bits*n_trials);
printf("\n");
printf("SNR %f: Channel BLER %e, Channel BER %e\n", SNR,(double)n_errors/n_trials,(double)errors_scrambling/available_bits/n_trials);
printf("SNR %f: Channel BLER %e, Channel BER %e Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %d bits/slot\n", SNR,(double)n_errors/n_trials,(double)errors_scrambling/available_bits/n_trials,roundStats[snrRun],effRate,effRate/TBS*100,TBS);
printf("*****************************************\n");
printf("\n");
......@@ -929,6 +937,7 @@ int main(int argc, char **argv)
break;
}
snrRun++;
} // SNR loop
printf("\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment