diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 3b9b65b457..a7f0ef6682 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -66,14 +66,15 @@ __attribute__((always_inline)) inline c16_t c32x16cumulVectVectWithSteps(c16_t * int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, unsigned char Ns, + int nl, unsigned short p, unsigned char symbol, int ul_id, unsigned short bwp_start_subcarrier, nfapi_nr_pusch_pdu_t *pusch_pdu, int *max_ch, - uint32_t *nvar) { - + uint32_t *nvar) +{ c16_t pilot[3280] __attribute__((aligned(32))); const int chest_freq = gNB->chest_freq; @@ -81,20 +82,17 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, FILE *debug_ch_est; debug_ch_est = fopen("debug_ch_est.txt","w"); #endif - //uint16_t Nid_cell = (eNB_offset == 0) ? gNB->frame_parms.Nid_cell : gNB->measurements.adj_cell_id[eNB_offset-1]; NR_gNB_PUSCH *pusch_vars = &gNB->pusch_vars[ul_id]; c16_t **ul_ch_estimates = (c16_t **)pusch_vars->ul_ch_estimates; const int symbolSize = gNB->frame_parms.ofdm_symbol_size; - const int soffset = (Ns&3)*gNB->frame_parms.symbols_per_slot*symbolSize; + const int soffset = (Ns & 3) * gNB->frame_parms.symbols_per_slot*symbolSize; const int nushift = (p >> 1) & 1; - int ch_offset = symbolSize*symbol; + int ch_offset = symbolSize*symbol; const int symbol_offset = symbolSize*symbol; - const int k0 = bwp_start_subcarrier; const int nb_rb_pusch = pusch_pdu->rb_size; - LOG_D(PHY, "In %s: ch_offset %d, soffset %d, symbol_offset %d, OFDM size %d, Ns = %d, k0 = %d, symbol %d\n", - __FUNCTION__, + LOG_D(PHY, "ch_offset %d, soffset %d, symbol_offset %d, OFDM size %d, Ns = %d, k0 = %d, symbol %d\n", ch_offset, soffset, symbol_offset, symbolSize, @@ -154,7 +152,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, for (int aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { c16_t *rxdataF = (c16_t *)&gNB->common_vars.rxdataF[aarx][symbol_offset]; - c16_t *ul_ch = &ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; + c16_t *ul_ch = &ul_ch_estimates[nl * gNB->frame_parms.nb_antennas_rx + aarx][ch_offset]; memset(ul_ch,0,sizeof(*ul_ch)*symbolSize); #ifdef DEBUG_PUSCH @@ -235,7 +233,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, // Revert delay pilot_cnt = 0; - ul_ch = &ul_ch_estimates[p * gNB->frame_parms.nb_antennas_rx + aarx][ch_offset]; + ul_ch = &ul_ch_estimates[nl * gNB->frame_parms.nb_antennas_rx + aarx][ch_offset]; int inv_delay_idx = get_delay_idx(-delay->est_delay, MAX_DELAY_COMP); c16_t *ul_inv_delay_table = gNB->frame_parms.delay_table[inv_delay_idx]; for (int n = 0; n < 3 * nb_rb_pusch; n++) { @@ -450,7 +448,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, } #ifdef DEBUG_PUSCH - ul_ch = &ul_ch_estimates[p * gNB->frame_parms.nb_antennas_rx + aarx][ch_offset]; + ul_ch = &ul_ch_estimates[nl * gNB->frame_parms.nb_antennas_rx + aarx][ch_offset]; for (int idxP = 0; idxP < ceil((float)nb_rb_pusch * 12 / 8); idxP++) { for (int idxI = 0; idxI < 8; idxI++) { printf("%d\t%d\t", ul_ch[idxP * 8 + idxI].r, ul_ch[idxP * 8 + idxI].i); diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index 609fa6c0b3..cb1745b027 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -43,6 +43,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, unsigned char Ns, + int nl, unsigned short p, unsigned char symbol, int ul_id, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 8d0391c255..8ed0988ba6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -1450,16 +1450,13 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB, uint8_t slot, unsigned char harq_pid) { - uint8_t aarx; - uint32_t bwp_start_subcarrier; - NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id].harq_process->ulsch_pdu; NR_gNB_PUSCH *pusch_vars = &gNB->pusch_vars[ulsch_id]; pusch_vars->dmrs_symbol = INVALID_VALUE; gNB->nbSymb = 0; - bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start)*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; + uint32_t bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start) * NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; LOG_D(PHY,"pusch %d.%d : bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n", frame,slot,bwp_start_subcarrier, rel15_ul->rb_start, frame_parms->first_carrier_offset); LOG_D(PHY,"pusch %d.%d : ul_dmrs_symb_pos %x\n",frame,slot,rel15_ul->ul_dmrs_symb_pos); @@ -1477,11 +1474,12 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB, if (pusch_vars->dmrs_symbol == INVALID_VALUE) pusch_vars->dmrs_symbol = symbol; - for (int nl=0; nlnrOfLayers; nl++) { + for (int nl = 0; nl < rel15_ul->nrOfLayers; nl++) { uint32_t nvar_tmp = 0; nr_pusch_channel_estimation(gNB, slot, - get_dmrs_port(nl,rel15_ul->dmrs_ports), + nl, + get_dmrs_port(nl, rel15_ul->dmrs_ports), symbol, ulsch_id, bwp_start_subcarrier, @@ -1502,10 +1500,8 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB, frame_parms->nb_antennas_rx, frame_parms->N_RB_UL, false); - for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) - { - if (symbol == rel15_ul->start_symbol_index) - { + for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + if (symbol == rel15_ul->start_symbol_index) { pusch_vars->ulsch_power[aarx] = 0; pusch_vars->ulsch_noise_power[aarx] = 0; } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index c2dc115e5b..7b3f2f3f3d 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1500,6 +1500,7 @@ void NFAPI_NR_DMRS_TYPE2_average_prb(NR_DL_FRAME_PARMS *frame_parms, } int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, + int nl, unsigned short p, unsigned char symbol, unsigned char nscid, @@ -1544,13 +1545,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, // Note: pilot returned by the following function is already the complex conjugate of the transmitted DMRS nr_pdsch_dmrs_rx(ue, Ns, ue->nr_gold_pdsch[gNB_id][Ns][symbol][nscid], pilot, 1000 + p, 0, nb_rb_pdsch + rb_offset, config_type); - uint8_t nushift = 0; - if (config_type == NFAPI_NR_DMRS_TYPE1) { - nushift = (p >> 1) & 1; - } else { // NFAPI_NR_DMRS_TYPE2 - nushift = delta; - } - delay_t delay = {0}; for (int aarx = 0; aarx < ue->frame_parms.nb_antennas_rx; aarx++) { @@ -1561,8 +1555,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, printf("============================================\n"); #endif - c16_t *rxF = &rxdataF[aarx][symbol_offset + nushift]; - c16_t *dl_ch = (c16_t *)&dl_ch_estimates[p * ue->frame_parms.nb_antennas_rx + aarx][ch_offset]; + c16_t *rxF = &rxdataF[aarx][symbol_offset + delta]; + c16_t *dl_ch = (c16_t *)&dl_ch_estimates[nl * ue->frame_parms.nb_antennas_rx + aarx][ch_offset]; memset(dl_ch, 0, sizeof(*dl_ch) * ue->frame_parms.ofdm_symbol_size); if (config_type == NFAPI_NR_DMRS_TYPE1 && ue->chest_freq == 0) { @@ -1604,7 +1598,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, } #ifdef DEBUG_PDSCH - dl_ch = (c16_t *)&dl_ch_estimates[p * ue->frame_parms.nb_antennas_rx + aarx][ch_offset]; + dl_ch = (c16_t *)&dl_ch_estimates[nl * ue->frame_parms.nb_antennas_rx + aarx][ch_offset]; for (uint16_t idxP = 0; idxP < ceil((float)nb_rb_pdsch * 12 / 8); idxP++) { for (uint8_t idxI = 0; idxI < 8; idxI++) { printf("%4d\t%4d\t", dl_ch[idxP * 8 + idxI].r, dl_ch[idxP * 8 + idxI].i); diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 64875331e5..5b1e43f953 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -77,6 +77,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, + int nl, unsigned short p, unsigned char symbol, unsigned char nscid, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 60da51e885..fdd8b6acef 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -181,24 +181,24 @@ static void nr_dlsch_channel_level_median(uint32_t rx_size_symbol, @param phy_measurements Pointer to UE PHY measurements */ -void nr_dlsch_channel_compensation(uint32_t rx_size_symbol, - int nbRx, - c16_t rxdataF_ext[][rx_size_symbol], - int32_t dl_ch_estimates_ext[][rx_size_symbol], - int32_t dl_ch_mag[][nbRx][rx_size_symbol], - int32_t dl_ch_magb[][nbRx][rx_size_symbol], - int32_t dl_ch_magr[][nbRx][rx_size_symbol], - int32_t rxdataF_comp[][nbRx][rx_size_symbol * NR_SYMBOLS_PER_SLOT], - int ***rho, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_layers, - unsigned char symbol, - int length, - uint8_t first_symbol_flag, - unsigned char mod_order, - unsigned short nb_rb, - unsigned char output_shift, - PHY_NR_MEASUREMENTS *measurements); +static void nr_dlsch_channel_compensation(uint32_t rx_size_symbol, + int nbRx, + c16_t rxdataF_ext[][rx_size_symbol], + int32_t dl_ch_estimates_ext[][rx_size_symbol], + int32_t dl_ch_mag[][nbRx][rx_size_symbol], + int32_t dl_ch_magb[][nbRx][rx_size_symbol], + int32_t dl_ch_magr[][nbRx][rx_size_symbol], + int32_t rxdataF_comp[][nbRx][rx_size_symbol * NR_SYMBOLS_PER_SLOT], + int ***rho, + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_layers, + unsigned char symbol, + int length, + bool first_symbol_flag, + unsigned char mod_order, + unsigned short nb_rb, + unsigned char output_shift, + PHY_NR_MEASUREMENTS *measurements); /** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal @param dl_ch_estimates_ext Channel estimates in allocated RBs @@ -242,7 +242,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t dlsch[2], unsigned char symbol, - unsigned char first_symbol_flag, + bool first_symbol_flag, unsigned char harq_pid, uint32_t pdsch_est_size, int32_t dl_ch_estimates[][pdsch_est_size], @@ -434,7 +434,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //---------------------------------------------------------- if (meas_enabled) start_meas(&meas); - if (first_symbol_flag == 1) { + if (first_symbol_flag) { int32_t avg[MAX_ANT][MAX_ANT]; nr_dlsch_channel_level(rx_size_symbol, dl_ch_estimates_ext, frame_parms, nl, avg, symbol, nb_re_pdsch, nb_rb_pdsch); int avgs = 0; @@ -734,24 +734,24 @@ void nr_dlsch_deinterleaving(uint8_t symbol, // Pre-processing for LLR computation //============================================================================================== -void nr_dlsch_channel_compensation(uint32_t rx_size_symbol, - int nbRx, - c16_t rxdataF_ext[][rx_size_symbol], - int32_t dl_ch_estimates_ext[][rx_size_symbol], - int32_t dl_ch_mag[][nbRx][rx_size_symbol], - int32_t dl_ch_magb[][nbRx][rx_size_symbol], - int32_t dl_ch_magr[][nbRx][rx_size_symbol], - int32_t rxdataF_comp[][nbRx][rx_size_symbol * NR_SYMBOLS_PER_SLOT], - int ***rho, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_layers, - unsigned char symbol, - int length, - uint8_t first_symbol_flag, - unsigned char mod_order, - unsigned short nb_rb, - unsigned char output_shift, - PHY_NR_MEASUREMENTS *measurements) +static void nr_dlsch_channel_compensation(uint32_t rx_size_symbol, + int nbRx, + c16_t rxdataF_ext[][rx_size_symbol], + int32_t dl_ch_estimates_ext[][rx_size_symbol], + int32_t dl_ch_mag[][nbRx][rx_size_symbol], + int32_t dl_ch_magb[][nbRx][rx_size_symbol], + int32_t dl_ch_magr[][nbRx][rx_size_symbol], + int32_t rxdataF_comp[][nbRx][rx_size_symbol * NR_SYMBOLS_PER_SLOT], + int ***rho, + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_layers, + unsigned char symbol, + int length, + bool first_symbol_flag, + unsigned char mod_order, + unsigned short nb_rb, + unsigned char output_shift, + PHY_NR_MEASUREMENTS *measurements) { @@ -1034,7 +1034,7 @@ void nr_dlsch_channel_compensation(uint32_t rx_size_symbol, dl_ch128_2+=3; rho128+=3; } - if (first_symbol_flag==1) { + if (first_symbol_flag) { //rho_nm = H_arx_n.conj(H_arx_m) //rho_rx_corr[arx][nm] = |H_arx_n|^2.|H_arx_m|^2 &rho[aarx][l*n_layers+atx][symbol*nb_rb*12] measurements->rx_correlation[0][aarx][l * n_layers + atx] = signal_energy(&rho[aarx][l * n_layers + atx][symbol * nb_rb * 12],length); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index c58fd5888e..c83083080a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -397,7 +397,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t dlsch[2], unsigned char symbol, - unsigned char first_symbol_flag, + bool first_symbol_flag, unsigned char harq_pid, uint32_t pdsch_est_size, int32_t dl_ch_estimates[][pdsch_est_size], diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 0c253bb198..79b390216e 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -489,8 +489,6 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; - int m; - int first_symbol_flag=0; // We handle only one CW now if (!(NR_MAX_NB_LAYERS>4)) { @@ -523,13 +521,14 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, __attribute__((aligned(32))) int32_t rxdataF_comp[dlsch[0].Nl][ue->frame_parms.nb_antennas_rx][rx_size_symbol * NR_SYMBOLS_PER_SLOT]; memset(rxdataF_comp, 0, sizeof(rxdataF_comp)); - for (m = s0; m < (s0 +s1); m++) { + for (int m = s0; m < (s0 +s1); m++) { if (dlsch0->dlsch_config.dlDmrsSymbPos & (1 << m)) { - for (uint8_t aatx=0; aatxNl; aatx++) {//for MIMO Config: it shall loop over no_layers - LOG_D(PHY,"PDSCH Channel estimation gNB id %d, PDSCH antenna port %d, slot %d, symbol %d\n",0,aatx,nr_slot_rx,m); + for (int nl = 0; nl < dlsch0->Nl; nl++) { //for MIMO Config: it shall loop over no_layers + LOG_D(PHY,"PDSCH Channel estimation layer %d, slot %d, symbol %d\n", nl, nr_slot_rx, m); nr_pdsch_channel_estimation(ue, proc, - get_dmrs_port(aatx,dlsch0->dlsch_config.dmrs_ports), + nl, + get_dmrs_port(nl,dlsch0->dlsch_config.dmrs_ports), m, dlsch0->dlsch_config.nscid, dlsch0->dlsch_config.dlDmrsScramblingId, @@ -546,9 +545,9 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, int nr_frame_rx = proc->frame_rx; char filename[100]; for (uint8_t aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { - sprintf(filename,"PDSCH_CHANNEL_frame%d_slot%d_sym%d_port%d_rx%d.m", nr_frame_rx, nr_slot_rx, m, aatx,aarx); + sprintf(filename,"PDSCH_CHANNEL_frame%d_slot%d_sym%d_port%d_rx%d.m", nr_frame_rx, nr_slot_rx, m, nl, aarx); int **dl_ch_estimates = ue->pdsch_vars[gNB_id]->dl_ch_estimates; - LOG_M(filename,"channel_F",&dl_ch_estimates[aatx*ue->frame_parms.nb_antennas_rx+aarx][ue->frame_parms.ofdm_symbol_size*m],ue->frame_parms.ofdm_symbol_size, 1, 1); + LOG_M(filename,"channel_F",&dl_ch_estimates[nl*ue->frame_parms.nb_antennas_rx+aarx][ue->frame_parms.ofdm_symbol_size*m],ue->frame_parms.ofdm_symbol_size, 1, 1); } #endif } @@ -582,12 +581,10 @@ static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, int32_t log2_maxh = 0; start_meas(&ue->rx_pdsch_stats); - for (m = s0; m < (s1 + s0); m++) { - - if (m==first_symbol_with_data) - first_symbol_flag = 1; - else - first_symbol_flag = 0; + for (int m = s0; m < (s1 + s0); m++) { + bool first_symbol_flag = false; + if (m == first_symbol_with_data) + first_symbol_flag = true; uint8_t slot = 0; if(m >= ue->frame_parms.symbols_per_slot>>1)