Commit 83ee05c0 authored by Melissa's avatar Melissa

Merge branch 'episys/sl_demodulation_update_for_16QAM' into 'episys/master-sl'

Update 16QAM operation for mcs 10 to 16

See merge request aburger/openairinterface5g!243
parents d2febea8 b8d49eac
......@@ -166,7 +166,13 @@ int write_file_matlab(const char *fname,
fprintf(fp,"%"PRIu32"\n",((uint32_t *)data)[i]);
}
break;
case 14:
for (i=0; i<length<<1; i+=(2*dec)) {
fprintf(fp,"%d+%dj\n",((short *)data)[i],((short *)data)[i+1]);
}
break;
case 15:
for (i=0; i<length<<1; i+=(2*dec)) {
fprintf(fp,"%d + j*(%d)\n",((short *)data)[i],((short *)data)[i+1]);
......
......@@ -621,8 +621,10 @@ void term_nr_ue_transport(PHY_VARS_NR_UE *ue)
{
const int N_RB_DL = ue->frame_parms.N_RB_DL;
const int N_RB_SL = ue->frame_parms.N_RB_SL;
int num_layers = get_softmodem_params()->sl_mode == 2 ? NR_MAX_NB_LAYERS_SL : NR_MAX_NB_LAYERS;
int num_codeword = num_layers > 4 ? 2 : 1;
for (int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) {
for (int j = 0; j < 2; j++) {
for (int j = 0; j < num_codeword; j++) {
for (int k = 0; k < RX_NB_TH_MAX; k++) {
free_nr_ue_dlsch(&ue->dlsch[k][i][j], N_RB_DL);
if (get_softmodem_params()->sl_mode == 2 || get_softmodem_params()->sl_mode == 1) {
......
......@@ -128,10 +128,7 @@ void nr_modulation(uint32_t *in,
uint8_t* in_bytes = (uint8_t*) in;
uint64_t* in64 = (uint64_t*) in;
int64_t* out64 = (int64_t*) out;
uint8_t idx;
uint32_t i,j;
uint32_t bit_cnt;
uint64_t x,x1,x2;
uint32_t i;
#if defined(__SSE2__)
__m128i *nr_mod_table128;
......@@ -152,7 +149,7 @@ void nr_modulation(uint32_t *in,
i = i*8/2;
nr_mod_table32 = (int32_t*) nr_qpsk_mod_table;
while (i<length/2) {
idx = ((in_bytes[(i*2)/8]>>((i*2)&0x7)) & mask);
const int idx = ((in_bytes[(i * 2) / 8] >> ((i * 2) & 0x7)) & mask);
out32[i] = nr_mod_table32[idx];
i++;
}
......@@ -161,7 +158,7 @@ void nr_modulation(uint32_t *in,
case 2:
nr_mod_table32 = (int32_t*) nr_qpsk_mod_table;
for (i=0; i<length/mod_order; i++) {
idx = ((in[i*2/32]>>((i*2)&0x1f)) & mask);
const int idx = ((in[i * 2 / 32] >> ((i * 2) & 0x1f)) & mask);
out32[i] = nr_mod_table32[idx];
}
return;
......@@ -174,66 +171,68 @@ void nr_modulation(uint32_t *in,
// the bits that are left out
i = i*8/4;
while (i<length/4) {
idx = ((in_bytes[(i*4)/8]>>((i*4)&0x7)) & mask);
const int idx = ((in_bytes[(i * 4) / 8] >> ((i * 4) & 0x7)) & mask);
out32[i] = nr_16qam_mod_table[idx];
i++;
}
return;
case 6:
j = 0;
for (i=0; i<length/192; i++) {
x = in64[i*3];
x1 = x&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x>>12)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x>>24)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x>>36)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x>>48)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x2 = (x>>60);
x = in64[i*3+1];
for (i = 0; i < length - 3 * 64; i += 3 * 64) {
uint64_t x = *in64++;
uint64_t x1 = x & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x >> 12) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x >> 24) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x >> 36) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x >> 48) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
uint64_t x2 = (x >> 60);
x = *in64++;
x2 |= x<<4;
x1 = x2&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>12)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>24)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>36)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>48)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = x2 & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 12) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 24) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 36) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 48) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x2 = ((x>>56)&0xf0) | (x2>>60);
x = in64[i*3+2];
x = *in64++;
x2 |= x<<8;
x1 = x2&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>12)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>24)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>36)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (x2>>48)&4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = x2 & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 12) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 24) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 36) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (x2 >> 48) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x2 = ((x>>52)&0xff0) | (x2>>60);
out64[j++] = nr_64qam_mod_table[x2];
*out64++ = nr_64qam_mod_table[x2];
}
i *= 24;
bit_cnt = i * 8;
while (bit_cnt < length) {
uint32_t xx;
memcpy(&xx, in_bytes+i, sizeof(xx));
x1 = xx & 4095;
out64[j++] = nr_64qam_mod_table[x1];
x1 = (xx >> 12) & 4095;
out64[j++] = nr_64qam_mod_table[x1];
i += 3;
bit_cnt += 24;
while (i + 24 <= length) {
uint32_t xx = 0;
memcpy(&xx, in_bytes + i / 8, 3);
uint64_t x1 = xx & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
x1 = (xx >> 12) & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
i += 24;
}
if (i != length) {
uint32_t xx = 0;
memcpy(&xx, in_bytes + i / 8, 2);
uint64_t x1 = xx & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
}
return;
......
......@@ -336,7 +336,7 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms,
c16_t rot2 = frame_parms->symbol_rotation[link_type][symbol + symb_offset];
rot2.i=-rot2.i;
LOG_I(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,rot2.r,rot2.i);
LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,rot2.r,rot2.i);
c16_t *shift_rot = frame_parms->timeshift_symbol_rotation;
c16_t *this_symbol = (c16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)];
......
......@@ -301,10 +301,10 @@ void free_ul_reference_signal_sequences(void)
for (Msc_RS=0; Msc_RS < SRS_SB_CONF; Msc_RS++) {
for (u=0; u < U_GROUP_NUMBER; u++) {
for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) {
if (rv_ul_ref_sig[u][v][Msc_RS])
if ((rv_ul_ref_sig) && (rv_ul_ref_sig[u][v][Msc_RS]))
free_and_zero(rv_ul_ref_sig[u][v][Msc_RS]);
if ((v==0) && (Msc_RS < MAX_INDEX_DMRS_UL_ALLOCATED_REs))
if (dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS])
if ((dmrs_lowpaprtype1_ul_ref_sig) && (dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS]))
free_and_zero(dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS]);
}
}
......
......@@ -40,6 +40,12 @@ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16
return(G);
}
uint32_t nr_get_G_sl(uint16_t nb_rb, uint16_t nb_re_sci1, uint16_t nb_re_sci2, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) {
uint32_t G;
G = (((NR_NB_SC_PER_RB * nb_symb_sch)-(nb_re_dmrs * length_dmrs)) * nb_rb - nb_re_sci1 - nb_re_sci2) * Qm * Nl;
return(G);
}
uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r) {
uint32_t E;
uint8_t Cprime = C; //assume CBGTI not present
......
......@@ -58,6 +58,8 @@ double nr_cyclic_shift_hopping(uint32_t n_id,
/** \brief Computes available bits G. */
uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint16_t length_dmrs, uint8_t Qm, uint8_t Nl);
uint32_t nr_get_G_sl(uint16_t nb_rb, uint16_t nb_re_sci1, uint16_t nb_re_sci2, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl);
uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r);
void compute_nr_prach_seq(uint8_t short_sequence,
......
......@@ -377,7 +377,6 @@ uint32_t nr_slsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
A = (harq_process->TBS) << 3;
ret = dlsch->max_ldpc_iterations + 1;
dlsch->last_iteration_cnt = ret;
harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl);
G = harq_process->G;
// target_code_rate is in 0.1 units
......
......@@ -82,7 +82,7 @@ void nr_slsch_extract_rbs(int32_t **rxdataF,
for (aatx = 0; aatx < pssch_pdu->nrOfLayers; aatx++) {
sl_ch0 = &pssch_vars->sl_ch_estimates[aatx * frame_parms->nb_antennas_rx + aarx][validDmrsEst * frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available
sl_ch0_ext = &pssch_vars->sl_ch_estimates_ext[aatx * frame_parms->nb_antennas_rx + aarx][symbol * nb_re_pssch2];
memcpy1((void*)sl_ch0_ext, (void*)sl_ch0, (nb_re_pssch - nb_re_sci1) * sizeof(int32_t));
memcpy1((void*)sl_ch0_ext, (void*)&sl_ch0[start_re], (nb_re_pssch - nb_re_sci1) * sizeof(int32_t));
}
} else { // DMRS case
......
This diff is collapsed.
......@@ -184,8 +184,9 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
///////////
uint32_t available_bits = G;
uint32_t scrambled_output[(available_bits>>5)+1];
memset(scrambled_output, 0, ((available_bits>>5)+1)*sizeof(uint32_t));
// +1 because size can be not modulo 4
uint32_t scrambled_output[available_bits / (8 * sizeof(uint32_t)) + 1];
memset(scrambled_output, 0, sizeof(scrambled_output));
nr_pusch_codeword_scrambling(harq_process_ul_ue->f,
available_bits,
......
......@@ -377,19 +377,11 @@ void free_context_synchro_nr(void)
free(synchroF_tmp);
synchroF_tmp = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
if (synchro_tmp != NULL) {
free(synchro_tmp);
synchro_tmp = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
#endif
......
......@@ -55,6 +55,7 @@
#include "PHY/impl_defs_top.h"
#include "PHY/MODULATION/modulation_common.h"
#define LDPC_MAX_LIMIT 31
#define DEBUG_NR_PSSCHSIM
// typedef struct {
......@@ -108,11 +109,12 @@ int N_RB_SL = 106;
int mu = 1;
int loglvl = OAILOG_WARNING;
int seed = 0;
int mcs = 0;
static void get_sim_cl_opts(int argc, char **argv)
{
char c;
while ((c = getopt(argc, argv, "F:g:hIL:l:m:M:n:N:o:O:p:P:r:R:s:S:x:y:z:")) != -1) {
while ((c = getopt(argc, argv, "F:g:hIL:l:m:M:n:N:o:O:p:P:r:R:s:S:t:x:y:z:")) != -1) {
switch (c) {
case 'F':
input_fd = fopen(optarg, "r");
......@@ -187,6 +189,10 @@ static void get_sim_cl_opts(int argc, char **argv)
snr1set = 1;
break;
case 't':
mcs = atoi(optarg);
break;
case 'y':
n_tx = atoi(optarg);
if ((n_tx == 0) || (n_tx > 2)) {
......@@ -357,14 +363,19 @@ int main(int argc, char **argv)
load_nrLDPClib(NULL);
PHY_VARS_NR_UE *txUE = malloc(sizeof(PHY_VARS_NR_UE));
txUE->sync_ref= true;
txUE->frame_parms.N_RB_SL = N_RB_SL;
txUE->frame_parms.Ncp = NORMAL;
txUE->frame_parms.nb_antennas_tx = 1;
txUE->frame_parms.nb_antennas_rx = n_rx;
txUE->frame_parms.Imcs = mcs;
txUE->max_ldpc_iterations = 5;
PHY_VARS_NR_UE *rxUE = malloc(sizeof(PHY_VARS_NR_UE));
rxUE->sync_ref= false;
rxUE->frame_parms.nb_antennas_tx = n_tx;
rxUE->frame_parms.nb_antennas_rx = 1;
rxUE->frame_parms.Imcs = mcs;
initTpool("n", &rxUE->threadPool, true);
initNotifiedFIFO(&rxUE->respDecode);
......@@ -433,6 +444,8 @@ int main(int argc, char **argv)
unsigned int errors_bit = 0;
unsigned int n_errors = 0;
unsigned int n_false_positive = 0;
unsigned int errors_bit_delta = 0;
unsigned int num_bytes_to_check = 80;
//double modulated_input[HNA_SIZE];
unsigned char test_input_bit[HNA_SIZE];
//short channel_output_uncoded[HNA_SIZE];
......@@ -453,7 +466,6 @@ int main(int argc, char **argv)
errors_bit = 0;
for (int trial = 0; trial < n_trials; trial++) {
for (int i = 0; i < frame_length_complex_samples; i++) {
for (int aa = 0; aa < txUE->frame_parms.nb_antennas_tx; aa++) {
r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i << 1)]);
......@@ -494,36 +506,41 @@ int main(int argc, char **argv)
txUE->slsch[0][0]->Nidx,
&proc);
if (ret)
n_errors++;
bool payload_type_string = true;
for (int i = 0; i < 200; i++) {
estimated_output_bit[i] = (harq_process_rxUE->b[i / 8] & (1 << (i & 7))) >> (i & 7);
test_input_bit[i] = (txUE->slsch[0][0]->harq_processes[harq_pid]->a[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments
bool polar_decoded = (ret < LDPC_MAX_LIMIT) ? true : false;
if (ret != -1) {
errors_bit_delta = 0;
bool payload_type_string = false;
for (int i = 0; i < num_bytes_to_check; i++) {
estimated_output_bit[i] = (harq_process_rxUE->b[i / 8] & (1 << (i & 7))) >> (i & 7);
test_input_bit[i] = (txUE->slsch[0][0]->harq_processes[harq_pid]->a[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments
#ifdef DEBUG_NR_PSSCHSIM
if (i % 8 == 0) {
if (payload_type_string) {
printf("TxByte : %c vs %c : RxByte\n", txUE->slsch[0][0]->harq_processes[harq_pid]->a[i / 8], harq_process_rxUE->b[i / 8]);
} else {
printf("TxByte : %2u vs %2u : RxByte\n", txUE->slsch[0][0]->harq_processes[harq_pid]->a[i / 8], harq_process_rxUE->b[i / 8]);
if (i % 8 == 0) {
if (payload_type_string) {
printf("TxByte : %c vs %c : RxByte\n", txUE->slsch[0][0]->harq_processes[harq_pid]->a[i / 8], harq_process_rxUE->b[i / 8]);
} else {
printf("TxByte : %2u vs %2u : RxByte\n", txUE->slsch[0][0]->harq_processes[harq_pid]->a[i / 8], harq_process_rxUE->b[i / 8]);
}
}
#endif
if (estimated_output_bit[i] != test_input_bit[i]) {
errors_bit_delta++;
}
}
#endif
if (estimated_output_bit[i] != test_input_bit[i]) {
errors_bit++;
if (errors_bit_delta > 0) {
n_false_positive++;
printf("errors_bit %u (trial %d)\n", errors_bit_delta, trial);
}
}
if (errors_bit > 0) {
n_false_positive++;
printf("errors_bit %u (trial %d)\n", errors_bit, trial);
if ((errors_bit_delta > 0) || (polar_decoded == false)) {
n_errors++;
}
errors_bit += errors_bit_delta;
}
} // trial
printf("*****************************************\n");
printf("SNR %f, BLER %f BER %f\n", SNR,
(float) n_errors / (float) n_trials,
(float) errors_bit / (float) (n_trials * 200));
(float) errors_bit / (float) (n_trials * num_bytes_to_check));
printf("*****************************************\n");
printf("\n");
......@@ -532,11 +549,15 @@ int main(int argc, char **argv)
printf("\n");
break;
}
else {
printf("PSSCH test NG due to number of error bits: %u\n", errors_bit);
printf("\n");
}
printf("\n");
} // snr
//term_nr_ue_transport(txUE);
term_nr_ue_transport(txUE);
term_nr_ue_transport(rxUE);
term_nr_ue_signal(rxUE, 1);
term_nr_ue_signal(txUE, 1);
......
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