Commit 17e4f0f1 authored by Ahmed Hussein's avatar Ahmed Hussein Committed by Thomas Schlichter

Reordering frame and SNR loops

parent 675c0dff
...@@ -393,83 +393,87 @@ int main(int argc, char **argv) ...@@ -393,83 +393,87 @@ int main(int argc, char **argv)
unsigned char *estimated_output_bit; unsigned char *estimated_output_bit;
unsigned char *test_input_bit; unsigned char *test_input_bit;
uint32_t errors_bit = 0; uint32_t errors_decoding = 0;
uint32_t errors_scrambling = 0; uint32_t errors_scrambling = 0;
uint32_t frames_in_error = 0; uint32_t is_frame_in_error = 0;
test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
nr_scheduled_response_t scheduled_response; nr_scheduled_response_t scheduled_response;
fapi_nr_ul_config_request_t ul_config; fapi_nr_ul_config_request_t ul_config;
for (int frame = 0; frame < number_of_frames; frame++) {
// printf("***********\n");
// printf("frame = %d\n", frame);
// printf("***********\n");
UE_proc.nr_tti_tx = slot;
UE_proc.frame_tx = frame;
// --------- setting rel15_ul parameters for gNB --------
rel15_ul->rnti = n_rnti;
rel15_ul->ulsch_pdu_rel15.start_rb = start_rb;
rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb;
rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol;
rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch;
rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs;
rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs;
rel15_ul->ulsch_pdu_rel15.Qm = mod_order;
rel15_ul->ulsch_pdu_rel15.mcs = Imcs;
rel15_ul->ulsch_pdu_rel15.rv = 0;
rel15_ul->ulsch_pdu_rel15.ndi = 0;
rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers;
///////////////////////////////////////////////////
//fapi_nr_tx_request_t tx_request;
scheduled_response.module_id = 0; printf("\n");
scheduled_response.CC_id = 0;
scheduled_response.frame = frame; for (SNR = snr0; SNR < snr1; SNR += snr_step) {
scheduled_response.slot = slot;
scheduled_response.dl_config = NULL; printf("-------------------\n");
scheduled_response.ul_config = &ul_config; printf("SNR %f\n", SNR);
scheduled_response.dl_config = NULL; printf("-------------------\n");
ul_config.sfn_slot = slot; is_frame_in_error = 0;
ul_config.number_pdus = 1; for (int frame = 0; frame < number_of_frames; frame++) {
ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; UE_proc.nr_tti_tx = slot;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; UE_proc.frame_tx = frame;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; // --------- setting rel15_ul parameters for gNB --------
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; rel15_ul->rnti = n_rnti;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; rel15_ul->ulsch_pdu_rel15.start_rb = start_rb;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs;
//there are plenty of other parameters that we don't seem to be using for now. e.g. rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs;
//ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; rel15_ul->ulsch_pdu_rel15.Qm = mod_order;
rel15_ul->ulsch_pdu_rel15.mcs = Imcs;
// set FAPI parameters for UE, put them in the scheduled response and call rel15_ul->ulsch_pdu_rel15.rv = 0;
nr_ue_scheduled_response(&scheduled_response); rel15_ul->ulsch_pdu_rel15.ndi = 0;
rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers;
/////////////////////////phy_procedures_nr_ue_TX/////////////////////// ///////////////////////////////////////////////////
///////////
//fapi_nr_tx_request_t tx_request;
phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
scheduled_response.module_id = 0;
/////////// scheduled_response.CC_id = 0;
//////////////////////////////////////////////////// scheduled_response.frame = frame;
tx_offset = slot*frame_parms->samples_per_slot; scheduled_response.slot = slot;
scheduled_response.dl_config = NULL;
txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], scheduled_response.ul_config = &ul_config;
frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); scheduled_response.dl_config = NULL;
txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation ul_config.sfn_slot = slot;
ul_config.number_pdus = 1;
for (SNR = snr0; SNR < snr1; SNR += snr_step) { ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers;
ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid;
//there are plenty of other parameters that we don't seem to be using for now. e.g.
//ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0;
// set FAPI parameters for UE, put them in the scheduled response and call
nr_ue_scheduled_response(&scheduled_response);
/////////////////////////phy_procedures_nr_ue_TX///////////////////////
///////////
phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
///////////
////////////////////////////////////////////////////
tx_offset = slot*frame_parms->samples_per_slot;
txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 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);
txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation
n_errors = 0; n_errors = 0;
n_false_positive = 0; n_false_positive = 0;
...@@ -481,21 +485,29 @@ int main(int argc, char **argv) ...@@ -481,21 +485,29 @@ int main(int argc, char **argv)
for (trial = 0; trial < n_trials; trial++) { for (trial = 0; trial < n_trials; trial++) {
errors_scrambling = 0; errors_scrambling = 0;
errors_bit = 0; errors_decoding = 0;
//----------------------------------------------------------
//------------------------ add noise -----------------------
//----------------------------------------------------------
for (i=0; i<frame_length_complex_samples; i++) { for (i=0; i<frame_length_complex_samples; i++) {
for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) { for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point
((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP);
} }
} }
////////////////////////////////////////////////////////////
//----------------------------------------------------------
//------------------- gNB phy procedures -------------------
//----------------------------------------------------------
phy_procedures_gNB_common_RX(gNB, frame, slot); phy_procedures_gNB_common_RX(gNB, frame, slot);
phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols);
////////////////////////////////////////////////////////////
//---------------------------------------------------------- //----------------------------------------------------------
//---------------------- count errors ---------------------- //----------------- count and print errors -----------------
//---------------------------------------------------------- //----------------------------------------------------------
for (i = 0; i < available_bits; i++) { for (i = 0; i < available_bits; i++) {
...@@ -503,54 +515,49 @@ int main(int argc, char **argv) ...@@ -503,54 +515,49 @@ int main(int argc, char **argv)
if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) ||
((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0)))
{ {
if(errors_scrambling == 0) { if(errors_scrambling == 0)
printf("\n"); printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);
printf("First bit in error in unscrambling in frame %d = %d\n", frame, i);
}
errors_scrambling++; errors_scrambling++;
} }
} }
if (errors_scrambling > 0) {
printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling);
}
for (i = 0; i < TBS; i++) { for (i = 0; i < TBS; i++) {
estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7);
test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7);
if (estimated_output_bit[i] != test_input_bit[i]) { if (estimated_output_bit[i] != test_input_bit[i]) {
if(errors_bit == 0) if(errors_decoding == 0)
printf("First bit in error in decoding in frame %d = %d\n", frame, i); printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i);
errors_bit++; errors_decoding++;
} }
} }
//////////////////////////////////////////////////////////// if (errors_decoding > 0) {
is_frame_in_error = 1;
if (errors_scrambling > 0) {
if (n_trials == 1)
printf("frame %d, errors_scrambling = %d (trial %d)\n", frame, errors_scrambling, trial);
}
if (errors_bit > 0) {
frames_in_error++;
n_false_positive++; n_false_positive++;
printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %d\n" "\x1B[0m", frame, trial, errors_decoding);
if (n_trials == 1) } else {
printf("frame %d, errors_bit = %d (trial %d)\n", frame, errors_bit, trial); is_frame_in_error = 0;
break;
printf("*****************************************\n");
printf("SNR %f, (false positive %f)\n", SNR,
(float) n_false_positive / (float) n_trials);
printf("*****************************************\n");
printf("\n");
} }
} // [hna] for (trial = 0; trial < n_trials; trial++) ////////////////////////////////////////////////////////////
} // trial loop
if (errors_bit == 0) if (is_frame_in_error == 1)
break; break;
} // [hna] for (SNR = snr0; SNR < snr1; SNR += snr_step) } // frame loop
} // frame loop
if(frames_in_error == 0) { if(is_frame_in_error == 0)
break;
} // SNR loop
if(is_frame_in_error == 0) {
printf("\n");
printf("*************\n"); printf("*************\n");
printf("PUSCH test OK\n"); printf("PUSCH test OK\n");
printf("*************\n"); 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