Commit e21a0996 authored by Roberto Louro Magueta's avatar Roberto Louro Magueta Committed by rmagueta

Compute LLR for QPSK for ML

parent 8fffe50a
...@@ -292,6 +292,18 @@ void nr_ulsch_compute_llr(int32_t *rxdataF_comp, ...@@ -292,6 +292,18 @@ void nr_ulsch_compute_llr(int32_t *rxdataF_comp,
void reset_active_stats(PHY_VARS_gNB *gNB, int frame); void reset_active_stats(PHY_VARS_gNB *gNB, int frame);
void reset_active_ulsch(PHY_VARS_gNB *gNB, int frame); void reset_active_ulsch(PHY_VARS_gNB *gNB, int frame);
void nr_ulsch_compute_ML_llr(int32_t **rxdataF_comp,
int32_t ***rho,
int16_t **llr_layers,
uint8_t nb_antennas_rx,
uint32_t rb_size,
uint32_t nb_re,
uint8_t symbol,
uint32_t rxdataF_ext_offset,
uint8_t mod_order);
void nr_ulsch_shift_llr(int16_t **llr_layers, uint32_t nb_re, uint32_t rxdataF_ext_offset, uint8_t mod_order, int shift);
void nr_fill_ulsch(PHY_VARS_gNB *gNB, void nr_fill_ulsch(PHY_VARS_gNB *gNB,
int frame, int frame,
int slot, int slot,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
//#define DEBUG_CH_COMP //#define DEBUG_CH_COMP
//#define DEBUG_RB_EXT //#define DEBUG_RB_EXT
//#define DEBUG_CH_MAG //#define DEBUG_CH_MAG
//#define ML_DEBUG
#define INVALID_VALUE 255 #define INVALID_VALUE 255
...@@ -636,7 +637,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, ...@@ -636,7 +637,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10)
QAM_amp128b = _mm_setzero_si128(); QAM_amp128b = _mm_setzero_si128();
QAM_amp128c = _mm_setzero_si128(); QAM_amp128c = _mm_setzero_si128();
} }
else if (mod_order == 6) { else if (mod_order == 6) {
QAM_amp128 = _mm_set1_epi16(QAM64_n1); // QAM_amp128 = _mm_set1_epi16(QAM64_n1); //
QAM_amp128b = _mm_set1_epi16(QAM64_n2); QAM_amp128b = _mm_set1_epi16(QAM64_n2);
...@@ -1081,7 +1082,7 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, ...@@ -1081,7 +1082,7 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
int32_t **ul_ch_mag, int32_t **ul_ch_mag,
int32_t **ul_ch_magb, int32_t **ul_ch_magb,
int32_t **ul_ch_magc, int32_t **ul_ch_magc,
int32_t ***rho, int32_t ***rho,
uint8_t nrOfLayers, uint8_t nrOfLayers,
uint8_t symbol, uint8_t symbol,
uint16_t nb_rb, uint16_t nb_rb,
...@@ -1115,7 +1116,7 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, ...@@ -1115,7 +1116,7 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
ul_ch_mag128[1] = (__m128i *)&ul_ch_mag[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))]; ul_ch_mag128[1] = (__m128i *)&ul_ch_mag[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))];
ul_ch_mag128b[1] = (__m128i *)&ul_ch_magb[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))]; ul_ch_mag128b[1] = (__m128i *)&ul_ch_magb[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))];
ul_ch_mag128c[1] = (__m128i *)&ul_ch_magc[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))]; ul_ch_mag128c[1] = (__m128i *)&ul_ch_magc[aatx*frame_parms->nb_antennas_rx+aa][(symbol*(nb_re + off))];
// MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
for (i=0; i<nb_rb_0*3; i++) { for (i=0; i<nb_rb_0*3; i++) {
rxdataF_comp128[0][i] = _mm_adds_epi16(rxdataF_comp128[0][i],rxdataF_comp128[1][i]); rxdataF_comp128[0][i] = _mm_adds_epi16(rxdataF_comp128[0][i],rxdataF_comp128[1][i]);
...@@ -1898,6 +1899,9 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1898,6 +1899,9 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
unsigned char harq_pid) unsigned char harq_pid)
{ {
// Temporary flag: (true) ML receiver, (false) MMSE receiver
bool ml_rx = true;
uint8_t aarx, aatx; uint8_t aarx, aatx;
uint32_t nb_re_pusch, bwp_start_subcarrier; uint32_t nb_re_pusch, bwp_start_subcarrier;
int avgs = 0; int avgs = 0;
...@@ -2001,8 +2005,8 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -2001,8 +2005,8 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
int ad_shift = 0; int ad_shift = 0;
if (rel15_ul->nrOfLayers == 1) { if (rel15_ul->nrOfLayers == 1) {
ad_shift = 1 + log2_approx(frame_parms->nb_antennas_rx >> 2); ad_shift = 1 + log2_approx(frame_parms->nb_antennas_rx >> 2);
} else { } else if (ml_rx == false) {
ad_shift = -3; // For 2-layers, we are already doing a bit shift in the nr_ulsch_zero_forcing_rx_2layers() function, so we can use more bits ad_shift = -3; // For 2-layers, we are already doing a bit shift in the nr_ulsch_mmse_2layers() function, so we can use more bits
} }
for(uint8_t symbol = rel15_ul->start_symbol_index; symbol < (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols); symbol++) { for(uint8_t symbol = rel15_ul->start_symbol_index; symbol < (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols); symbol++) {
...@@ -2108,7 +2112,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -2108,7 +2112,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
nb_re_pusch); nb_re_pusch);
// Apply MMSE for 2 Tx layers // Apply MMSE for 2 Tx layers
if (rel15_ul->nrOfLayers == 2) { if (ml_rx == false && rel15_ul->nrOfLayers == 2) {
nr_ulsch_mmse_2layers(frame_parms, nr_ulsch_mmse_2layers(frame_parms,
pusch_vars->rxdataF_comp, pusch_vars->rxdataF_comp,
pusch_vars->ul_ch_mag0, pusch_vars->ul_ch_mag0,
...@@ -2159,16 +2163,45 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -2159,16 +2163,45 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
/*-------------------- LLRs computation -------------------------------------------------------------*/ /*-------------------- LLRs computation -------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------*/
start_meas(&gNB->ulsch_llr_stats); start_meas(&gNB->ulsch_llr_stats);
for (aatx=0; aatx < rel15_ul->nrOfLayers; aatx++) { if (ml_rx == false || rel15_ul->nrOfLayers == 1) {
nr_ulsch_compute_llr(&pusch_vars->rxdataF_comp[aatx*frame_parms->nb_antennas_rx][symbol * (off + rel15_ul->rb_size * NR_NB_SC_PER_RB)], for (aatx=0; aatx < rel15_ul->nrOfLayers; aatx++) {
pusch_vars->ul_ch_mag0[aatx*frame_parms->nb_antennas_rx], nr_ulsch_compute_llr(&pusch_vars->rxdataF_comp[aatx * frame_parms->nb_antennas_rx][symbol * (off + rel15_ul->rb_size * NR_NB_SC_PER_RB)],
pusch_vars->ul_ch_magb0[aatx*frame_parms->nb_antennas_rx], pusch_vars->ul_ch_mag0[aatx * frame_parms->nb_antennas_rx],
pusch_vars->ul_ch_magc0[aatx*frame_parms->nb_antennas_rx], pusch_vars->ul_ch_magb0[aatx * frame_parms->nb_antennas_rx],
&pusch_vars->llr_layers[aatx][rxdataF_ext_offset * rel15_ul->qam_mod_order], pusch_vars->ul_ch_magc0[aatx * frame_parms->nb_antennas_rx],
rel15_ul->rb_size, &pusch_vars->llr_layers[aatx][rxdataF_ext_offset * rel15_ul->qam_mod_order],
pusch_vars->ul_valid_re_per_slot[symbol], rel15_ul->rb_size,
symbol, pusch_vars->ul_valid_re_per_slot[symbol],
rel15_ul->qam_mod_order); symbol,
rel15_ul->qam_mod_order);
}
} else {
nr_ulsch_compute_ML_llr(pusch_vars->rxdataF_comp,
pusch_vars->rho,
pusch_vars->llr_layers,
frame_parms->nb_antennas_rx,
rel15_ul->rb_size,
nb_re_pusch,
symbol,
rxdataF_ext_offset,
rel15_ul->qam_mod_order);
if (rel15_ul->qam_mod_order == 2) {
nr_ulsch_shift_llr(pusch_vars->llr_layers, nb_re_pusch, rxdataF_ext_offset, rel15_ul->qam_mod_order, 4);
}
#ifdef ML_DEBUG
c16_t *llr_layers0 = (c16_t *)&pusch_vars->llr_layers[0][rxdataF_ext_offset * rel15_ul->qam_mod_order];
c16_t *llr_layers1 = (c16_t *)&pusch_vars->llr_layers[1][rxdataF_ext_offset * rel15_ul->qam_mod_order];
printf("===============================\n");
printf("AFTER nr_ulsch_compute_ML_llr()\n");
printf("===============================\n");
for (int k = 0; k < nb_re_pusch; k++) {
printf("[%3i] llr_layers0 = (%6i, %6i), llr_layers1 = (%6i, %6i)\n",
k, llr_layers0[k].r, llr_layers0[k].i, llr_layers1[k].r, llr_layers1[k].i);
}
printf("\n");
#endif
} }
stop_meas(&gNB->ulsch_llr_stats); stop_meas(&gNB->ulsch_llr_stats);
rxdataF_ext_offset += pusch_vars->ul_valid_re_per_slot[symbol]; rxdataF_ext_offset += pusch_vars->ul_valid_re_per_slot[symbol];
......
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