Commit 0033da56 authored by Romain Beurdouche's avatar Romain Beurdouche

fix(nr_ulschsim): make nr_ulschsim functional

There was two issues that were making nr_ulschsim non functional:
1. The channel output was not copied to decoder input (llr array)
2. The test on decoding successful outcome was wrong

The result was that nr_ulschsim was succesfull whatever were its arguments.
This commit fixes the two issues so that nr_ulschsim is now functional.
parent 1fdbf290
......@@ -448,6 +448,7 @@ int main(int argc, char **argv)
NR_gNB_ULSCH_t *ulsch_gNB = &gNB->ulsch[UE_id];
NR_UL_gNB_HARQ_t *harq_process_gNB = ulsch_gNB->harq_process;
nfapi_nr_pusch_pdu_t *rel15_ul = &harq_process_gNB->ulsch_pdu;
NR_gNB_PUSCH *pusch_vars = &gNB->pusch_vars[UE_id];
nr_phy_data_tx_t phy_data = {0};
NR_UE_ULSCH_t *ulsch_ue = &phy_data.ulsch;
......@@ -475,7 +476,6 @@ int main(int argc, char **argv)
///////////////////////////////////////////////////
double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc
short channel_output_fixed[16 * 68 * 384];
short channel_output_uncoded[16 * 68 * 384];
unsigned int errors_bit_uncoded = 0;
......@@ -526,12 +526,13 @@ int main(int argc, char **argv)
////////////////////////////////////////////////////////////////////
for (SNR = snr0; SNR < snr1 && !stop; SNR += snr_step) {
errors_bit_uncoded = 0;
n_errors = 0;
n_false_positive = 0;
for (trial = 0; trial < n_trials && !stop; trial++) {
errors_bit_uncoded = 0;
memset(pusch_vars->llr, 0, (8 * ((3 * 8 * 6144) + 12)) * sizeof(int16_t));
harq_process_gNB->harq_to_be_cleared = true;
for (i = 0; i < available_bits; i++) {
......@@ -555,16 +556,16 @@ int main(int argc, char **argv)
#if 1
SNR_lin = pow(10, SNR / 10.0);
sigma = 1.0 / sqrt(2 * SNR_lin);
channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0,
modulated_input[i] + sigma * gaussdouble(0.0, 1.0),
qbits);
pusch_vars->llr[i] = (int16_t) quantize(sigma / 4.0 / 4.0,
modulated_input[i] + sigma * gaussdouble(0.0, 1.0),
qbits);
#else
channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits);
pusch_vars->llr[i] = (int16_t) quantize(0.01, modulated_input[i], qbits);
#endif
//printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]);
//printf("pusch_vars->llr[%d]: %d\n", i, pusch_vars->llr[i]);
//Uncoded BER
if (channel_output_fixed[i] < 0)
if (pusch_vars->llr[i] < 0)
channel_output_uncoded[i] = 1; //QPSK demod
else
channel_output_uncoded[i] = 0;
......@@ -581,14 +582,19 @@ int main(int argc, char **argv)
exit(-1);
#endif
nr_ulsch_decoding(gNB, frame_parms, frame, subframe, &G, &UE_id, 1);
bool crc_valid = check_crc(harq_process_gNB->b, lenWithCrc(1, (harq_process_gNB->TBS) << 3), crcType(1, (harq_process_gNB->TBS) << 3));
if (!crc_valid) {
if (harq_process_gNB->processedSegments == harq_process_gNB->C) {
bool crc_valid = check_crc(harq_process_gNB->b, lenWithCrc(1, (harq_process_gNB->TBS) << 3), crcType(1, (harq_process_gNB->TBS) << 3));
if (!crc_valid) {
n_false_positive++;
}
} else {
n_errors++;
}
}
printf("*****************************************\n");
printf("SNR %f, BLER %f (false positive %f)\n", SNR,
printf("SNR %f, uncoded BER %f, BLER %f (false positive %f)\n", SNR,
(float) errors_bit_uncoded / (float) available_bits / (float) n_trials,
(float) n_errors / (float) n_trials,
(float) n_false_positive / (float) n_trials);
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