Merge branch 'NR_RRC_harq_hacks' of https://gitlab.eurecom.fr/oai/openairinterface5g into NR_RRC_harq_hacks
This commit is contained in:
+161
-117
@@ -137,6 +137,12 @@ int main(int argc, char **argv)
|
||||
int i,aa;//,l;
|
||||
double sigma2, sigma2_dB=10, SNR, snr0=-2.0, snr1=2.0;
|
||||
uint8_t snr1set=0;
|
||||
float roundStats[50];
|
||||
float effRate;
|
||||
float psnr;
|
||||
float eff_tp_check = 0.7;
|
||||
uint8_t snrRun;
|
||||
uint32_t TBS;
|
||||
int **txdata;
|
||||
double **s_re,**s_im,**r_re,**r_im;
|
||||
//double iqim = 0.0;
|
||||
@@ -152,6 +158,8 @@ int main(int argc, char **argv)
|
||||
int trial, n_trials = 1, n_errors = 0, n_false_positive = 0;
|
||||
//int n_errors2, n_alamouti;
|
||||
uint8_t transmission_mode = 1,n_tx=1,n_rx=1;
|
||||
uint8_t round;
|
||||
uint8_t num_rounds = 4;
|
||||
|
||||
channel_desc_t *gNB2UE;
|
||||
//uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
|
||||
@@ -382,6 +390,10 @@ int main(int argc, char **argv)
|
||||
mu = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
eff_tp_check = (float)atoi(optarg)/100;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'h':
|
||||
printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n",
|
||||
@@ -411,6 +423,7 @@ int main(int argc, char **argv)
|
||||
printf("-c Start symbol for PDSCH (fixed for now)\n");
|
||||
printf("-j Number of symbols for PDSCH (fixed for now)\n");
|
||||
printf("-e MSC index\n");
|
||||
printf("-t Acceptable effective throughput (in percentage)\n");
|
||||
printf("-P Print DLSCH performances\n");
|
||||
exit (-1);
|
||||
break;
|
||||
@@ -677,6 +690,9 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
nr_ue_phy_config_request(&UE_mac->phy_config);
|
||||
NR_UE_list_t *UE_list = &RC.nrmac[0]->UE_list;
|
||||
NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels;
|
||||
snrRun = 0;
|
||||
|
||||
for (SNR = snr0; SNR < snr1; SNR += .2) {
|
||||
|
||||
@@ -694,6 +710,7 @@ int main(int argc, char **argv)
|
||||
reset_meas(&gNB->toutput);
|
||||
|
||||
n_errors = 0;
|
||||
effRate = 0;
|
||||
//n_errors2 = 0;
|
||||
//n_alamouti = 0;
|
||||
errors_scrambling=0;
|
||||
@@ -703,95 +720,7 @@ int main(int argc, char **argv)
|
||||
errors_bit = 0;
|
||||
//multipath channel
|
||||
//multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0);
|
||||
memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int));
|
||||
memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int));
|
||||
clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot);
|
||||
if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&pucch_sched,&dlsch_config);
|
||||
else nr_schedule_css_dlsch_phytest(0,frame,slot);
|
||||
|
||||
|
||||
Sched_INFO.module_id = 0;
|
||||
Sched_INFO.CC_id = 0;
|
||||
Sched_INFO.frame = frame;
|
||||
Sched_INFO.slot = slot;
|
||||
Sched_INFO.DL_req = &gNB_mac->DL_req[0];
|
||||
Sched_INFO.UL_tti_req = &gNB_mac->UL_tti_req[0];
|
||||
Sched_INFO.UL_dci_req = NULL;
|
||||
Sched_INFO.TX_req = &gNB_mac->TX_req[0];
|
||||
nr_schedule_response(&Sched_INFO);
|
||||
|
||||
if (run_initial_sync)
|
||||
nr_common_signal_procedures(gNB,frame,slot);
|
||||
else
|
||||
phy_procedures_gNB_TX(gNB,frame,slot,0);
|
||||
|
||||
int txdataF_offset = (slot%2) * frame_parms->samples_per_slot_wCP;
|
||||
|
||||
if (n_trials==1) {
|
||||
LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);
|
||||
if (gNB->frame_parms.nb_antennas_tx>1)
|
||||
LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);
|
||||
}
|
||||
int tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
|
||||
if (n_trials==1) printf("samples_per_slot_wCP = %d\n", frame_parms->samples_per_slot_wCP);
|
||||
|
||||
//TODO: loop over slots
|
||||
for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
|
||||
|
||||
if (cyclic_prefix_type == 1) {
|
||||
PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
|
||||
&txdata[aa][tx_offset],
|
||||
frame_parms->ofdm_symbol_size,
|
||||
12,
|
||||
frame_parms->nb_prefix_samples,
|
||||
CYCLIC_PREFIX);
|
||||
} else {
|
||||
nr_normal_prefix_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
|
||||
&txdata[aa][tx_offset],
|
||||
14,
|
||||
frame_parms);
|
||||
}
|
||||
}
|
||||
|
||||
if (n_trials==1) {
|
||||
LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1);
|
||||
if (gNB->frame_parms.nb_antennas_tx>1)
|
||||
LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1);
|
||||
}
|
||||
if (output_fd)
|
||||
fwrite(txdata[0],sizeof(int32_t),frame_length_complex_samples,output_fd);
|
||||
|
||||
int txlev = signal_energy(&txdata[0][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
|
||||
frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
|
||||
|
||||
// if (n_trials==1) printf("txlev %d (%f)\n",txlev,10*log10((double)txlev));
|
||||
|
||||
for (i=(frame_parms->get_samples_slot_timestamp(slot,frame_parms,0));
|
||||
i<(frame_parms->get_samples_slot_timestamp(slot+1,frame_parms,0));
|
||||
i++) {
|
||||
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
|
||||
r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]);
|
||||
r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]);
|
||||
}
|
||||
}
|
||||
|
||||
NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0];
|
||||
nfapi_nr_dl_tti_pdsch_pdu_rel15_t rel15 = gNB_dlsch->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15;
|
||||
|
||||
//AWGN
|
||||
sigma2_dB = 10 * log10((double)txlev * ((double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize))) - SNR;
|
||||
sigma2 = pow(10, sigma2_dB/10);
|
||||
if (n_trials==1) printf("sigma2 %f (%f dB), txlev %f (factor %f)\n",sigma2,sigma2_dB,10*log10((double)txlev),(double)(double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize));
|
||||
|
||||
for (i=frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
|
||||
i<frame_parms->get_samples_slot_timestamp(slot+1,frame_parms,0);
|
||||
i++) {
|
||||
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
|
||||
((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
|
||||
((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UE->rx_offset=0;
|
||||
UE_proc.frame_rx = frame;
|
||||
UE_proc.nr_tti_rx= slot;
|
||||
@@ -799,43 +728,144 @@ int main(int argc, char **argv)
|
||||
|
||||
dcireq.frame = frame;
|
||||
dcireq.slot = slot;
|
||||
|
||||
NR_UE_DLSCH_t *dlsch0 = UE->dlsch[UE->current_thread_id[UE_proc.nr_tti_rx]][0][0];
|
||||
|
||||
int harq_pid = dlsch0->current_harq_pid;
|
||||
NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid];
|
||||
|
||||
NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0];
|
||||
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &gNB_dlsch->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15;
|
||||
|
||||
nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
|
||||
nr_ue_scheduled_response(&scheduled_response);
|
||||
UE_harq_process->harq_ack.ack = 0;
|
||||
round = 0;
|
||||
UE_harq_process->round = round;
|
||||
UE_harq_process->first_tx = 1;
|
||||
|
||||
while ((round<num_rounds) && (UE_harq_process->harq_ack.ack==0)) {
|
||||
memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int));
|
||||
memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int));
|
||||
clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot);
|
||||
|
||||
UE_list->UE_sched_ctrl[0].harq_processes[0].ndi = !(trial&1);
|
||||
|
||||
UE_list->UE_sched_ctrl[0].harq_processes[0].round = round;
|
||||
gNB->dlsch[0][0]->harq_processes[0]->round = round;
|
||||
|
||||
phy_procedures_nrUE_RX(UE,
|
||||
&UE_proc,
|
||||
0,
|
||||
do_pdcch_flag,
|
||||
normal_txrx);
|
||||
|
||||
if (UE->dlsch[UE->current_thread_id[slot]][0][0]->last_iteration_cnt >=
|
||||
UE->dlsch[UE->current_thread_id[slot]][0][0]->max_ldpc_iterations+1)
|
||||
n_errors++;
|
||||
if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&pucch_sched,&dlsch_config);
|
||||
else nr_schedule_css_dlsch_phytest(0,frame,slot);
|
||||
Sched_INFO.module_id = 0;
|
||||
Sched_INFO.CC_id = 0;
|
||||
Sched_INFO.frame = frame;
|
||||
Sched_INFO.slot = slot;
|
||||
Sched_INFO.DL_req = &gNB_mac->DL_req[0];
|
||||
Sched_INFO.UL_tti_req = &gNB_mac->UL_tti_req[0];
|
||||
Sched_INFO.UL_dci_req = NULL;
|
||||
Sched_INFO.TX_req = &gNB_mac->TX_req[0];
|
||||
nr_schedule_response(&Sched_INFO);
|
||||
|
||||
if (run_initial_sync)
|
||||
nr_common_signal_procedures(gNB,frame,slot);
|
||||
else
|
||||
phy_procedures_gNB_TX(gNB,frame,slot,0);
|
||||
|
||||
int txdataF_offset = (slot%2) * frame_parms->samples_per_slot_wCP;
|
||||
|
||||
if (n_trials==1) {
|
||||
LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);
|
||||
if (gNB->frame_parms.nb_antennas_tx>1)
|
||||
LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);
|
||||
}
|
||||
int tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
|
||||
if (n_trials==1) printf("samples_per_slot_wCP = %d\n", frame_parms->samples_per_slot_wCP);
|
||||
|
||||
//TODO: loop over slots
|
||||
for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
|
||||
|
||||
if (cyclic_prefix_type == 1) {
|
||||
PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
|
||||
&txdata[aa][tx_offset],
|
||||
frame_parms->ofdm_symbol_size,
|
||||
12,
|
||||
frame_parms->nb_prefix_samples,
|
||||
CYCLIC_PREFIX);
|
||||
} else {
|
||||
nr_normal_prefix_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
|
||||
&txdata[aa][tx_offset],
|
||||
14,
|
||||
frame_parms);
|
||||
}
|
||||
}
|
||||
|
||||
if (n_trials==1) {
|
||||
LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1);
|
||||
if (gNB->frame_parms.nb_antennas_tx>1)
|
||||
LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1);
|
||||
}
|
||||
if (output_fd)
|
||||
fwrite(txdata[0],sizeof(int32_t),frame_length_complex_samples,output_fd);
|
||||
|
||||
int txlev = signal_energy(&txdata[0][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
|
||||
|
||||
// if (n_trials==1) printf("txlev %d (%f)\n",txlev,10*log10((double)txlev));
|
||||
|
||||
for (i=(frame_parms->get_samples_slot_timestamp(slot,frame_parms,0));
|
||||
i<(frame_parms->get_samples_slot_timestamp(slot+1,frame_parms,0));
|
||||
i++) {
|
||||
|
||||
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
|
||||
r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]);
|
||||
r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]);
|
||||
}
|
||||
}
|
||||
|
||||
//AWGN
|
||||
sigma2_dB = 10 * log10((double)txlev * ((double)UE->frame_parms.ofdm_symbol_size/(12*rel15->rbSize))) - SNR;
|
||||
sigma2 = pow(10, sigma2_dB/10);
|
||||
if (n_trials==1) printf("sigma2 %f (%f dB), txlev %f (factor %f)\n",sigma2,sigma2_dB,10*log10((double)txlev),(double)(double)UE->frame_parms.ofdm_symbol_size/(12*rel15->rbSize));
|
||||
|
||||
for (i=frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
|
||||
i<frame_parms->get_samples_slot_timestamp(slot+1,frame_parms,0);
|
||||
i++) {
|
||||
|
||||
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
|
||||
((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
|
||||
((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
|
||||
}
|
||||
}
|
||||
|
||||
nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
|
||||
nr_ue_scheduled_response(&scheduled_response);
|
||||
|
||||
phy_procedures_nrUE_RX(UE,
|
||||
&UE_proc,
|
||||
0,
|
||||
do_pdcch_flag,
|
||||
normal_txrx);
|
||||
|
||||
//printf("dlsim round %d ends\n",round);
|
||||
round++;
|
||||
} // round
|
||||
|
||||
//----------------------------------------------------------
|
||||
//---------------------- count errors ----------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
NR_UE_DLSCH_t *dlsch0 = UE->dlsch[UE->current_thread_id[UE_proc.nr_tti_rx]][0][0];
|
||||
|
||||
int harq_pid = dlsch0->current_harq_pid;
|
||||
NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid];
|
||||
|
||||
if (UE->dlsch[UE->current_thread_id[slot]][0][0]->last_iteration_cnt >=
|
||||
UE->dlsch[UE->current_thread_id[slot]][0][0]->max_ldpc_iterations+1)
|
||||
n_errors++;
|
||||
|
||||
NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars[UE->current_thread_id[UE_proc.nr_tti_rx]];
|
||||
int16_t *UE_llr = pdsch_vars[0]->llr[0];
|
||||
|
||||
|
||||
uint32_t TBS = rel15.TBSize[0];
|
||||
TBS = rel15->TBSize[0];
|
||||
uint16_t length_dmrs = 1;
|
||||
uint16_t nb_rb = rel15.rbSize;
|
||||
uint8_t nb_re_dmrs = rel15.dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4;
|
||||
uint8_t mod_order = rel15.qamModOrder[0];
|
||||
uint8_t nb_symb_sch = rel15.NrOfSymbols;
|
||||
uint16_t nb_rb = rel15->rbSize;
|
||||
uint8_t nb_re_dmrs = rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4;
|
||||
uint8_t mod_order = rel15->qamModOrder[0];
|
||||
uint8_t nb_symb_sch = rel15->NrOfSymbols;
|
||||
|
||||
available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15.nrOfLayers);
|
||||
available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15->nrOfLayers);
|
||||
|
||||
for (i = 0; i < available_bits; i++) {
|
||||
|
||||
@@ -875,15 +905,18 @@ int main(int argc, char **argv)
|
||||
if (n_trials == 1)
|
||||
printf("errors_bit = %u (trial %d)\n", errors_bit, trial);
|
||||
}
|
||||
|
||||
roundStats[snrRun]+=((float)round);
|
||||
if (UE_harq_process->harq_ack.ack==1) effRate += ((float)TBS)/round;
|
||||
} // noise trials
|
||||
|
||||
roundStats[snrRun]/=((float)n_trials);
|
||||
effRate /= n_trials;
|
||||
printf("*****************************************\n");
|
||||
printf("SNR %f, (false positive %f)\n", SNR,
|
||||
(float) n_errors / (float) n_trials);
|
||||
printf("*****************************************\n");
|
||||
printf("\n");
|
||||
printf("SNR %f : n_errors (negative CRC) = %d/%d, Channel BER %e\n", SNR, n_errors, n_trials,(double)errors_scrambling/available_bits/n_trials);
|
||||
printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, Eff Rate %.4f bits/slot, Eff Throughput %.2f\%, TBS %d bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],(double)errors_scrambling/available_bits/n_trials,effRate,effRate/TBS*100,TBS);
|
||||
printf("\n");
|
||||
|
||||
if (n_trials == 1) {
|
||||
@@ -896,7 +929,8 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((float)n_errors/(float)n_trials <= target_error_rate) {
|
||||
//if ((float)n_errors/(float)n_trials <= target_error_rate) {
|
||||
if (effRate >= (eff_tp_check*TBS)) {
|
||||
printf("PDSCH test OK\n");
|
||||
break;
|
||||
}
|
||||
@@ -951,8 +985,18 @@ int main(int argc, char **argv)
|
||||
printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC");
|
||||
*/
|
||||
}
|
||||
snrRun++;
|
||||
} // NSR
|
||||
|
||||
/*if (n_trials>1) {
|
||||
printf("HARQ stats:\nSNR\tRounds\n");
|
||||
psnr = snr0;
|
||||
for (uint8_t i=0; i<snrRun; i++) {
|
||||
printf("%.1f\t%.2f\n",psnr,roundStats[i]);
|
||||
psnr+=0.2;
|
||||
}
|
||||
}*/
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
free(s_re[i]);
|
||||
free(s_im[i]);
|
||||
|
||||
Reference in New Issue
Block a user