From 1c57a8618c85c1a7b8407c1af63621f3c1583b31 Mon Sep 17 00:00:00 2001 From: Sagar Parsawar Date: Mon, 31 Jan 2022 12:25:52 +0100 Subject: [PATCH] bug fix for PRS DL channel estimation in OAI UE, added more debug prints --- openair1/PHY/NR_TRANSPORT/nr_prs.c | 2 +- .../nr_dl_channel_estimation.c | 53 ++++++++++++++----- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 4 +- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_prs.c b/openair1/PHY/NR_TRANSPORT/nr_prs.c index 55111333d8..079f8d89f1 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prs.c @@ -78,7 +78,7 @@ int nr_generate_prs(uint32_t **nr_gold_prs, k-=frame_parms->ofdm_symbol_size; } } - LOG_M("nr_prs.m", "prs",(int16_t *)&txdataF[0],frame_parms->samples_per_slot_wCP, 1, 1); + LOG_M("nr_prs.m", "prs",(int16_t *)&txdataF[prs_data->SymbolStart*frame_parms->ofdm_symbol_size],prs_data->NumPRSSymbols*frame_parms->ofdm_symbol_size, 1, 1); return 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 bb49846221..83b8422c4b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -81,8 +81,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, //re_offset k = re_offset = (prs_cfg->REOffset+k_prime) % prs_cfg->CombSize + frame_params->first_carrier_offset; - LOG_D(PHY, "PRS config l %d k_prime %d, re_offset %d :\nprs_cfg->SymbolStart %d\nprs_cfg->NumPRSSymbols %d\nprs_cfg->NumRB %d\nprs_cfg->CombSize %d\n", l, k_prime, re_offset, prs_cfg->SymbolStart, prs_cfg->NumPRSSymbols, prs_cfg->NumRB, prs_cfg->CombSize); - +#ifdef DEBUG_PRS_CHEST + printf("PRS config l %d k_prime %d, re_offset %d k %d :\nprs_cfg->SymbolStart %d\nprs_cfg->NumPRSSymbols %d\nprs_cfg->NumRB %d\nprs_cfg->CombSize %d\n", l, k_prime, re_offset, k, prs_cfg->SymbolStart, prs_cfg->NumPRSSymbols, prs_cfg->NumRB, prs_cfg->CombSize); +#endif // Pilots generation and modulation for (int m = 0; m < (12/prs_cfg->CombSize)*prs_cfg->NumRB; m++) { @@ -129,7 +130,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, //Start pilot ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fl, ch, ch_intrp, @@ -144,6 +147,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, { ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); +#ifdef DEBUG_PRS_CHEST + printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif if(pIdx == 1) // 2nd pilot { multadd_real_vector_complex_scalar(fml, @@ -164,6 +170,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); +#ifdef DEBUG_PRS_CHEST + printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx+1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif if(pIdx == (prs_cfg->NumRB*(12/prs_cfg->CombSize)-3)) // 2nd last pilot { multadd_real_vector_complex_scalar(fmr, @@ -188,7 +197,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, //End pilot ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fr, ch, ch_intrp, @@ -244,7 +255,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, //Start pilot ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fl, ch, ch_intrp, @@ -256,7 +269,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot 1 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fml, ch, ch_intrp, @@ -272,7 +287,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, { ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fmm, ch, ch_intrp, @@ -287,7 +304,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, //End pilot ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-2, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fmr, ch, ch_intrp, @@ -299,7 +318,9 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15); ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15); - +#ifdef DEBUG_PRS_CHEST + printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif multadd_real_vector_complex_scalar(fr, ch, ch_intrp, @@ -316,8 +337,10 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, { prs_chest[re_offset] = ch_intrp[re<<1]; prs_chest[re_offset+1] = ch_intrp[(re<<1)+1]; - LOG_D(PHY, "prs_ch[%d] %d %d\n", re_offset, ch_intrp[re<<1], ch_intrp[(re<<1)+1]); - re_offset = (re_offset+1) % frame_params->ofdm_symbol_size; +#ifdef DEBUG_PRS_CHEST + printf("prs_ch[%d] %d %d\n", re_offset, ch_intrp[re<<1], ch_intrp[(re<<1)+1]); +#endif + re_offset = (re_offset+2) % frame_params->ofdm_symbol_size; } // Time domain IMPULSE response @@ -368,14 +391,17 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue, memcpy((int16_t *)&ue->prs_ch_estimates_time[rxAnt][l*frame_params->ofdm_symbol_size], &ch_time[frame_params->ofdm_symbol_size>>1], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t)); memcpy((int16_t *)&ue->prs_ch_estimates_time[rxAnt][l*frame_params->ofdm_symbol_size + (frame_params->ofdm_symbol_size>>1)], &ch_time[0], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t)); } //for l - - LOG_M("rxSigF.m","rxF",&rxdataF[rxAnt][0], frame_params->symbols_per_slot*frame_params->ofdm_symbol_size,1,1); + LOG_M("PRSpilot.m", "prs_loc", &mod_prs[0], prs_cfg->NumRB*(12/prs_cfg->CombSize),1,1); + LOG_M("rxSigF.m","rxF",&rxdataF[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1); LOG_M("prsEstF.m","prs_chestF",&ue->prs_ch_estimates[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1); LOG_M("prsEstT.m","prs_chestT",&ue->prs_ch_estimates_time[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1); T(T_UE_PHY_DL_CHANNEL_ESTIMATE, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx), T_INT(0), T_BUFFER(&ue->prs_ch_estimates[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], frame_params->ofdm_symbol_size*sizeof(int32_t))); + + free(ch_intrp); + free(ch_time); return(0); } @@ -802,7 +828,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } } } - } return(0); } diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 11a19cc189..b59aea6c0d 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -83,14 +83,14 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ n_hf=1; ssb_index = ssb_pdu.ssb_pdu_rel15.SsbBlockIndex; - LOG_I(PHY,"common_signal_procedures: frame %d, slot %d ssb index %d\n",frame,slot,ssb_index); + LOG_D(PHY,"common_signal_procedures: frame %d, slot %d ssb index %d\n",frame,slot,ssb_index); int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp,ssb_index); // computing the starting symbol for current ssb ssb_start_symbol = ssb_start_symbol_abs % fp->symbols_per_slot; // start symbol wrt slot nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier - LOG_I(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); + LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); nr_generate_pss(gNB->d_pss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 9d017ab20c..3c79b79a0b 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -763,9 +763,9 @@ int main(int argc, char **argv) UE->prs_cfg.PRSResourceSetPeriod[1]=0; // resource slot offset UE->prs_cfg.SymbolStart=7; UE->prs_cfg.NumPRSSymbols=4; - UE->prs_cfg.NumRB=273; + UE->prs_cfg.NumRB=frame_parms->N_RB_DL; UE->prs_cfg.RBOffset=0; - UE->prs_cfg.CombSize=4; + UE->prs_cfg.CombSize=2; UE->prs_cfg.REOffset=0; UE->prs_cfg.PRSResourceOffset=0; UE->prs_cfg.PRSResourceRepetition=1;