diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e31f72eaea..cd64a66287 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -584,7 +584,7 @@ void processSlotTX(void *arg) { stop_meas(&UE->ue_ul_indication_stats); } - phy_procedures_nrUE_TX(UE, proc, proc->gNB_id, &phy_data); + phy_procedures_nrUE_TX(UE, proc, &phy_data); } RU_write(rxtxD); @@ -594,7 +594,6 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; - uint8_t gNB_id = 0; nr_phy_data_t phy_data = {0}; if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { @@ -611,7 +610,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { nr_downlink_indication_t dl_indication; - nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id, &phy_data); + nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, &phy_data); UE->if_inst->dl_indication(&dl_indication, NULL); } @@ -620,7 +619,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL ); #else uint64_t a=rdtsc_oai(); - phy_procedures_nrUE_RX(UE, proc, gNB_id, &phy_data); + phy_procedures_nrUE_RX(UE, proc, &phy_data); LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500); #endif diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 08d47bad0b..ac7d1ceed9 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -39,104 +39,6 @@ extern uint16_t beta_cqi[16]; -/*! \brief Helper function to allocate memory for DLSCH data structures. - * \param[out] pdsch Pointer to the LTE_UE_PDSCH structure to initialize. - * \param[in] frame_parms LTE_DL_FRAME_PARMS structure. - * \note This function is optimistic in that it expects malloc() to succeed. - */ -void phy_init_nr_ue_PDSCH(NR_UE_PDSCH *const pdsch, - const NR_DL_FRAME_PARMS *const fp) { - - AssertFatal( pdsch, "pdsch==0" ); - - pdsch->llr128 = (int16_t **)malloc16_clear( sizeof(int16_t *) ); - // FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV - // FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there - pdsch->rxdataF_ext = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->rxdataF_uespec_pilots = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->rxdataF_comp0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->rho = (int32_t ***)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t **) ); - pdsch->dl_ch_estimates = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_ch_estimates_ext = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_bf_ch_estimates = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_bf_ch_estimates_ext = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_ch_mag0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_ch_magb0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->dl_ch_magr0 = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->ptrs_phase_per_slot = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - pdsch->ptrs_re_per_slot = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - // the allocated memory size is fixed: - AssertFatal( fp->nb_antennas_rx <= 4, "nb_antennas_rx > 4" );//Extend the max number of UE Rx antennas to 4 - - const size_t num = 7*2*fp->N_RB_DL*12; - for (int i=0; inb_antennas_rx; i++) { - pdsch->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - pdsch->rxdataF_uespec_pilots[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); - pdsch->ptrs_phase_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * 14 ); - pdsch->ptrs_re_per_slot[i] = (int32_t *)malloc16_clear( sizeof(int32_t) * 14); - pdsch->rho[i] = (int32_t **)malloc16_clear( NR_MAX_NB_LAYERS*NR_MAX_NB_LAYERS*sizeof(int32_t *) ); - - for (int j=0; jnb_antennas_rx)+i; - for (int k=0; krho[i][j*NR_MAX_NB_LAYERS+k] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - } - pdsch->rxdataF_comp0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); - pdsch->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_bf_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); - pdsch->dl_bf_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_mag0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_magb0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_magr0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); - } - } -} - -void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp) -{ - for (int i = 0; i < fp->nb_antennas_rx; i++) { - for (int j = 0; j < NR_MAX_NB_LAYERS; j++) { - const int idx = j * fp->nb_antennas_rx + i; - for (int k = 0; k < NR_MAX_NB_LAYERS; k++) - free_and_zero(pdsch->rho[i][j*NR_MAX_NB_LAYERS+k]); - free_and_zero(pdsch->rxdataF_comp0[idx]); - free_and_zero(pdsch->dl_ch_estimates[idx]); - free_and_zero(pdsch->dl_ch_estimates_ext[idx]); - free_and_zero(pdsch->dl_bf_ch_estimates[idx]); - free_and_zero(pdsch->dl_bf_ch_estimates_ext[idx]); - free_and_zero(pdsch->dl_ch_mag0[idx]); - free_and_zero(pdsch->dl_ch_magb0[idx]); - free_and_zero(pdsch->dl_ch_magr0[idx]); - } - free_and_zero(pdsch->rxdataF_ext[i]); - free_and_zero(pdsch->rxdataF_uespec_pilots[i]); - free_and_zero(pdsch->ptrs_phase_per_slot[i]); - free_and_zero(pdsch->ptrs_re_per_slot[i]); - free_and_zero(pdsch->rho[i]); - } - free_and_zero(pdsch->pmi_ext); - int nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; - for (int i=0; illr[i]); - for (int i=0; ilayer_llr[i]); - free_and_zero(pdsch->llr128); - free_and_zero(pdsch->rxdataF_ext); - free_and_zero(pdsch->rxdataF_uespec_pilots); - free_and_zero(pdsch->rxdataF_comp0); - free_and_zero(pdsch->rho); - free_and_zero(pdsch->dl_ch_estimates); - free_and_zero(pdsch->dl_ch_estimates_ext); - free_and_zero(pdsch->dl_bf_ch_estimates); - free_and_zero(pdsch->dl_bf_ch_estimates_ext); - free_and_zero(pdsch->dl_ch_mag0); - free_and_zero(pdsch->dl_ch_magb0); - free_and_zero(pdsch->dl_ch_magr0); - free_and_zero(pdsch->ptrs_phase_per_slot); - free_and_zero(pdsch->ptrs_re_per_slot); -} - void RCconfig_nrUE_prs(void *cfg) { int j = 0, k = 0, gNB_id = 0; @@ -406,11 +308,9 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) // init RX buffers common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); - common_vars->rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); for (i=0; inb_antennas_rx; i++) { common_vars->rxdata[i] = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+fp->ofdm_symbol_size)*sizeof(int32_t) ); - common_vars->rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->samples_per_slot_wCP) ); } // ceil(((NB_RB<<1)*3)/32) // 3 RE *2(QPSK) @@ -453,19 +353,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } // DLSCH - for (gNB_id = 0; gNB_id < ue->n_connected_gNB+1; gNB_id++) { - ue->pdsch_vars[gNB_id] = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH)); - phy_init_nr_ue_PDSCH( ue->pdsch_vars[gNB_id], fp ); - - int nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; - for (i=0; ipdsch_vars[gNB_id]->llr[i] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );//Q_m = 8 bits/Sym, Code_Rate=3, Number of Segments =8, Circular Buffer K_cb = 8448 - } - for (i=0; ipdsch_vars[gNB_id]->layer_llr[i] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );//Q_m = 8 bits/Sym, Code_Rate=3, Number of Segments =8, Circular Buffer K_cb = 8448 - } - } - for (gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { prach_vars[gNB_id] = (NR_UE_PRACH *)malloc16_clear(sizeof(NR_UE_PRACH)); pbch_vars[gNB_id] = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH)); @@ -539,9 +426,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(common_vars->rxdata[i]); - free_and_zero(common_vars->rxdataF[i]); } - free_and_zero(common_vars->rxdataF); free_and_zero(common_vars->rxdata); for (int slot = 0; slot < fp->slots_per_frame; slot++) { @@ -564,10 +449,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int gNB_id = 0; gNB_id < ue->n_connected_gNB+1; gNB_id++) { // PDSCH - free_and_zero(ue->pdsch_vars[gNB_id]->llr_shifts); - free_and_zero(ue->pdsch_vars[gNB_id]->llr128_2ndstream); - phy_term_nr_ue__PDSCH(ue->pdsch_vars[gNB_id], fp); - free_and_zero(ue->pdsch_vars[gNB_id]); } for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) { @@ -628,7 +509,7 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } } -void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb) { +void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t harq_list[2][NR_MAX_DLSCH_HARQ_PROCESSES], int number_of_processes, int num_rb) { uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; if (num_rb != 273) { @@ -636,19 +517,21 @@ void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int a_segments = (a_segments/273)+1; } - for (int i=0; iframe_parms.N_RB_DL; const int N_RB_UL = ue->frame_parms.N_RB_UL; - int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; - for (int j = 0; j < num_cw; j++) { - free_nr_ue_dl_harq(ue->dl_harq_processes[j], NR_MAX_DLSCH_HARQ_PROCESSES, N_RB_DL); - } + free_nr_ue_dl_harq(ue->dl_harq_processes, NR_MAX_DLSCH_HARQ_PROCESSES, N_RB_DL); free_nr_ue_ul_harq(ue->ul_harq_processes, NR_MAX_ULSCH_HARQ_PROCESSES, N_RB_UL, ue->frame_parms.nb_antennas_tx); } -void nr_init_dl_harq_processes(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb) { +void nr_init_dl_harq_processes(NR_DL_UE_HARQ_t harq_list[2][NR_MAX_DLSCH_HARQ_PROCESSES], int number_of_processes, int num_rb) { int a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated if (num_rb != 273) { @@ -693,35 +573,39 @@ void nr_init_dl_harq_processes(NR_DL_UE_HARQ_t* harq_list, int number_of_process uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment - for (int i=0; i 4? 2:1; - - for (int j=0; jdl_harq_processes[j], NR_MAX_DLSCH_HARQ_PROCESSES, ue->frame_parms.N_RB_DL); - } + nr_init_dl_harq_processes(ue->dl_harq_processes, NR_MAX_DLSCH_HARQ_PROCESSES, ue->frame_parms.N_RB_DL); nr_init_ul_harq_processes(ue->ul_harq_processes, NR_MAX_ULSCH_HARQ_PROCESSES, ue->frame_parms.N_RB_UL, ue->frame_parms.nb_antennas_tx); for(int i=0; i<5; i++) diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index ed4b83fa5d..5ec47c1dae 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -418,10 +418,10 @@ void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg); void RCconfig_nrUE_prs(void *cfg); void init_nr_prs_ue_vars(PHY_VARS_NR_UE *ue); -void nr_init_dl_harq_processes(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb); -void nr_init_ul_harq_processes(NR_UL_UE_HARQ_t *harq_list, int number_of_processes, int num_rb, int num_ant_tx); -void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb); -void free_nr_ue_ul_harq(NR_UL_UE_HARQ_t *harq_list, int number_of_processes, int num_rb, int num_ant_tx); +void nr_init_dl_harq_processes(NR_DL_UE_HARQ_t harq_list[2][NR_MAX_DLSCH_HARQ_PROCESSES], int number_of_processes, int num_rb); +void nr_init_ul_harq_processes(NR_UL_UE_HARQ_t harq_list[NR_MAX_ULSCH_HARQ_PROCESSES], int number_of_processes, int num_rb, int num_ant_tx); +void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t harq_list[2][NR_MAX_DLSCH_HARQ_PROCESSES], int number_of_processes, int num_rb); +void free_nr_ue_ul_harq(NR_UL_UE_HARQ_t harq_list[NR_MAX_ULSCH_HARQ_PROCESSES], int number_of_processes, int num_rb, int num_ant_tx); /** @} */ #endif diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h index 6ed10a8c77..031b444323 100644 --- a/openair1/PHY/MODULATION/modulation_UE.h +++ b/openair1/PHY/MODULATION/modulation_UE.h @@ -51,14 +51,14 @@ int slot_fep(PHY_VARS_UE *phy_vars_ue, int nr_slot_fep(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, unsigned char l, - unsigned char Ns); + c16_t rxdataF[][phy_vars_ue->frame_parms.samples_per_slot_wCP]); int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, unsigned char symbol, - unsigned char Ns, int sample_offset, - bool pbch_decoded); + bool pbch_decoded, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, unsigned char l, diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index a8bbe34355..d902c2af47 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -37,10 +37,11 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, unsigned char symbol, - unsigned char Ns) + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_UE_COMMON *common_vars = &ue->common_vars; + int Ns = proc->nr_slot_rx; AssertFatal(symbol < frame_parms->symbols_per_slot, "slot_fep: symbol must be between 0 and %d\n", frame_parms->symbols_per_slot-1); AssertFatal(Ns < frame_parms->slots_per_frame, "slot_fep: Ns must be between 0 and %d\n", frame_parms->slots_per_frame-1); @@ -75,8 +76,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, //#endif for (unsigned char aa=0; aanb_antennas_rx; aa++) { - memset(&common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int32_t)); - int16_t *rxdata_ptr = (int16_t *)&common_vars->rxdata[aa][rx_offset]; // if input to dft is not 256-bit aligned @@ -92,7 +91,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, dft(dftsize, rxdata_ptr, - (int16_t *)&common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], + (int16_t *)&rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], 1); stop_meas(&ue->rx_dft_stats); @@ -108,7 +107,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, #endif c16_t *shift_rot = frame_parms->timeshift_symbol_rotation; - c16_t *this_symbol = (c16_t *)&common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol]; + c16_t *this_symbol = &rxdataF[aa][frame_parms->ofdm_symbol_size*symbol]; if (frame_parms->N_RB_DL & 1) { rotate_cpx_vector(this_symbol, &rot2, this_symbol, @@ -149,12 +148,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, unsigned char symbol, - unsigned char Ns, int sample_offset, - bool pbch_decoded) + bool pbch_decoded, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_UE_COMMON *common_vars = &ue->common_vars; + int Ns = proc->nr_slot_rx; AssertFatal(symbol < frame_parms->symbols_per_slot, "slot_fep: symbol must be between 0 and %d\n", frame_parms->symbols_per_slot-1); AssertFatal(Ns < frame_parms->slots_per_frame, "slot_fep: Ns must be between 0 and %d\n", frame_parms->slots_per_frame-1); @@ -189,7 +189,6 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, #endif for (unsigned char aa=0; aanb_antennas_rx; aa++) { - memset(&common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int32_t)); int16_t *rxdata_ptr; rx_offset%=frame_length_samples*2; @@ -225,7 +224,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, dft(dftsize, rxdata_ptr, - (int16_t *)&common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], + (int16_t *)&rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], 1); stop_meas(&ue->rx_dft_stats); @@ -240,7 +239,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, symbol+symb_offset,rot2.r,rot2.i); #endif - c16_t *this_symbol = (c16_t *)&common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*symbol]; + c16_t *this_symbol = &rxdataF[aa][frame_parms->ofdm_symbol_size*symbol]; rotate_cpx_vector(this_symbol, &rot2, this_symbol, frame_parms->ofdm_symbol_size, 15); } diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.c b/openair1/PHY/NR_REFSIG/dmrs_nr.c index 1fd502a93e..179c5d9cbd 100644 --- a/openair1/PHY/NR_REFSIG/dmrs_nr.c +++ b/openair1/PHY/NR_REFSIG/dmrs_nr.c @@ -341,7 +341,7 @@ int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t count /* perform averaging of channel estimates and store result in first symbol buffer */ void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms, - int **ch_est, + int32_t **ch_estimates, uint8_t num_symbols, uint8_t start_symbol, uint16_t dmrs_bitmap, @@ -356,9 +356,9 @@ void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms, AssertFatal(first_dmrs_symb > -1, "No DMRS symbol present in this slot\n"); for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { for (int symb = first_dmrs_symb+1; symb < total_symbols; symb++) { - ul_ch128_0 = (__m128i *)&ch_est[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; + ul_ch128_0 = (__m128i *)&ch_estimates[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; if ((dmrs_bitmap >> symb) & 0x01) { - ul_ch128_1 = (__m128i *)&ch_est[aarx][symb*frame_parms->ofdm_symbol_size]; + ul_ch128_1 = (__m128i *)&ch_estimates[aarx][symb*frame_parms->ofdm_symbol_size]; for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { ul_ch128_0[0] = _mm_adds_epi16(ul_ch128_0[0], ul_ch128_1[0]); ul_ch128_0[1] = _mm_adds_epi16(ul_ch128_0[1], ul_ch128_1[1]); @@ -368,7 +368,7 @@ void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms, } } } - ul_ch128_0 = (__m128i *)&ch_est[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; + ul_ch128_0 = (__m128i *)&ch_estimates[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; if (num_dmrs_symb == 2) { for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { ul_ch128_0[0] = _mm_srai_epi16(ul_ch128_0[0], 1); @@ -384,7 +384,7 @@ void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms, ul_ch128_0 += 3; } } else if (num_dmrs_symb == 3) { - ul_ch16_0 = (int16_t *)&ch_est[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; + ul_ch16_0 = (int16_t *)&ch_estimates[aarx][first_dmrs_symb*frame_parms->ofdm_symbol_size]; for (int rbIdx = 0; rbIdx < num_rbs; rbIdx++) { ul_ch16_0[0] /= 3; ul_ch16_0[1] /= 3; diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.h b/openair1/PHY/NR_REFSIG/dmrs_nr.h index 1297a0cc2f..4611e363e5 100644 --- a/openair1/PHY/NR_REFSIG/dmrs_nr.h +++ b/openair1/PHY/NR_REFSIG/dmrs_nr.h @@ -66,7 +66,7 @@ int8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, uint8_t get_dmrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t nb_symb); int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t counter); void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms, - int **ch_est, + int32_t **ch_estimates, uint8_t num_symbols, uint8_t start_symbol, uint16_t dmrs_bitmap, diff --git a/openair1/PHY/NR_REFSIG/sss_nr.h b/openair1/PHY/NR_REFSIG/sss_nr.h index 03610ae30f..212ee59c1d 100644 --- a/openair1/PHY/NR_REFSIG/sss_nr.h +++ b/openair1/PHY/NR_REFSIG/sss_nr.h @@ -96,7 +96,7 @@ int pss_ch_est_nr(PHY_VARS_NR_UE *ue, int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR], int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR]); -int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, uint8_t *phase_max, int *freq_offset_sss); +int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, uint8_t *phase_max, int *freq_offset_sss, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); #undef INIT_VARIABLES_SSS_NR_H #undef EXTERN 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 927734e538..0a0d92743d 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -61,15 +61,15 @@ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_idx = max_idx; } -int nr_prs_channel_estimation(uint8_t gNB_id, - uint8_t rsc_id, +int nr_prs_channel_estimation(uint8_t rsc_id, uint8_t rep_num, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - NR_DL_FRAME_PARMS *frame_params) + NR_DL_FRAME_PARMS *frame_params, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + int gNB_id = proc->gNB_id; uint8_t rxAnt = 0, idx = 0; - int32_t **rxdataF = ue->common_vars.rxdataF; prs_config_t *prs_cfg = &ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_cfg; prs_meas_t **prs_meas = ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_meas; c16_t ch_tmp_buf[ ue->frame_parms.ofdm_symbol_size] __attribute__((aligned(32))); @@ -567,11 +567,10 @@ int nr_prs_channel_estimation(uint8_t gNB_id, int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - unsigned char Ns, unsigned char symbol, int dmrss, - NR_UE_SSB *current_ssb) + NR_UE_SSB *current_ssb, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int pilot[200] __attribute__((aligned(16))); unsigned short k; @@ -583,7 +582,6 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, uint8_t nushift; uint8_t ssb_index=current_ssb->i_ssb; uint8_t n_hf=current_ssb->n_hf; - int **rxdataF=ue->common_vars.rxdataF; nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; @@ -600,7 +598,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, k = nushift; #ifdef DEBUG_PBCH - printf("PBCH DMRS Correlation : gNB_id %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n", gNB_id, ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp, Ns, k, symbol); + printf("PBCH DMRS Correlation : gNB_id %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n", proc->gNB_id, ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp, Ns, k, symbol); #endif // generate pilot @@ -730,13 +728,13 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, struct complex16 dl_ch_estimates [][estimateSz], struct complex16 dl_ch_estimates_time [][ue->frame_parms.ofdm_symbol_size], UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - unsigned char Ns, unsigned char symbol, int dmrss, uint8_t ssb_index, - uint8_t n_hf) + uint8_t n_hf, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + int Ns = proc->nr_slot_rx; int pilot[200] __attribute__((aligned(16))); unsigned short k; unsigned int pilot_cnt; @@ -745,8 +743,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, //int slot_pbch; uint8_t nushift; - int **rxdataF=ue->common_vars.rxdataF; - nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; @@ -764,7 +760,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, k = nushift; #ifdef DEBUG_PBCH - printf("PBCH Channel Estimation : gNB_id %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n", gNB_id, ch_offset, ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp, Ns, k, symbol); + printf("PBCH Channel Estimation : gNB_id %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n", proc->gNB_id, ch_offset, ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp, Ns, k, symbol); #endif switch (k) { @@ -994,24 +990,23 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - unsigned char Ns, unsigned char symbol, fapi_nr_coreset_t *coreset, uint16_t first_carrier_offset, uint16_t BWPStart, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size]) + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + int Ns = proc->nr_slot_rx; + int gNB_id = proc->gNB_id; unsigned char aarx; unsigned short k; unsigned int pilot_cnt; int16_t ch[2],*pil,*rxF,*dl_ch; int ch_offset,symbol_offset; - int **rxdataF=ue->common_vars.rxdataF; - ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; @@ -1239,9 +1234,7 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, bool is_SI, - unsigned char Ns, unsigned short p, unsigned char symbol, unsigned char nscid, @@ -1249,8 +1242,13 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned short BWPStart, uint8_t config_type, unsigned short bwp_start_subcarrier, - unsigned short nb_rb_pdsch) + unsigned short nb_rb_pdsch, + uint32_t pdsch_est_size, + int32_t dl_ch_estimates[][pdsch_est_size], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + int gNB_id = proc->gNB_id; + int Ns = proc->nr_slot_rx; int pilot[3280] __attribute__((aligned(16))); unsigned char aarx; unsigned short k; @@ -1260,9 +1258,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, int ch_offset,symbol_offset; uint8_t nushift; - int **dl_ch_estimates = ue->pdsch_vars[gNB_id]->dl_ch_estimates; - int **rxdataF=ue->common_vars.rxdataF; - ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; @@ -2030,7 +2025,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, * NAME : nr_pdsch_ptrs_processing * * PARAMETERS : PHY_VARS_NR_UE : ue data structure - * NR_UE_PDSCH : pdsch_vars pointer + * c16_t : ptrs_phase_per_slot array + * int32_t : ptrs_re_per_slot array + * uint32_t : rx_size, + * int32_t : rxdataF_comp, array * NR_DL_FRAME_PARMS : frame_parms pointer * NR_DL_UE_HARQ_t : dlsch0_harq pointer * NR_DL_UE_HARQ_t : dlsch1_harq pointer @@ -2049,7 +2047,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, * 3) Compensate signal with PTRS estimation for slot *********************************************************************/ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, - NR_UE_PDSCH **pdsch_vars, + c16_t ptrs_phase_per_slot[][14], + int32_t ptrs_re_per_slot[][14], + uint32_t rx_size, + int32_t rxdataF_comp[][rx_size], NR_DL_FRAME_PARMS *frame_parms, NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq, @@ -2104,8 +2105,8 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, } /* loop over antennas */ for (int aarx=0; aarxnb_antennas_rx; aarx++) { - c16_t *phase_per_symbol = (c16_t*)pdsch_vars[gNB_id]->ptrs_phase_per_slot[aarx]; - ptrs_re_symbol = (int32_t*)pdsch_vars[gNB_id]->ptrs_re_per_slot[aarx]; + c16_t *phase_per_symbol = (c16_t*)ptrs_phase_per_slot[aarx]; + ptrs_re_symbol = (int32_t*)ptrs_re_per_slot[aarx]; ptrs_re_symbol[symbol] = 0; phase_per_symbol[symbol].i = 0; // Imag /* set DMRS estimates to 0 angle with magnitude 1 */ @@ -2141,7 +2142,7 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, rnti, nr_slot_rx, symbol,frame_parms->ofdm_symbol_size, - (int16_t*)&pdsch_vars[gNB_id]->rxdataF_comp0[aarx][(symbol * nb_re_pdsch)], + (int16_t*)&rxdataF_comp[aarx][(symbol * nb_re_pdsch)], ue->nr_gold_pdsch[gNB_id][nr_slot_rx][symbol][0], (int16_t*)&phase_per_symbol[symbol], &ptrs_re_symbol[symbol]); @@ -2161,9 +2162,9 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, } } #ifdef DEBUG_DL_PTRS - LOG_M("ptrsEst.m","est",pdsch_vars[gNB_id]->ptrs_phase_per_slot[aarx],frame_parms->symbols_per_slot,1,1 ); + LOG_M("ptrsEst.m","est",ptrs_phase_per_slot[aarx],frame_parms->symbols_per_slot,1,1 ); LOG_M("rxdataF_bf_ptrs_comp.m","bf_ptrs_cmp", - &pdsch_vars[gNB_id]->rxdataF_comp0[aarx][(*startSymbIndex) * NR_NB_SC_PER_RB * (*nb_rb) ], + &rxdataF_comp[aarx][(*startSymbIndex) * NR_NB_SC_PER_RB * (*nb_rb) ], (*nb_rb) * NR_NB_SC_PER_RB * (*nbSymb),1,1); #endif /*------------------------------------------------------------------------------------------------------- */ @@ -2176,9 +2177,9 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, #ifdef DEBUG_DL_PTRS printf("[PHY][DL][PTRS]: Rotate Symbol %2d with %d + j* %d\n", i, phase_per_symbol[i].r,phase_per_symbol[i].i); #endif - rotate_cpx_vector((c16_t*)&pdsch_vars[gNB_id]->rxdataF_comp0[aarx][(i * (*nb_rb) * NR_NB_SC_PER_RB)], + rotate_cpx_vector((c16_t*)&rxdataF_comp[aarx][(i * (*nb_rb) * NR_NB_SC_PER_RB)], &phase_per_symbol[i], - (c16_t*)&pdsch_vars[gNB_id]->rxdataF_comp0[aarx][(i * (*nb_rb) * NR_NB_SC_PER_RB)], + (c16_t*)&rxdataF_comp[aarx][(i * (*nb_rb) * NR_NB_SC_PER_RB)], ((*nb_rb) * NR_NB_SC_PER_RB), 15); }// if not DMRS Symbol }// symbol loop diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index c8ae045e1b..cf4917369a 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -33,12 +33,12 @@ #define SYNCH_HYST 2 /* A function to perform the channel estimation of DL PRS signal */ -int nr_prs_channel_estimation(uint8_t gNB_id, - uint8_t rsc_id, +int nr_prs_channel_estimation(uint8_t rsc_id, uint8_t rep_num, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - NR_DL_FRAME_PARMS *frame_params); + NR_DL_FRAME_PARMS *frame_params, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); /* Generic function to find the peak of channel estimation buffer */ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val); @@ -52,40 +52,35 @@ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t */ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - unsigned char Ns, unsigned char symbol, fapi_nr_coreset_t *coreset, uint16_t first_carrier_offset, uint16_t BWPStart, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size]); + int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - unsigned char Ns, unsigned char symbol, int dmrss, - NR_UE_SSB *current_ssb); + NR_UE_SSB *current_ssb, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int estimateSz, - struct complex16 dl_ch_estimates [][estimateSz], - struct complex16 dl_ch_estimates_time [][estimateSz], - UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - unsigned char Ns, + struct complex16 dl_ch_estimates [][estimateSz], + struct complex16 dl_ch_estimates_time [][estimateSz], + UE_nr_rxtx_proc_t *proc, unsigned char symbol, int dmrss, uint8_t ssb_index, - uint8_t n_hf); + uint8_t n_hf, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, bool is_SI, - unsigned char Ns, unsigned short p, unsigned char symbol, unsigned char nscid, @@ -93,7 +88,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned short BWPStart, uint8_t config_type, unsigned short bwp_start_subcarrier, - unsigned short nb_rb_pdsch); + unsigned short nb_rb_pdsch, + uint32_t pdsch_est_size, + int32_t pdsch_dl_ch_estimates[][pdsch_est_size], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *ue, @@ -107,24 +105,28 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, void nr_ue_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t slot, - NR_UE_DLSCH_t *dlsch); + NR_UE_DLSCH_t *dlsch, + uint32_t pdsch_est_size, + int32_t dl_ch_estimates[][pdsch_est_size]); void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, uint8_t gNB_index, UE_nr_rxtx_proc_t *proc, - uint8_t slot); + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t slot); + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue, uint32_t rx_power_fil_dB, uint8_t gNB_id); void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, - NR_UE_PDSCH **pdsch_vars, + c16_t ptrs_phase_per_slot[][14], + int32_t ptrs_re_per_slot[][14], + uint32_t rx_size, + int32_t rxdataF_comp[][rx_size], NR_DL_FRAME_PARMS *frame_parms, NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 1b5689f335..5545f5c4bd 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -76,9 +76,11 @@ float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index) void nr_ue_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t slot, - NR_UE_DLSCH_t *dlsch) + NR_UE_DLSCH_t *dlsch, + uint32_t pdsch_est_size, + int32_t dl_ch_estimates[][pdsch_est_size]) { + int slot = proc->nr_slot_rx; int aarx, aatx, gNB_id = 0; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int ch_offset = frame_parms->ofdm_symbol_size*2; @@ -97,7 +99,7 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, for (aatx = 0; aatx < frame_parms->nb_antenna_ports_gNB; aatx++){ - ue->measurements.rx_spatial_power[gNB_id][aatx][aarx] = (signal_energy_nodc(&ue->pdsch_vars[0]->dl_ch_estimates[gNB_id][ch_offset], N_RB_DL*NR_NB_SC_PER_RB)); + ue->measurements.rx_spatial_power[gNB_id][aatx][aarx] = (signal_energy_nodc(&dl_ch_estimates[gNB_id][ch_offset], N_RB_DL*NR_NB_SC_PER_RB)); if (ue->measurements.rx_spatial_power[gNB_id][aatx][aarx]<0) ue->measurements.rx_spatial_power[gNB_id][aatx][aarx] = 0; @@ -170,10 +172,11 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, int ssb_index, UE_nr_rxtx_proc_t *proc, - uint8_t slot) { + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int k_start = 56; int k_end = 183; + int slot = proc->nr_slot_rx; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; int symbol_offset = nr_get_ssb_start_symbol(&ue->frame_parms,ssb_index); @@ -192,7 +195,7 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, for (int aarx = 0; aarx < ue->frame_parms.nb_antennas_rx; aarx++) { - int16_t *rxF_sss = (int16_t *)&ue->common_vars.rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; + int16_t *rxF_sss = (int16_t *)&rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; for(int k = k_start; k < k_end; k++){ @@ -225,9 +228,10 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, // - psd_awgn (AWGN power spectral density): dBm/Hz void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t slot){ + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]){ uint8_t k; + int slot = proc->nr_slot_rx; int aarx, nb_nulls; int16_t *rxF_sss; uint8_t k_left = 48; @@ -246,7 +250,7 @@ void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, nb_nulls = 0; ue->measurements.n0_power[aarx] = 0; - rxF_sss = (int16_t *)&ue->common_vars.rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; + rxF_sss = (int16_t *)&rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; //-ve spectrum from SSS for(k = k_left; k < k_left + k_length; k++){ diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 64222cab9a..6768c8bc37 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -190,9 +190,9 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, const uint8_t *l_overline, int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], uint32_t *rsrp, - int *rsrp_dBm) { + int *rsrp_dBm, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - int32_t **rxdataF = ue->common_vars.rxdataF; const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; uint16_t meas_count = 0; uint32_t rsrp_sum = 0; @@ -218,7 +218,7 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, for (int lp = 0; lp <= l_prime; lp++) { uint16_t symb = lp + l_overline[cdm_id]; uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; - c16_t *rx_signal = (c16_t*)&rxdataF[ant_rx][symbol_offset]; + c16_t *rx_signal = &rxdataF[ant_rx][symbol_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; rx_csi_rs_signal[k].r = rx_signal[k].r; rx_csi_rs_signal[k].i = rx_signal[k].i; @@ -729,9 +729,9 @@ int nr_csi_rs_cqi_estimation(const uint32_t precoded_sinr, int nr_csi_im_power_estimation(const PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, const fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu, - uint32_t *interference_plus_noise_power) { + uint32_t *interference_plus_noise_power, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - int32_t **rxdataF = ue->common_vars.rxdataF; const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; const uint16_t end_rb = csiim_config_pdu->start_rb + csiim_config_pdu->nr_of_rbs > csiim_config_pdu->bwp_size ? @@ -764,7 +764,7 @@ int nr_csi_im_power_estimation(const PHY_VARS_NR_UE *ue, for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { - c16_t *rx_signal = (c16_t*)&rxdataF[ant_rx][symbol_offset]; + c16_t *rx_signal = &rxdataF[ant_rx][symbol_offset]; for (int rb = csiim_config_pdu->start_rb; rb < end_rb; rb++) { @@ -800,8 +800,9 @@ int nr_csi_im_power_estimation(const PHY_VARS_NR_UE *ue, return 0; } -int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + int gNB_id = proc->gNB_id; if(!ue->csiim_vars[gNB_id]->active) { return -1; } @@ -818,14 +819,15 @@ int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t LOG_I(NR_PHY, "csiim_config_pdu->l_csiim = %i.%i.%i.%i\n", csiim_config_pdu->l_csiim[0], csiim_config_pdu->l_csiim[1], csiim_config_pdu->l_csiim[2], csiim_config_pdu->l_csiim[3]); #endif - nr_csi_im_power_estimation(ue, proc, csiim_config_pdu, &ue->nr_csi_info->interference_plus_noise_power); + nr_csi_im_power_estimation(ue, proc, csiim_config_pdu, &ue->nr_csi_info->interference_plus_noise_power, rxdataF); ue->nr_csi_info->csi_im_meas_computed = true; return 0; } -int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { +int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + int gNB_id = proc->gNB_id; if(!ue->csirs_vars[gNB_id]->active) { return -1; } @@ -901,7 +903,8 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t l_overline, csi_rs_received_signal, &rsrp, - &rsrp_dBm); + &rsrp_dBm, + rxdataF); nr_csi_rs_channel_estimation(ue, proc, @@ -958,8 +961,8 @@ int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t csirs_measurements.cqi = cqi; nr_downlink_indication_t dl_indication; fapi_nr_rx_indication_t *rx_ind = calloc(sizeof(*rx_ind),1); - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); - nr_fill_rx_indication(rx_ind, FAPI_NR_CSIRS_IND, gNB_id, ue, NULL, NULL, 1, proc, (void *)&csirs_measurements); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, NULL); + nr_fill_rx_indication(rx_ind, FAPI_NR_CSIRS_IND, ue, NULL, NULL, 1, proc, (void *)&csirs_measurements); if (ue->if_inst && ue->if_inst->dl_indication) { ue->if_inst->dl_indication(&dl_indication, NULL); } else { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 315519bf99..423140fc7a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -340,7 +340,8 @@ void nr_pdcch_channel_level(int32_t rx_size, // This function will extract the mapped DM-RS PDCCH REs as per 38.211 Section 7.4.1.3.2 (Mapping to physical resources) -void nr_pdcch_extract_rbs_single(int32_t **rxdataF, +void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, + c16_t rxdataF[][rxdataF_sz], int32_t est_size, int32_t dl_ch_estimates[][est_size], int32_t rx_size, @@ -415,7 +416,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, // first we set initial conditions for pointer to rxdataF depending on the situation of the first RB within the CORESET (c_rb = n_BWP_start) if (((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) == 0)) { //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): even case - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; + rxF = (int32_t *)&rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; LOG_DDD("in even case c_rb (%d) is lower than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); } @@ -423,14 +424,14 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if (((c_rb + n_BWP_start) >= (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) == 0)) { // number of RBs is even and c_rb is higher than half system bandwidth (we don't skip DC) // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF - rxF = &rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol + rxF = (int32_t *)&rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol LOG_DDD("in even case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", c_rb,aarx,(12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size)); } if (((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): odd case - rxF = &rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; + rxF = (int32_t *)&rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; LOG_DDD("in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", c_rb,aarx,(frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size)); } @@ -438,7 +439,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if (((c_rb + n_BWP_start) > (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { // number of RBs is odd and c_rb is higher than half system bandwidth + 1 // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF just after the first IQ symbols of the RB containing DC - rxF = &rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol + rxF = (int32_t *)&rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol LOG_DDD("in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", c_rb,aarx,(12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size)); } @@ -446,7 +447,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if (((c_rb + n_BWP_start) == (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { // treatment of RB containing the DC // if odd number RBs in system bandwidth and first RB to be treated is higher than middle system bandwidth (around DC) // we have to treat the RB in two parts: first part from i=0 to 5, the data is at the end of rxdataF (pointing at the end of the table) - rxF = &rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; + rxF = (int32_t *)&rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; LOG_DDD("in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", c_rb,aarx,(frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size)); j = 0; @@ -467,7 +468,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, } // then we point at the begining of the symbol part of rxdataF do process second part of RB - rxF = &rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol + rxF = (int32_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol LOG_DDD("in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][symbol * frame_parms->ofdm_symbol_size = (%d)]\n", c_rb,aarx,(symbol * frame_parms->ofdm_symbol_size)); for (; i < 12; i++) { @@ -671,11 +672,11 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], int16_t *pdcch_e_rx, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { uint32_t frame = proc->frame_rx; uint32_t slot = proc->nr_slot_rx; - NR_UE_COMMON *common_vars = &ue->common_vars; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; uint8_t log2_maxh, aarx; @@ -703,7 +704,8 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, for (int s=rel15->coreset.StartSymbolIndex; s<(rel15->coreset.StartSymbolIndex+rel15->coreset.duration); s++) { LOG_D(PHY,"in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n"); - nr_pdcch_extract_rbs_single(common_vars->rxdataF, + nr_pdcch_extract_rbs_single(ue->frame_parms.samples_per_slot_wCP, + rxdataF, pdcch_est_size, pdcch_dl_ch_estimates, rx_size, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 2a3de5a9bc..39d45a82d8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -81,38 +81,40 @@ unsigned char offset_mumimo_llr_drange[29][3]={{8,8,8},{7,7,7},{7,7,7},{7,7,7},{ #define print_shorts(s,x) printf("%s = [%d+j*%d, %d+j*%d, %d+j*%d, %d+j*%d]\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7]) /* compute H_h_H matrix inversion up to 4x4 matrices */ -uint8_t nr_zero_forcing_rx(int **rxdataF_comp, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_magr, - int **dl_ch_estimates_ext, - unsigned short nb_rb, - unsigned char n_rx, - unsigned char n_tx,//number of layer - unsigned char mod_order, - int shift, - unsigned char symbol, - int length); +uint8_t nr_zero_forcing_rx(uint32_t rx_size, + int32_t rxdataF_comp[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], + unsigned short nb_rb, + unsigned char n_rx, + unsigned char n_tx,//number of layer + unsigned char mod_order, + int shift, + unsigned char symbol, + int length); /* Apply layer demapping */ -static void nr_dlsch_layer_demapping(int16_t **llr_cw, +static void nr_dlsch_layer_demapping(int16_t *llr_cw[2], uint8_t Nl, uint8_t mod_order, uint32_t length, int32_t codeword_TB0, int32_t codeword_TB1, - int16_t **llr_layers); + int16_t *llr_layers[NR_MAX_NB_LAYERS]); /* compute LLR */ -static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, +static int nr_dlsch_llr(uint32_t rx_size, + int16_t *layer_llr[NR_MAX_NB_LAYERS], NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp_ptr, - int32_t **dl_ch_mag_ptr, + int32_t rxdataF_comp[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq, unsigned char harq_pid, - unsigned char gNB_id, - unsigned char gNB_id_i, unsigned char first_symbol_flag, unsigned char symbol, unsigned short nb_rb, @@ -120,26 +122,40 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, int32_t codeword_TB1, uint32_t len, uint8_t nr_slot_rx, - NR_UE_DLSCH_t *dlsch); - + NR_UE_DLSCH_t dlsch[2], + uint32_t llr_offset[NR_SYMBOLS_PER_SLOT]); /* Main Function */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t *dlsch, - unsigned char gNB_id, - unsigned char gNB_id_i, - uint32_t frame, - uint8_t nr_slot_rx, + NR_UE_DLSCH_t dlsch[2], unsigned char symbol, unsigned char first_symbol_flag, - unsigned char harq_pid) + unsigned char harq_pid, + uint32_t pdsch_est_size, + int32_t dl_ch_estimates[][pdsch_est_size], + int16_t *llr[2], + c16_t ptrs_phase_per_slot[][NR_SYMBOLS_PER_SLOT], + int32_t ptrs_re_per_slot[][NR_SYMBOLS_PER_SLOT], + uint32_t dl_valid_re[NR_SYMBOLS_PER_SLOT], + uint32_t rx_size, + int32_t dl_ch_estimates_ext[][rx_size], + int32_t rxdataF_ext[][rx_size], + int32_t rxdataF_comp[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], + uint32_t llr_offset[NR_SYMBOLS_PER_SLOT], + int32_t *log2_maxh) { NR_UE_COMMON *common_vars = &ue->common_vars; - NR_UE_PDSCH **pdsch_vars; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; PHY_NR_MEASUREMENTS *measurements = &ue->measurements; + int frame = proc->frame_rx; + int nr_slot_rx = proc->nr_slot_rx; + int gNB_id = proc->gNB_id; int avg[16]; // int avg_0[2]; @@ -152,8 +168,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, int avgs = 0;// rb; NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL; - int32_t **rxdataF_comp_ptr; - int32_t **dl_ch_mag_ptr; int32_t codeword_TB0 = -1; int32_t codeword_TB1 = -1; @@ -169,7 +183,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, uint16_t nbSymb=0; uint16_t pduBitmap=0x0; - pdsch_vars = ue->pdsch_vars; dlsch0_harq = &ue->dl_harq_processes[0][harq_pid]; if (NR_MAX_NB_LAYERS>4) dlsch1_harq = &ue->dl_harq_processes[1][harq_pid]; @@ -251,11 +264,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return(-1); } - if (!pdsch_vars) { - LOG_W(PHY,"dlsch_demodulation.c: Null pdsch_vars pointer\n"); - return(-1); - } - if (!frame_parms) { LOG_W(PHY,"dlsch_demodulation.c: Null frame_parms\n"); return(-1); @@ -272,10 +280,12 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //--------------------- RBs extraction --------------------- //---------------------------------------------------------- start_meas(&ue->generic_stat_bis[slot]); - nr_dlsch_extract_rbs(common_vars->rxdataF, - pdsch_vars[gNB_id]->dl_ch_estimates, - pdsch_vars[gNB_id]->rxdataF_ext, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, + nr_dlsch_extract_rbs(ue->frame_parms.samples_per_slot_wCP, + rxdataF, + rx_size, + dl_ch_estimates, + rxdataF_ext, + dl_ch_estimates_ext, symbol, pilots, config_type, @@ -298,7 +308,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //--------------------- Channel Scaling -------------------- //---------------------------------------------------------- start_meas(&ue->generic_stat_bis[slot]); - nr_dlsch_scale_channel(pdsch_vars[gNB_id]->dl_ch_estimates_ext, + nr_dlsch_scale_channel(rx_size, + dl_ch_estimates_ext, frame_parms, nl, n_rx, @@ -317,7 +328,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //---------------------------------------------------------- start_meas(&ue->generic_stat_bis[slot]); if (first_symbol_flag==1) { - nr_dlsch_channel_level(pdsch_vars[gNB_id]->dl_ch_estimates_ext, + nr_dlsch_channel_level(rx_size, + dl_ch_estimates_ext, frame_parms, nl, avg, @@ -333,7 +345,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, median[(aatx*n_rx)+aarx] = avg[(aatx*n_rx)+aarx]; } if (dlsch[0].Nl > 1) { - nr_dlsch_channel_level_median(pdsch_vars[gNB_id]->dl_ch_estimates_ext, + nr_dlsch_channel_level_median(rx_size, + dl_ch_estimates_ext, median, nl, n_rx, @@ -345,14 +358,12 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } } } - pdsch_vars[gNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1; - //LOG_I(PHY, "avgs Power per SC is %d lg2_maxh %d\n", avgs, pdsch_vars[gNB_id]->log2_maxh); - LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n", + *log2_maxh = (log2_approx(avgs)/2) + 1; + //LOG_I(PHY, "avgs Power per SC is %d lg2_maxh %d\n", avgs, log2_maxh); + LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d (%d,%d)\n", frame%1024, nr_slot_rx, - pdsch_vars[gNB_id]->log2_maxh, - pdsch_vars[gNB_id]->log2_maxh0, - pdsch_vars[gNB_id]->log2_maxh1, + *log2_maxh, avg[0], avgs); } @@ -373,13 +384,14 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //---------------------------------------------------------- // Disable correlation measurement for optimizing UE start_meas(&ue->generic_stat_bis[slot]); - nr_dlsch_channel_compensation(pdsch_vars[gNB_id]->rxdataF_ext, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->dl_ch_magr0, - pdsch_vars[gNB_id]->rxdataF_comp0, - NULL,//NULL:disable meas. pdsch_vars[gNB_id]->rho:enable meas. + nr_dlsch_channel_compensation(rx_size, + rxdataF_ext, + dl_ch_estimates_ext, + dl_ch_mag, + dl_ch_magb, + dl_ch_magr, + rxdataF_comp, + NULL, frame_parms, nl, symbol, @@ -387,67 +399,63 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, first_symbol_flag, dlsch[0].dlsch_config.qamModOrder, nb_rb_pdsch, - pdsch_vars[gNB_id]->log2_maxh, + *log2_maxh, measurements); // log2_maxh+I0_shift stop_meas(&ue->generic_stat_bis[slot]); if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[slot].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, *log2_maxh, proc->channel_level, ue->generic_stat_bis[slot].p_time/(cpuf*1000.0)); start_meas(&ue->generic_stat_bis[slot]); if (n_rx > 1) { - nr_dlsch_detection_mrc(pdsch_vars[gNB_id]->rxdataF_comp0, - (nl>1)? pdsch_vars[gNB_id]->rho : NULL, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->dl_ch_magr0, + nr_dlsch_detection_mrc(rx_size, + rxdataF_comp, + NULL, + dl_ch_mag, + dl_ch_magb, + dl_ch_magr, nl, n_rx, symbol, nb_rb_pdsch, nb_re_pdsch); if (nl >= 2)//Apply zero forcing for 2, 3, and 4 Tx layers - nr_zero_forcing_rx(pdsch_vars[gNB_id]->rxdataF_comp0, - pdsch_vars[gNB_id]->dl_ch_mag0, - pdsch_vars[gNB_id]->dl_ch_magb0, - pdsch_vars[gNB_id]->dl_ch_magr0, - pdsch_vars[gNB_id]->dl_ch_estimates_ext, - nb_rb_pdsch, - n_rx, - nl, - dlsch[0].dlsch_config.qamModOrder, - pdsch_vars[gNB_id]->log2_maxh, - symbol, - nb_re_pdsch); + nr_zero_forcing_rx(rx_size, + rxdataF_comp, + dl_ch_mag, + dl_ch_magb, + dl_ch_magr, + dl_ch_estimates_ext, + nb_rb_pdsch, + n_rx, + nl, + dlsch[0].dlsch_config.qamModOrder, + *log2_maxh, + symbol, + nb_re_pdsch); } stop_meas(&ue->generic_stat_bis[slot]); - //printf("start compute LLR\n"); - rxdataF_comp_ptr = pdsch_vars[gNB_id_i]->rxdataF_comp0; - dl_ch_mag_ptr = pdsch_vars[gNB_id_i]->dl_ch_mag0; - if (cpumeas(CPUMEAS_GETSTATE)) LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine and zero forcing %5.2f \n", frame, nr_slot_rx, slot, symbol, ue->generic_stat_bis[slot].p_time / (cpuf * 1000.0)); start_meas(&ue->generic_stat_bis[slot]); /* Store the valid DL RE's */ - pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = nb_re_pdsch; + dl_valid_re[symbol-1] = nb_re_pdsch; if(dlsch0_harq->status == ACTIVE) { startSymbIdx = dlsch[0].dlsch_config.start_symbol; nbSymb = dlsch[0].dlsch_config.number_symbols; pduBitmap = dlsch[0].dlsch_config.pduBitmap; } - if(dlsch1_harq) { - startSymbIdx = dlsch[1].dlsch_config.start_symbol; - nbSymb = dlsch[1].dlsch_config.number_symbols; - pduBitmap = dlsch[1].dlsch_config.pduBitmap; - } - + /* Check for PTRS bitmap and process it respectively */ if((pduBitmap & 0x1) && (dlsch[0].rnti_type == _C_RNTI_)) { nr_pdsch_ptrs_processing(ue, - pdsch_vars, + ptrs_phase_per_slot, + ptrs_re_per_slot, + rx_size, + rxdataF_comp, frame_parms, dlsch0_harq, dlsch1_harq, @@ -456,11 +464,31 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, symbol, (nb_rb_pdsch*12), dlsch[0].rnti,dlsch); - pdsch_vars[gNB_id]->dl_valid_re[symbol-1] -= pdsch_vars[gNB_id]->ptrs_re_per_slot[0][symbol]; + dl_valid_re[symbol-1] -= ptrs_re_per_slot[0][symbol]; } /* at last symbol in a slot calculate LLR's for whole slot */ if(symbol == (startSymbIdx + nbSymb -1)) { + uint8_t nb_re_dmrs; + if (dlsch[0].dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + } + else { + nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + } + uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); + + const uint32_t rx_llr_size = nr_get_G(dlsch[0].dlsch_config.number_rbs, + dlsch[0].dlsch_config.number_symbols, + nb_re_dmrs, + dmrs_len, + dlsch[0].dlsch_config.qamModOrder, + dlsch[0].Nl); + const uint32_t rx_llr_layer_size = (rx_llr_size + dlsch[0].Nl - 1) / dlsch[0].Nl; + + int16_t* layer_llr[NR_MAX_NB_LAYERS]; + for (int i=0; idl_valid_re[i-1], - nr_slot_rx, dlsch); + i, + nb_rb_pdsch, + codeword_TB0, + codeword_TB1, + dl_valid_re[i-1], + nr_slot_rx, + dlsch, + llr_offset); } - int dmrs_type = dlsch[0].dlsch_config.dmrsConfigType; - uint8_t nb_re_dmrs; - uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); - if (dmrs_type==NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; - } else { - nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; - } - dlsch0_harq->G = nr_get_G(dlsch[0].dlsch_config.number_rbs, dlsch[0].dlsch_config.number_symbols, nb_re_dmrs, @@ -498,51 +526,53 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dlsch[0].dlsch_config.qamModOrder, dlsch[0].Nl); - nr_dlsch_layer_demapping(pdsch_vars[gNB_id]->llr, + nr_dlsch_layer_demapping(llr, dlsch[0].Nl, dlsch[0].dlsch_config.qamModOrder, dlsch0_harq->G, codeword_TB0, codeword_TB1, - pdsch_vars[gNB_id]->layer_llr); + layer_llr); + + for (int i=0; iofdm_symbol_size, 1, 1); + + snprintf(filename, 50, "dl_ch_estimates0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + write_output(filename, "dl_ch_estimates", &dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); + + snprintf(filename, 50, "rxdataF_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + write_output(filename, "rxdataF_ext", &rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); + + snprintf(filename, 50, "dl_ch_estimates_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + write_output(filename, "dl_ch_estimates_ext00", &dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); + + snprintf(filename, 50, "rxdataF_comp0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); + write_output(filename, "rxdataF_comp00", &rxdataF_comp[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); + /* + for (int i=0; i < 2; i++){ + snprintf(filename, 50, "llr%d_symb_%d_nr_slot_rx_%d.m", i, symbol, nr_slot_rx); + write_output(filename,"llr", &llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb_pdsch*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb_pdsch*4*dlsch1_harq->Qm), 1, 0); + } + */ +#endif } - + stop_meas(&ue->generic_stat_bis[slot]); if (cpumeas(CPUMEAS_GETSTATE)) LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n", frame, nr_slot_rx, slot, symbol, ue->generic_stat_bis[slot].p_time / (cpuf * 1000.0)); - // Please keep it: useful for debugging -#ifdef DEBUG_PDSCH_RX - char filename[50]; - uint8_t aa = 0; - - snprintf(filename, 50, "rxdataF0_symb_%d_nr_slot_rx_%d.m", symbol, nr_slot_rx); - write_output(filename, "rxdataF0", &common_vars->rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - - snprintf(filename, 50, "dl_ch_estimates0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); - write_output(filename, "dl_ch_estimates", &pdsch_vars[gNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - - snprintf(filename, 50, "rxdataF_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); - write_output(filename, "rxdataF_ext", &pdsch_vars[gNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - - snprintf(filename, 50, "dl_ch_estimates_ext0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); - write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[gNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - - snprintf(filename, 50, "rxdataF_comp0%d_symb_%d_nr_slot_rx_%d.m", aa, symbol, nr_slot_rx); - write_output(filename, "rxdataF_comp00", &pdsch_vars[gNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); -/* - for (int i=0; i < 2; i++){ - snprintf(filename, 50, "llr%d_symb_%d_nr_slot_rx_%d.m", i, symbol, nr_slot_rx); - write_output(filename,"llr", &pdsch_vars[gNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb_pdsch*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb_pdsch*4*dlsch1_harq->Qm), 1, 0); - } -*/ -#endif - #if T_TRACER T(T_UE_PHY_PDSCH_IQ, T_INT(gNB_id), T_INT(ue->Mod_id), T_INT(frame%1024), T_INT(nr_slot_rx), T_INT(nb_rb_pdsch), T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_slot), - T_BUFFER(&pdsch_vars[gNB_id]->rxdataF_comp0[gNB_id][0], 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2)); + T_BUFFER(&rxdataF_comp[gNB_id][0], 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2)); #endif return(0); @@ -599,12 +629,13 @@ void nr_dlsch_deinterleaving(uint8_t symbol, // Pre-processing for LLR computation //============================================================================================== -void nr_dlsch_channel_compensation(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_magr, - int **rxdataF_comp, +void nr_dlsch_channel_compensation(uint32_t rx_size, + int32_t rxdataF_ext[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], + int32_t rxdataF_comp[][rx_size], int ***rho, NR_DL_FRAME_PARMS *frame_parms, uint8_t nb_aatx, @@ -1304,14 +1335,15 @@ void nr_dlsch_channel_compensation_core(int **rxdataF_ext, } -void nr_dlsch_scale_channel(int **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_tx, - uint8_t n_rx, - uint8_t symbol, - uint8_t pilots, - uint32_t len, - unsigned short nb_rb) +void nr_dlsch_scale_channel(uint32_t rx_size, + int32_t dl_ch_estimates_ext[][rx_size], + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_tx, + uint8_t n_rx, + uint8_t symbol, + uint8_t pilots, + uint32_t len, + unsigned short nb_rb) { #if defined(__x86_64__)||defined(__i386__) @@ -1359,13 +1391,14 @@ void nr_dlsch_scale_channel(int **dl_ch_estimates_ext, //compute average channel_level on each (TX,RX) antenna pair -void nr_dlsch_channel_level(int **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_tx, - int32_t *avg, - uint8_t symbol, - uint32_t len, - unsigned short nb_rb) +void nr_dlsch_channel_level(uint32_t rx_size, + int32_t dl_ch_estimates_ext[][rx_size], + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_tx, + int32_t *avg, + uint8_t symbol, + uint32_t len, + unsigned short nb_rb) { #if defined(__x86_64__)||defined(__i386__) @@ -1466,12 +1499,13 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext, #endif } -void nr_dlsch_channel_level_median(int **dl_ch_estimates_ext, - int32_t *median, - int n_tx, - int n_rx, - int length, - int start_point) +void nr_dlsch_channel_level_median(uint32_t rx_size, + int32_t dl_ch_estimates_ext[][rx_size], + int32_t *median, + int n_tx, + int n_rx, + int length, + int start_point) { #if defined(__x86_64__)||defined(__i386__) @@ -1563,10 +1597,12 @@ void nr_dlsch_channel_level_median(int **dl_ch_estimates_ext, // Extraction functions //============================================================================================== -void nr_dlsch_extract_rbs(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, +void nr_dlsch_extract_rbs(uint32_t rxdataF_sz, + c16_t rxdataF[][rxdataF_sz], + uint32_t rx_size, + int32_t dl_ch_estimates[][rx_size], + int32_t rxdataF_ext[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], unsigned char symbol, uint8_t pilots, uint8_t config_type, @@ -1597,7 +1633,7 @@ void nr_dlsch_extract_rbs(int **rxdataF, for (unsigned char aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { int32_t *rxF_ext = &rxdataF_ext[aarx][symbol * nb_rb_pdsch * NR_NB_SC_PER_RB]; - int32_t *rxF = &rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; + int32_t *rxF = (int32_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; for (unsigned char aatx = 0; aatx < Nl; aatx++) { @@ -1682,11 +1718,12 @@ void nr_dlsch_extract_rbs(int **rxdataF, } } -void nr_dlsch_detection_mrc(int **rxdataF_comp, +void nr_dlsch_detection_mrc(uint32_t rx_size, + int32_t rxdataF_comp[][rx_size], int ***rho, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_magr, + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], short n_tx, short n_rx, unsigned char symbol, @@ -2144,11 +2181,12 @@ void nr_conjch0_mult_ch1(int *ch0, * * * */ -uint8_t nr_zero_forcing_rx(int **rxdataF_comp, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_magr, - int **dl_ch_estimates_ext, +uint8_t nr_zero_forcing_rx(uint32_t rx_size, + int32_t rxdataF_comp[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], unsigned short nb_rb, unsigned char n_rx, unsigned char n_tx,//number of layer @@ -2305,13 +2343,13 @@ uint8_t nr_zero_forcing_rx(int **rxdataF_comp, return(0); } -static void nr_dlsch_layer_demapping(int16_t **llr_cw, - uint8_t Nl, - uint8_t mod_order, - uint32_t length, - int32_t codeword_TB0, - int32_t codeword_TB1, - int16_t **llr_layers) { +static void nr_dlsch_layer_demapping(int16_t *llr_cw[2], + uint8_t Nl, + uint8_t mod_order, + uint32_t length, + int32_t codeword_TB0, + int32_t codeword_TB1, + int16_t *llr_layers[NR_MAX_NB_LAYERS]) { switch (Nl) { case 1: @@ -2343,15 +2381,16 @@ static void nr_dlsch_layer_demapping(int16_t **llr_cw, } } -static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, +static int nr_dlsch_llr(uint32_t rx_size, + int16_t *layer_llr[NR_MAX_NB_LAYERS], NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp_ptr, - int32_t **dl_ch_mag_ptr, + int32_t rxdataF_comp[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq, unsigned char harq_pid, - unsigned char gNB_id, - unsigned char gNB_id_i, unsigned char first_symbol_flag, unsigned char symbol, unsigned short nb_rb, @@ -2359,22 +2398,23 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, int32_t codeword_TB1, uint32_t len, uint8_t nr_slot_rx, - NR_UE_DLSCH_t *dlsch) + NR_UE_DLSCH_t dlsch[2], + uint32_t llr_offset[14]) { uint32_t llr_offset_symbol; if (first_symbol_flag==1) - pdsch_vars[gNB_id]->llr_offset[symbol-1] = 0; - llr_offset_symbol = pdsch_vars[gNB_id]->llr_offset[symbol-1]; + llr_offset[symbol-1] = 0; + llr_offset_symbol = llr_offset[symbol-1]; - pdsch_vars[gNB_id]->llr_offset[symbol] = len*dlsch->dlsch_config.qamModOrder + llr_offset_symbol; + llr_offset[symbol] = len*dlsch[0].dlsch_config.qamModOrder + llr_offset_symbol; switch (dlsch[0].dlsch_config.qamModOrder) { case 2 : for(int l=0; l < dlsch[0].Nl; l++) nr_dlsch_qpsk_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, + rxdataF_comp[l*frame_parms->nb_antennas_rx], + layer_llr[l]+llr_offset_symbol, symbol, len, first_symbol_flag, @@ -2384,9 +2424,9 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, case 4 : for(int l=0; l < dlsch[0].Nl; l++) nr_dlsch_16qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], + rxdataF_comp[l*frame_parms->nb_antennas_rx], + layer_llr[l]+llr_offset_symbol, + dl_ch_mag[0], symbol, len, first_symbol_flag, @@ -2396,10 +2436,10 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, case 6 : for(int l=0; l < dlsch[0].Nl; l++) nr_dlsch_64qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - pdsch_vars[gNB_id]->dl_ch_magb0[0], + rxdataF_comp[l*frame_parms->nb_antennas_rx], + layer_llr[l]+llr_offset_symbol, + dl_ch_mag[0], + dl_ch_magb[0], symbol, len, first_symbol_flag, @@ -2409,11 +2449,11 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, case 8: for(int l=0; l < dlsch[0].Nl; l++) nr_dlsch_256qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - pdsch_vars[gNB_id]->dl_ch_magb0[0], - pdsch_vars[gNB_id]->dl_ch_magr0[0], + rxdataF_comp[l*frame_parms->nb_antennas_rx], + layer_llr[l]+llr_offset_symbol, + dl_ch_mag[0], + dl_ch_magb[0], + dl_ch_magr[0], symbol, len, first_symbol_flag, @@ -2426,12 +2466,13 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, break; } + //TODO: Revisited for Nl>4 if (dlsch1_harq) { switch (dlsch[1].dlsch_config.qamModOrder) { case 2 : nr_dlsch_qpsk_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[0], - pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, + rxdataF_comp[0], + layer_llr[0]+llr_offset_symbol, symbol, len, first_symbol_flag, @@ -2440,9 +2481,9 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, case 4: nr_dlsch_16qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[0], - pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], + rxdataF_comp[0], + layer_llr[0]+llr_offset_symbol, + dl_ch_mag[0], symbol, len, first_symbol_flag, @@ -2451,10 +2492,10 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, case 6 : nr_dlsch_64qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[0], - pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - pdsch_vars[gNB_id]->dl_ch_magb0[0], + rxdataF_comp[0], + layer_llr[0]+llr_offset_symbol, + dl_ch_mag[0], + dl_ch_magb[0], symbol, len, first_symbol_flag, @@ -2463,11 +2504,11 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, case 8 : nr_dlsch_256qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[0], - pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - pdsch_vars[gNB_id]->dl_ch_magb0[0], - pdsch_vars[gNB_id]->dl_ch_magr0[0], + rxdataF_comp[0], + layer_llr[0]+llr_offset_symbol, + dl_ch_mag[0], + dl_ch_magb[0], + dl_ch_magr[0], symbol, len, first_symbol_flag, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index f58dbc3e81..1904bed457 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -101,7 +101,7 @@ void free_list(NR_UE_SSB *node) { } -int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, nr_phy_data_t *phy_data) +int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, nr_phy_data_t *phy_data, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; @@ -127,7 +127,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini start_meas(&ue->dlsch_channel_estimation_stats); // computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im*current_ssb->c_im; @@ -152,7 +152,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini for(int i=pbch_initial_symbol; ii_ssb,temp_ptr->n_hf); + proc,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf,rxdataF); stop_meas(&ue->dlsch_channel_estimation_stats); fapiPbch_t result; @@ -162,11 +162,11 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini dl_ch_estimates, ue->pbch_vars[0], frame_parms, - 0, temp_ptr->i_ssb, SISO, phy_data, - &result); + &result, + rxdataF); if (DUMP_PBCH_CH_ESTIMATES && (ret == 0)) { write_output("pbch_ch_estimates.m", "pbch_ch_estimates", dl_ch_estimates, frame_parms->nb_antennas_rx*estimateSz, 1, 1); @@ -242,6 +242,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, * sync_pos SS/PBCH block */ + const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP; + __attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz]; cnt++; if (1){ // (cnt>100) cnt =0; @@ -302,16 +304,16 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_slot_fep_init_sync(ue, proc, i, - 0, is*fp->samples_per_frame+ue->ssb_offset, - false); + false, + rxdataF); #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"Calling sss detection (normal CP)\n"); #endif int freq_offset_sss = 0; - ret = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss); + ret = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss, rxdataF); // digital compensation of FFO for SSB symbols if (ue->UE_fo_compensation){ @@ -341,7 +343,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, if (ret==0) { //we got sss channel nr_gold_pbch(ue); - ret = nr_pbch_detection(proc, ue, 1, &phy_data); // start pbch detection at first symbol after pss + ret = nr_pbch_detection(proc, ue, 1, &phy_data, rxdataF); // start pbch detection at first symbol after pss } if (ret == 0) { @@ -524,7 +526,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, if (sa==1 && ret==0) { nr_ue_dlsch_init(phy_data.dlsch, 1, ue->max_ldpc_iterations); bool dec = false; - int gnb_id = 0; //FIXME + proc->gNB_id = 0; //FIXME // Hold the channel estimates in frequency domain. int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16); @@ -538,23 +540,22 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_slot_fep_init_sync(ue, proc, l, // the UE PHY has no notion of the symbols to be monitored in the search space - phy_pdcch_config->slot, is*fp->samples_per_frame+phy_pdcch_config->sfn*fp->samples_per_frame+ue->rx_offset, - true); + true, + rxdataF); nr_pdcch_channel_estimation(ue, proc, - 0, - phy_pdcch_config->slot, l, &phy_pdcch_config->pdcch_config[n_ss].coreset, fp->first_carrier_offset, phy_pdcch_config->pdcch_config[n_ss].BWPStart, pdcch_est_size, - pdcch_dl_ch_estimates); + pdcch_dl_ch_estimates, + rxdataF); } - int dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_data, n_ss); + int dci_cnt = nr_ue_pdcch_procedures(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_data, n_ss, rxdataF); if (dci_cnt>0){ NR_UE_DLSCH_t *dlsch = phy_data.dlsch; if (dlsch[0].active == 1) { @@ -565,24 +566,46 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_slot_fep_init_sync(ue, proc, m, - phy_pdcch_config->slot, // same slot and offset as pdcch is*fp->samples_per_frame+phy_pdcch_config->sfn*fp->samples_per_frame+ue->rx_offset, - true); + true, + rxdataF); } + uint8_t nb_re_dmrs; + if (dlsch[0].dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + } + else { + nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + } + uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); + + const uint32_t rx_llr_size = nr_get_G(dlsch[0].dlsch_config.number_rbs, + dlsch[0].dlsch_config.number_symbols, + nb_re_dmrs, + dmrs_len, + dlsch[0].dlsch_config.qamModOrder, + dlsch[0].Nl); + int16_t* llr[2]; + int16_t* layer_llr[NR_MAX_NB_LAYERS]; + llr[0] = (int16_t *)malloc16_clear(rx_llr_size*sizeof(int16_t)); + int ret = nr_ue_pdsch_procedures(ue, proc, - gnb_id, - dlsch); + phy_data.dlsch, + llr, + rxdataF); if (ret >= 0) dec = nr_ue_dlsch_procedures(ue, proc, - gnb_id, - dlsch, - NULL); + phy_data.dlsch, + llr); // deactivate dlsch once dlsch proc is done - dlsch->active = 0; + dlsch[0].active = 0; + free(llr[0]); + for (int i=0; inb_antennas_rx; aarx++) { unsigned int rx_offset = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier; rx_offset = (rx_offset)%(frame_parms->ofdm_symbol_size); - struct complex16 *rxF = (struct complex16 *)&rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size]; + struct complex16 *rxF = &rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size]; struct complex16 *rxF_ext = rxdataF_ext[aarx]; #ifdef DEBUG_PBCH printf("extract_rbs (nushift %d): rx_offset=%d, symbol %u\n",frame_parms->nushift, @@ -388,13 +389,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, int estimateSz, struct complex16 dl_ch_estimates [][estimateSz], NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, - uint8_t gNB_id, uint8_t i_ssb, MIMO_mode_t mimo_mode, nr_phy_data_t *phy_data, - fapiPbch_t *result) { + fapiPbch_t *result, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; int max_h=0; int symbol; //uint8_t pbch_a[64]; @@ -424,7 +424,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, #ifdef DEBUG_PBCH //printf("address dataf %p",nr_ue_common_vars->rxdataF); write_output("rxdataF0_pbch.m","rxF0pbch", - &nr_ue_common_vars->rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); + &rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); #endif // symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot double log2_maxh = 0; @@ -434,7 +434,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, __attribute__ ((aligned(32))) struct complex16 rxdataF_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL]; memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext); - nr_pbch_extract(nr_ue_common_vars->rxdataF, + nr_pbch_extract(ue->frame_parms.samples_per_slot_wCP, + rxdataF, estimateSz, dl_ch_estimates, rxdataF_ext, @@ -580,8 +581,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1); uint16_t number_pdus = 1; - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, phy_data); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc,(void *)result); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, phy_data); + nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, ue, NULL, NULL, number_pdus, proc,(void *)result); if (ue->if_inst && ue->if_inst->dl_indication) ue->if_inst->dl_indication(&dl_indication, NULL); 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 efdcd51e64..921be85002 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -543,10 +543,12 @@ void nr_dlsch_256qam_llr(NR_DL_FRAME_PARMS *frame_parms, @param n_dmrs_cdm_groups @param frame_parms Pointer to frame descriptor */ -void nr_dlsch_extract_rbs(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, +void nr_dlsch_extract_rbs(uint32_t rxdataF_sz, + c16_t rxdataF[][rxdataF_sz], + uint32_t rx_size, + int32_t dl_ch_estimates[][rx_size], + int32_t rxdataF_ext[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], unsigned char symbol, uint8_t pilots, uint8_t config_type, @@ -558,7 +560,6 @@ void nr_dlsch_extract_rbs(int **rxdataF, uint16_t dlDmrsSymbPos, int chest_time_type); - /** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation. In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation) @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated @param dl_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated @@ -574,22 +575,23 @@ void nr_dlsch_extract_rbs(int **rxdataF, @param output_shift Rescaling for compensated output (should be energy-normalizing) @param phy_measurements Pointer to UE PHY measurements */ -void nr_dlsch_channel_compensation(int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - int32_t **dl_ch_magr, - int32_t **rxdataF_comp, - int32_t ***rho, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t nb_aatx, - uint8_t symbol, - int length, - uint8_t first_symbol_flag, - uint8_t mod_order, - uint16_t nb_rb, - uint8_t output_shift, - PHY_NR_MEASUREMENTS *phy_measurements); +void nr_dlsch_channel_compensation(uint32_t rx_size, + int32_t rxdataF_ext[][rx_size], + int32_t dl_ch_estimates_ext[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], + int32_t rxdataF_comp[][rx_size], + int ***rho, + NR_DL_FRAME_PARMS *frame_parms, + uint8_t nb_aatx, + 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); void nr_dlsch_channel_compensation_core(int **rxdataF_ext, int **dl_ch_estimates_ext, @@ -611,18 +613,20 @@ void nr_dlsch_deinterleaving(uint8_t symbol, uint16_t *llr_deint, uint16_t nb_rb_pdsch); -void nr_dlsch_channel_level_median(int **dl_ch_estimates_ext, - int32_t *median, - int n_tx, - int n_rx, - int length, - int start_point); +void nr_dlsch_channel_level_median(uint32_t rx_size, + int32_t dl_ch_estimates[][rx_size], + int32_t *median, + int n_tx, + int n_rx, + int length, + int start_point); -void nr_dlsch_detection_mrc(int **rxdataF_comp, +void nr_dlsch_detection_mrc(uint32_t rx_size, + int32_t rxdataF_comp[][rx_size], int ***rho, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_magr, + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], short n_tx, short n_rx, unsigned char symbol, @@ -647,23 +651,24 @@ void nr_a_sum_b(__m128i *input_x, @param pilots_flag Flag to indicate pilots in symbol @param nb_rb Number of allocated RBs */ -void nr_dlsch_channel_level(int **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_tx, - int32_t *avg, - uint8_t symbol, - uint32_t len, - unsigned short nb_rb); +void nr_dlsch_channel_level(uint32_t rx_size, + int32_t dl_ch_estimates[][rx_size], + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_tx, + int32_t *avg, + uint8_t symbol, + uint32_t len, + unsigned short nb_rb); - -void nr_dlsch_scale_channel(int32_t **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_tx, - uint8_t n_rx, - uint8_t symbol, - uint8_t start_symbol, - uint32_t len, - uint16_t nb_rb); +void nr_dlsch_scale_channel(uint32_t rx_size, + int32_t dl_ch_estimates[][rx_size], + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_tx, + uint8_t n_rx, + uint8_t symbol, + uint8_t pilots, + uint32_t len, + unsigned short nb_rb); /** \brief This is the top-level entry point for DLSCH decoding in UE. It should be replicated on several threads (on multi-core machines) corresponding to different HARQ processes. The routine first @@ -751,7 +756,8 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], int16_t *pdcch_e_rx, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); /*! \brief Performs detection of SSS to find cell ID and other framing parameters (FDD/TDD, normal/extended prefix) @@ -773,16 +779,17 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, struct complex16 dl_ch_estimates[][estimateSz], NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, - uint8_t eNB_id, uint8_t i_ssb, MIMO_mode_t mimo_mode, nr_phy_data_t *phy_data, - fapiPbch_t* result); + fapiPbch_t* result, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pbch_detection(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, - nr_phy_data_t *phy_data); + nr_phy_data_t *phy_data, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); #ifndef modOrder @@ -862,14 +869,26 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - NR_UE_DLSCH_t *dlsch, - unsigned char gNB_id, - unsigned char gNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference - uint32_t frame, - uint8_t nr_slot_rx, + NR_UE_DLSCH_t dlsch[2], unsigned char symbol, unsigned char first_symbol_flag, - unsigned char harq_pid); + unsigned char harq_pid, + uint32_t pdsch_est_size, + int32_t dl_ch_estimates[][pdsch_est_size], + int16_t *llr[2], + c16_t ptrs_phase_per_slot[][NR_SYMBOLS_PER_SLOT], + int32_t ptrs_re_per_slot[][NR_SYMBOLS_PER_SLOT], + uint32_t dl_valid_re[NR_SYMBOLS_PER_SLOT], + uint32_t rx_size, + int32_t dl_ch_estimates_ext[][rx_size], + int32_t rxdataF_ext[][rx_size], + int32_t rxdataF_comp[][rx_size], + int32_t dl_ch_mag[][rx_size], + int32_t dl_ch_magb[][rx_size], + int32_t dl_ch_magr[][rx_size], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP], + uint32_t llr_offset[NR_SYMBOLS_PER_SLOT], + int32_t *log2_maxh); int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t slot); diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index 55669ba322..5e60ae2940 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -432,9 +432,8 @@ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, * send srs according to current configuration * *********************************************************************/ -int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) +int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc) { - if(!ue->srs_vars[0]->active) { return -1; } diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h index 2c3d6d266c..5feea8d9ce 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h @@ -175,7 +175,7 @@ int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource, @param current gNB_id identifier @returns 0 if srs is transmitted -1 otherwise */ -int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); +int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc); #undef EXTERN #undef INIT_VARIABLES_SRS_MODULATION_NR_H diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c index 53191f0946..41829b68f2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c @@ -318,13 +318,13 @@ int do_pss_sss_extract_nr(PHY_VARS_NR_UE *ue, int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR], int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR], uint8_t doPss, uint8_t doSss, - uint8_t subframe) // add flag to indicate extracting only PSS, only SSS, or both + uint8_t subframe, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) // add flag to indicate extracting only PSS, only SSS, or both { uint8_t aarx; int32_t *pss_rxF,*pss_rxF_ext; int32_t *sss_rxF,*sss_rxF_ext; uint8_t pss_symbol, sss_symbol; - int32_t **rxdataF; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; for (aarx=0; aarxnb_antennas_rx; aarx++) { @@ -332,12 +332,10 @@ int do_pss_sss_extract_nr(PHY_VARS_NR_UE *ue, pss_symbol = 0; sss_symbol = SSS_SYMBOL_NB-PSS_SYMBOL_NB; - rxdataF = ue->common_vars.rxdataF; - unsigned int ofdm_symbol_size = frame_parms->ofdm_symbol_size; - pss_rxF = &rxdataF[aarx][pss_symbol*ofdm_symbol_size]; - sss_rxF = &rxdataF[aarx][sss_symbol*ofdm_symbol_size]; + pss_rxF = (int32_t *)&rxdataF[aarx][pss_symbol*ofdm_symbol_size]; + sss_rxF = (int32_t *)&rxdataF[aarx][sss_symbol*ofdm_symbol_size]; pss_rxF_ext = &pss_ext[aarx][0]; sss_rxF_ext = &sss_ext[aarx][0]; @@ -402,9 +400,10 @@ int pss_sss_extract_nr(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR], int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR], - uint8_t subframe) + uint8_t subframe, + c16_t rxdataF[][phy_vars_ue->frame_parms.samples_per_slot_wCP]) { - return do_pss_sss_extract_nr(phy_vars_ue, proc, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe); + return do_pss_sss_extract_nr(phy_vars_ue, proc, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe, rxdataF); } /******************************************************************* @@ -420,7 +419,7 @@ int pss_sss_extract_nr(PHY_VARS_NR_UE *phy_vars_ue, * *********************************************************************/ -int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, uint8_t *phase_max, int *freq_offset_sss) +int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, uint8_t *phase_max, int *freq_offset_sss, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { uint8_t i; int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR]; @@ -439,7 +438,8 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric, proc, pss_ext, sss_ext, - 0); /* subframe */ + 0, + rxdataF); /* subframe */ #ifdef DEBUG_PLOT_SSS diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 8d963281c4..23f6f76181 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -788,13 +788,19 @@ static void ueChannelResponse (scopeGraphData_t **data, OAIgraph_t *graph, PHY_ } static void ueFreqWaterFall (scopeGraphData_t **data, OAIgraph_t *graph,PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id ) { - NR_DL_FRAME_PARMS *frame_parms=&phy_vars_ue->frame_parms; //use 1st antenna + if (!data[commonRxdataF]) + return; + + const int sz = data[commonRxdataF]->lineSz; + + scopeSample_t *rxdataF = (scopeSample_t *)(data[commonRxdataF]+1); + genericWaterFall(graph, - (scopeSample_t *)phy_vars_ue->common_vars.rxdataF[0], - frame_parms->samples_per_slot_wCP, - phy_vars_ue->frame_parms.slots_per_frame, - "X axis: one frame frequency" ); + rxdataF, + sz, + 1, + "X axis: one slot frequency" ); } /* static void uePbchFrequencyResp (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { @@ -925,70 +931,48 @@ static void uePcchIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_U } static void uePdschLLR (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PDSCH LLRs - if (!phy_vars_ue->pdsch_vars[eNB_id]->llr[0]) + if (!data[pdschLlr]) return; - int num_re = 4500; - int Qm = 2; - int coded_bits_per_codeword = num_re*Qm; - int newsz = 0; + const int sz = data[pdschLlr]->lineSz; float *llr, *bit; + int nx = sz; + int16_t *pdsch_llr = (int16_t *)(data[pdschLlr]+1); -#ifndef WEBSRVSCOPE - oai_xygraph_getbuff(graph, &bit, &llr, coded_bits_per_codeword*RX_NB_TH_MAX, 0); -#endif - int base=0; - - for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) { - int16_t *pdsch_llr = (int16_t *) phy_vars_ue->pdsch_vars[eNB_id]->llr[0]; // stream 0 #ifdef WEBSRVSCOPE - newsz += websrv_cpllrbuff_tomsg(graph, pdsch_llr, coded_bits_per_codeword, 0, thr, RX_NB_TH_MAX); + nx = websrv_cpllrbuff_tomsg(graph, pdsch_llr, sz, UE_id, 0, 0); #else - for (int i=0; ipdsch_llr,0,coded_bits_per_codeword); - oai_xygraph(graph, bit, llr, newsz, 0, 10); + oai_xygraph(graph, bit, llr, nx, 0, 10); } static void uePdschIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { // PDSCH I/Q of MF Output - if (!phy_vars_ue->pdsch_vars[eNB_id]->rxdataF_comp0[0]) + if (!data[pdschRxdataF_comp]) return; - NR_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->frame_parms; - int sz=7*2*frame_parms->N_RB_DL*12; // size of the malloced buffer - int newsz = 0; + const int sz=data[pdschRxdataF_comp]->lineSz; + int nz = sz; float *I, *Q; - int base=0; - -#ifndef WEBSRVSCOPE - oai_xygraph_getbuff(graph, &I, &Q, sz * RX_NB_TH_MAX, 0); - memset(I+base, 0, sz*RX_NB_TH_MAX * sizeof(*I)); - memset(Q+base, 0, sz*RX_NB_TH_MAX * sizeof(*Q)); -#endif - for (int thr=0 ; thr < RX_NB_TH_MAX ; thr ++ ) { - scopeSample_t *pdsch_comp = (scopeSample_t *) phy_vars_ue->pdsch_vars[eNB_id]->rxdataF_comp0[0]; + scopeSample_t *pdsch_comp = (scopeSample_t *) (data[pdschRxdataF_comp]+1); #ifdef WEBSRVSCOPE - newsz += websrv_cpiqbuff_tomsg(graph, pdsch_comp, sz, 0, base); + nz += websrv_cpiqbuff_tomsg(graph, pdsch_comp, sz, 0, 0); #else - for (int s=0; sscopeData; if (tmp) { - // Begin of critical zone between UE Rx threads that might copy new data at the same time: might require a mutex - int newCopyDataIdx = (copyDataBufsIdx[type]==0)?1:0; + // Begin of critical zone between UE Rx threads that might copy new data at the same time: + pthread_mutex_lock(&UEcopyDataMutex); + int newCopyDataIdx = (copyDataBufsIdx[type]<2)?copyDataBufsIdx[type]+1:0; copyDataBufsIdx[type] = newCopyDataIdx; + pthread_mutex_unlock(&UEcopyDataMutex); // End of critical zone between UE Rx threads // New data will be copied in a different buffer than the live one @@ -1204,6 +1192,7 @@ STATICFORXSCOPE void nrUEinitScope(PHY_VARS_NR_UE *ue) pthread_t forms_thread; threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW); #endif + pthread_mutex_init(&UEcopyDataMutex, NULL); } void nrscope_autoinit(void *dataptr) { diff --git a/openair1/PHY/TOOLS/phy_scope_interface.h b/openair1/PHY/TOOLS/phy_scope_interface.h index 6162e1eee5..00efbdff24 100644 --- a/openair1/PHY/TOOLS/phy_scope_interface.h +++ b/openair1/PHY/TOOLS/phy_scope_interface.h @@ -47,6 +47,9 @@ enum UEdataType { pbchRxdataF_comp, pdcchLlr, pdcchRxdataF_comp, + pdschLlr, + pdschRxdataF_comp, + commonRxdataF, UEdataTypeNumberOfItems }; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 0c67ac017e..a75529b1d3 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -232,11 +232,6 @@ typedef struct { /// - second index: sample [0..2*FRAME_LENGTH_COMPLEX_SAMPLES+2048[ int32_t **rxdata; - /// \brief Holds the received data in the frequency domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: symbol [0..28*ofdm_symbol_size[ - int32_t **rxdataF; - /// holds output of the sync correlator int32_t *sync_corr; /// estimated frequency offset (in radians) for all subcarriers @@ -245,97 +240,6 @@ typedef struct { int32_t eNb_id; } NR_UE_COMMON; -typedef struct { - /// \brief Received frequency-domain signal after extraction. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_ext; - /// \brief Received frequency-domain ue specific pilots. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..12*N_RB_DL[ - int32_t **rxdataF_uespec_pilots; - /// \brief Received frequency-domain signal after extraction and channel compensation. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_comp0; - /// \brief Hold the channel estimates in frequency domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_ch_estimates; - /// \brief Downlink channel estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_estimates_ext; - /// \brief Downlink beamforming channel estimates in frequency domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_bf_ch_estimates; - /// \brief Downlink beamforming channel estimates. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_bf_ch_estimates_ext; - /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. - /// - first index: ressource block [0..N_RB_DL[ - uint8_t *pmi_ext; - /// \brief Magnitude of Downlink Channel first layer (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_mag0; - /// \brief Magnitude of Downlink Channel, first layer (2nd 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_magb0; - /// \brief Magnitude of Downlink Channel, first layer (256QAM level). - int32_t **dl_ch_magr0; - /// \brief Cross-correlation Matrix of the gNB Tx channel signals. - /// - first index: aatx*n_rx+aarx for all aatx=[0..n_tx[ and aarx=[0..nb_rx[ - /// - second index: symbol [0..] - int32_t ***rho; - /// \brief Pointers to llr vectors (2 TBs). - /// - first index: ? [0..1] (hard coded) - /// - second index: ? [0..1179743] (hard coded) - int16_t *llr[2]; - /// Pointers to layer llr vectors (4 layers). - int16_t *layer_llr[4]; - /// \f$\log_2(\max|H_i|^2)\f$ - int16_t log2_maxh; - /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer1 channel compensation - int16_t log2_maxh0; - /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer2 channel commpensation - int16_t log2_maxh1; - /// \brief LLR shifts for subband scaling. - /// - first index: ? [0..168*N_RB_DL[ - uint8_t *llr_shifts; - /// \brief Pointer to LLR shifts. - /// - first index: ? [0..168*N_RB_DL[ - uint8_t *llr_shifts_p; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128_2ndstream; - //uint32_t *rb_alloc; - //uint8_t Qm[2]; - //MIMO_mode_t mimo_mode; - // llr offset per ofdm symbol - uint32_t llr_offset[14]; - // llr length per ofdm symbol - uint32_t llr_length[14]; - // llr offset per ofdm symbol - uint32_t dl_valid_re[14]; - /// \brief Estimated phase error based upon PTRS on each symbol . - /// - first index: ? [0..7] Number of Antenna - /// - second index: ? [0...14] smybol per slot - int32_t **ptrs_phase_per_slot; - /// \brief Estimated phase error based upon PTRS on each symbol . - /// - first index: ? [0..7] Number of Antenna - /// - second index: ? [0...14] smybol per slot - int32_t **ptrs_re_per_slot; -} NR_UE_PDSCH; - #define NR_PRS_IDFT_OVERSAMP_FACTOR 1 // IDFT oversampling factor for NR PRS channel estimates in time domain, ALLOWED value 16x, and 1x is default(ie. IDFT size is frame_params->ofdm_symbol_size) typedef struct { prs_config_t prs_cfg; @@ -533,7 +437,6 @@ typedef struct { fapi_nr_config_request_t nrUE_config; - NR_UE_PDSCH *pdsch_vars[NUMBER_OF_CONNECTED_gNB_MAX+1]; NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_CSI_IM *csiim_vars[NUMBER_OF_CONNECTED_gNB_MAX]; @@ -541,7 +444,7 @@ typedef struct { NR_UE_SRS *srs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRS *prs_vars[NR_MAX_PRS_COMB_SIZE]; uint8_t prs_active_gNBs; - NR_DL_UE_HARQ_t dl_harq_processes[NR_MAX_NB_LAYERS>4 ? 2:1][NR_MAX_DLSCH_HARQ_PROCESSES]; + NR_DL_UE_HARQ_t dl_harq_processes[2][NR_MAX_DLSCH_HARQ_PROCESSES]; NR_UL_UE_HARQ_t ul_harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES]; //Paging parameters @@ -747,6 +650,13 @@ typedef struct { int dl_errors; int dl_stats[8]; void* scopeData; + // Pointers to hold PDSCH data only for phy simulators + void *phy_sim_rxdataF; + void *phy_sim_pdsch_llr; + void *phy_sim_pdsch_rxdataF_ext; + void *phy_sim_pdsch_rxdataF_comp; + void *phy_sim_pdsch_dl_ch_estimates; + void *phy_sim_pdsch_dl_ch_estimates_ext; } PHY_VARS_NR_UE; typedef struct nr_phy_data_tx_s { @@ -756,7 +666,7 @@ typedef struct nr_phy_data_tx_s { typedef struct nr_phy_data_s { NR_UE_PDCCH_CONFIG phy_pdcch_config; - NR_UE_DLSCH_t dlsch[NR_MAX_NB_LAYERS>4 ? 2:1]; + NR_UE_DLSCH_t dlsch[2]; } nr_phy_data_t; /* this structure is used to pass both UE phy vars and * proc to the function UE_thread_rxn_txnp4 diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 89e5d7501c..1439c9fd01 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -96,22 +96,20 @@ typedef struct { @param proc Pointer to RXn-TXnp4 proc information @param eNB_id Local id of eNB on which to act */ -void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, nr_phy_data_tx_t *phy_data); +void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data); /*! \brief Scheduling for UE RX procedures in normal subframes. @param ue Pointer to UE variables on which to act @param proc Pointer to proc information - @param gNB_id Local id of eNB on which to act @param dlsch_parallel use multithreaded dlsch processing @param phy_pdcch_config PDCCH Config for this slot @param txFifo Result fifo if PDSCH is run in parallel */ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, nr_phy_data_t *phy_data); -int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); +int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); void processSlotTX(void *arg); @@ -120,7 +118,7 @@ void processSlotTX(void *arg); @param @param */ -void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); +void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc); int8_t nr_find_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); @@ -151,7 +149,6 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_rx_indication_t *rx_ind, UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - uint8_t gNB_id, void *phy_data); /*@}*/ @@ -164,7 +161,6 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, */ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, uint8_t pdu_type, - uint8_t gNB_id, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, @@ -174,26 +170,26 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int gNB_id, - NR_UE_DLSCH_t *dlsch0, - NR_UE_DLSCH_t *dlsch1); + NR_UE_DLSCH_t dlsch[2], + int16_t* llr[2]); int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int gNB_id, - NR_UE_DLSCH_t *dlsch); + NR_UE_DLSCH_t dlsch[2], + int16_t *llr[2], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); -int nr_ue_pdcch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, +int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, - int n_ss); + int n_ss, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); -int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); +int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); -int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); +int nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); #endif diff --git a/openair1/SCHED_NR_UE/harq_nr.h b/openair1/SCHED_NR_UE/harq_nr.h index e511e6f1c6..f640d0f7be 100644 --- a/openair1/SCHED_NR_UE/harq_nr.h +++ b/openair1/SCHED_NR_UE/harq_nr.h @@ -65,6 +65,11 @@ /*************** FUNCTIONS ****************************************/ +/** \brief This function update uplink harq context and return transmission type (new transmission or retransmission) + @param ulsch uplink harq context + @param harq process identifier harq_pid + @returns retransmission or new transmission */ + harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, NR_UL_UE_HARQ_t harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES], int ndi, uint8_t rnti_type); /** \brief This function initialises downlink HARQ status diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 4888892a82..5d624bfd63 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -52,7 +52,8 @@ #include "executables/softmodem-common.h" #include "executables/nr-uesoftmodem.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -#include "openair1/SCHED_NR_UE/pucch_uci_ue_nr.h" +#include "SCHED_NR_UE/pucch_uci_ue_nr.h" +#include //#define DEBUG_PHY_PROC #define NR_PDCCH_SCHED @@ -87,12 +88,11 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_rx_indication_t *rx_ind, UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - uint8_t gNB_id, void *phy_data){ memset((void*)dl_ind, 0, sizeof(nr_downlink_indication_t)); - dl_ind->gNB_index = gNB_id; + dl_ind->gNB_index = proc->gNB_id; dl_ind->module_id = ue->Mod_id; dl_ind->cc_id = ue->CC_id; dl_ind->frame = proc->frame_rx; @@ -114,7 +114,6 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, uint8_t pdu_type, - uint8_t gNB_id, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, @@ -268,11 +267,11 @@ void ue_ta_procedures(PHY_VARS_NR_UE *ue, int slot_tx, int frame_tx){ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, nr_phy_data_tx_t *phy_data) { int slot_tx = proc->nr_slot_tx; int frame_tx = proc->frame_tx; + int gNB_id = proc->gNB_id; AssertFatal(ue->CC_id == 0, "Transmission on secondary CCs is not supported yet\n"); @@ -290,12 +289,9 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, gNB_id, phy_data); } - ue_srs_procedures_nr(ue, proc, gNB_id); + ue_srs_procedures_nr(ue, proc); - pucch_procedures_ue_nr(ue, - gNB_id, - proc, - phy_data); + pucch_procedures_ue_nr(ue, proc, phy_data); LOG_D(PHY, "Sending Uplink data \n"); nr_ue_pusch_common_procedures(ue, @@ -303,7 +299,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, &ue->frame_parms, ue->frame_parms.nb_antennas_tx); - nr_ue_prach_procedures(ue, proc, proc->gNB_id); + nr_ue_prach_procedures(ue, proc); LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", proc->frame_tx, proc->nr_slot_tx); @@ -314,13 +310,14 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, void nr_ue_measurement_procedures(uint16_t l, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - uint16_t slot, - NR_UE_DLSCH_t *dlsch){ + NR_UE_DLSCH_t *dlsch, + uint32_t pdsch_est_size, + int32_t dl_ch_estimates[][pdsch_est_size]) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; + int gNB_id = proc->gNB_id; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_IN); if (l==2) { @@ -331,10 +328,10 @@ void nr_ue_measurement_procedures(uint16_t l, nr_slot_rx, ue->common_vars.rxdata); - nr_ue_measurements(ue, proc, nr_slot_rx, dlsch); + nr_ue_measurements(ue, proc, dlsch, pdsch_est_size, dl_ch_estimates); #if T_TRACER - if(slot == 0) + if(nr_slot_rx == 0) T(T_UE_PHY_MEAS, T_INT(gNB_id), T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(nr_slot_rx), T_INT((int)(10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB)), T_INT((int)ue->measurements.rx_rssi_dBm[0]), @@ -347,7 +344,7 @@ void nr_ue_measurement_procedures(uint16_t l, } // accumulate and filter timing offset estimation every subframe (instead of every frame) - if (( slot == 2) && (l==(2-frame_parms->Ncp))) { + if (( nr_slot_rx == 2) && (l==(2-frame_parms->Ncp))) { // AGC @@ -364,32 +361,35 @@ void nr_ue_measurement_procedures(uint16_t l, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); } -static void nr_ue_pbch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, +static void nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], - nr_phy_data_t *phy_data) { + nr_phy_data_t *phy_data, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int ret = 0; DevAssert(ue); int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; + int gNB_id = proc->gNB_id; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN); LOG_D(PHY,"[UE %d] Frame %d Slot %d, Trying PBCH (NidCell %d, gNB_id %d)\n",ue->Mod_id,frame_rx,nr_slot_rx,ue->frame_parms.Nid_cell,gNB_id); fapiPbch_t result; - ret = nr_rx_pbch(ue, proc, - estimateSz, dl_ch_estimates, + ret = nr_rx_pbch(ue, + proc, + estimateSz, + dl_ch_estimates, ue->pbch_vars[gNB_id], &ue->frame_parms, - gNB_id, (ue->frame_parms.ssb_index)&7, SISO, phy_data, - &result); + &result, + rxdataF); if (ret==0) { @@ -481,13 +481,13 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb #ifdef NR_PDCCH_SCHED -int nr_ue_pdcch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, +int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, - int n_ss) + int n_ss, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; @@ -505,7 +505,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, int16_t pdcch_e_rx[pdcch_e_rx_size]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); - nr_rx_pdcch(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, pdcch_e_rx, rel15); + nr_rx_pdcch(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, pdcch_e_rx, rel15, rxdataF); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); @@ -537,7 +537,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, dci_ind.number_of_dcis = dci_cnt; // fill dl_indication message - nr_fill_dl_indication(&dl_indication, &dci_ind, NULL, proc, ue, gNB_id, phy_data); + nr_fill_dl_indication(&dl_indication, &dci_ind, NULL, proc, ue, phy_data); // send to mac ue->if_inst->dl_indication(&dl_indication, NULL); @@ -549,23 +549,22 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, } #endif // NR_PDCCH_SCHED -int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_id, NR_UE_DLSCH_t *dlsch) { +int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + NR_UE_DLSCH_t dlsch[2], + int16_t *llr[2], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int m; - int gNB_id_i; int first_symbol_flag=0; if (!dlsch[0].active) return 0; - NR_UE_DLSCH_t *dlsch1 = NULL; - - if (NR_MAX_NB_LAYERS > 4) - dlsch1 = &dlsch[1]; - - if (!dlsch1) { + // We handle only one CW now + if (!(NR_MAX_NB_LAYERS>4)) { NR_UE_DLSCH_t *dlsch0 = &dlsch[0]; int harq_pid = dlsch0->dlsch_config.harq_process_nbr; NR_DL_UE_HARQ_t *dlsch0_harq = ue->dl_harq_processes[harq_pid]; @@ -579,15 +578,17 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ LOG_D(PHY,"[UE %d] nr_slot_rx %d, harq_pid %d (%d), rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x, Nl %d\n", ue->Mod_id,nr_slot_rx,harq_pid,dlsch0_harq->status,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0->dlsch_config.dlDmrsSymbPos, dlsch0->Nl); + const uint32_t pdsch_est_size = ((ue->frame_parms.symbols_per_slot*ue->frame_parms.ofdm_symbol_size+15)/16)*16; + __attribute__ ((aligned(32))) int32_t pdsch_dl_ch_estimates[ue->frame_parms.nb_antennas_rx][pdsch_est_size]; + memset(pdsch_dl_ch_estimates, 0, sizeof(int32_t)*ue->frame_parms.nb_antennas_rx*pdsch_est_size); + for (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); nr_pdsch_channel_estimation(ue, proc, - gNB_id, is_SI, - nr_slot_rx, get_dmrs_port(aatx,dlsch0->dlsch_config.dmrs_ports), m, dlsch0->dlsch_config.nscid, @@ -595,7 +596,10 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ BWPStart, dlsch0->dlsch_config.dmrsConfigType, ue->frame_parms.first_carrier_offset+(BWPStart + pdsch_start_rb)*12, - pdsch_nb_rb); + pdsch_nb_rb, + pdsch_est_size, + pdsch_dl_ch_estimates, + rxdataF); #if 0 ///LOG_M: the channel estimation int nr_frame_rx = proc->frame_rx; @@ -609,10 +613,11 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ } } } + nr_ue_measurement_procedures(2, ue, proc, &dlsch[0], pdsch_est_size, pdsch_dl_ch_estimates); if (ue->chest_time == 1) { // averaging time domain channel estimates nr_chest_time_domain_avg(&ue->frame_parms, - ue->pdsch_vars[gNB_id]->dl_ch_estimates, + (int32_t **) pdsch_dl_ch_estimates, dlsch0->dlsch_config.number_symbols, dlsch0->dlsch_config.start_symbol, dlsch0->dlsch_config.dlDmrsSymbPos, @@ -631,10 +636,40 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ first_symbol_with_data++; } + c16_t ptrs_phase_per_slot[ue->frame_parms.nb_antennas_rx][NR_SYMBOLS_PER_SLOT]; + memset(ptrs_phase_per_slot, 0, ue->frame_parms.nb_antennas_rx*NR_SYMBOLS_PER_SLOT*sizeof(c16_t)); + + int32_t ptrs_re_per_slot[ue->frame_parms.nb_antennas_rx][NR_SYMBOLS_PER_SLOT]; + memset(ptrs_re_per_slot, 0, ue->frame_parms.nb_antennas_rx*NR_SYMBOLS_PER_SLOT*sizeof(c16_t)); + + uint32_t dl_valid_re[NR_SYMBOLS_PER_SLOT] = {0}; + uint32_t llr_offset[NR_SYMBOLS_PER_SLOT] = {0}; + + const uint32_t rx_size = NR_SYMBOLS_PER_SLOT* + dlsch[0].dlsch_config.number_rbs* + NR_NB_SC_PER_RB; + __attribute__ ((aligned(32))) int32_t dl_ch_estimates_ext[ue->frame_parms.nb_antennas_rx][rx_size]; + memset(dl_ch_estimates_ext, 0, ue->frame_parms.nb_antennas_rx*rx_size*sizeof(int32_t)); + + __attribute__ ((aligned(32))) int32_t rxdataF_ext[ue->frame_parms.nb_antennas_rx][rx_size]; + memset(rxdataF_ext, 0, ue->frame_parms.nb_antennas_rx*rx_size*sizeof(int32_t)); + + __attribute__ ((aligned(32))) int32_t rxdataF_comp[ue->frame_parms.nb_antennas_rx][rx_size]; + memset(rxdataF_comp, 0, ue->frame_parms.nb_antennas_rx*rx_size*sizeof(int32_t)); + + __attribute__ ((aligned(32))) int32_t dl_ch_mag[ue->frame_parms.nb_antennas_rx][rx_size]; + memset(dl_ch_mag, 0, ue->frame_parms.nb_antennas_rx*rx_size*sizeof(int32_t)); + + __attribute__ ((aligned(32))) int32_t dl_ch_magb[ue->frame_parms.nb_antennas_rx][rx_size]; + memset(dl_ch_magb, 0, ue->frame_parms.nb_antennas_rx*rx_size*sizeof(int32_t)); + + __attribute__ ((aligned(32))) int32_t dl_ch_magr[ue->frame_parms.nb_antennas_rx][rx_size]; + memset(dl_ch_magr, 0, ue->frame_parms.nb_antennas_rx*rx_size*sizeof(int32_t)); + + int32_t log2_maxh = 0; start_meas(&ue->rx_pdsch_stats); for (m = s0; m < (s1 + s0); m++) { - gNB_id_i = gNB_id+1; if (m==first_symbol_with_data) first_symbol_flag = 1; else @@ -649,13 +684,25 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ if (nr_rx_pdsch(ue, proc, dlsch, - gNB_id, - gNB_id_i, - frame_rx, - nr_slot_rx, m, first_symbol_flag, - harq_pid) < 0) + harq_pid, + pdsch_est_size, + pdsch_dl_ch_estimates, + llr, + ptrs_phase_per_slot, + ptrs_re_per_slot, + dl_valid_re, + rx_size, + dl_ch_estimates_ext, + rxdataF_ext, + rxdataF_comp, + dl_ch_mag, + dl_ch_magb, + dl_ch_magr, + rxdataF, + llr_offset, + &log2_maxh) < 0) return -1; stop_meas(&ue->dlsch_llr_stats_parallelization[slot]); @@ -666,27 +713,40 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ } } // CRNTI active stop_meas(&ue->rx_pdsch_stats); + + UEscopeCopy(ue, pdschRxdataF_comp, rxdataF_comp, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, rx_size); + + if (ue->phy_sim_pdsch_rxdataF_comp) + memcpy(ue->phy_sim_pdsch_rxdataF_comp, rxdataF_comp, sizeof(int32_t)*rx_size*ue->frame_parms.nb_antennas_rx); + if (ue->phy_sim_pdsch_rxdataF_ext) + memcpy(ue->phy_sim_pdsch_rxdataF_ext, rxdataF_ext, sizeof(int32_t)*rx_size*ue->frame_parms.nb_antennas_rx); + if (ue->phy_sim_pdsch_dl_ch_estimates_ext) + memcpy(ue->phy_sim_pdsch_dl_ch_estimates_ext, dl_ch_estimates_ext, sizeof(int32_t)*rx_size*ue->frame_parms.nb_antennas_rx); + if (ue->phy_sim_pdsch_dl_ch_estimates) + memcpy(ue->phy_sim_pdsch_dl_ch_estimates, dl_ch_estimates_ext, sizeof(int32_t)*rx_size*ue->frame_parms.nb_antennas_rx); } return 0; } bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int gNB_id, - NR_UE_DLSCH_t *dlsch0, - NR_UE_DLSCH_t *dlsch1) { + NR_UE_DLSCH_t dlsch[2], + int16_t* llr[2]) { - if (dlsch0==NULL) - AssertFatal(0,"dlsch0 should be defined at this level \n"); + if (dlsch[0].active == false) { + LOG_E(PHY, "DLSCH should be active when calling this function\n"); + return 1; + } + + int gNB_id = proc->gNB_id; bool dec = false; - int harq_pid = dlsch0->dlsch_config.harq_process_nbr; + int harq_pid = dlsch[0].dlsch_config.harq_process_nbr; int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; uint32_t ret = UINT32_MAX, ret1 = UINT32_MAX; - NR_UE_PDSCH *pdsch_vars; NR_DL_UE_HARQ_t *dl_harq0 = &ue->dl_harq_processes[0][harq_pid]; - NR_DL_UE_HARQ_t *dl_harq1 = &ue->dl_harq_processes[NR_MAX_NB_LAYERS>4 ? 1:0][harq_pid]; - uint16_t dmrs_len = get_num_dmrs(dlsch0->dlsch_config.dlDmrsSymbPos); + NR_DL_UE_HARQ_t *dl_harq1 = &ue->dl_harq_processes[1][harq_pid]; + uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); nr_downlink_indication_t dl_indication; fapi_nr_rx_indication_t *rx_ind = calloc(1, sizeof(*rx_ind)); uint16_t number_pdus = 1; @@ -694,45 +754,40 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &ue->ul_time_alignment[gNB_id]; uint8_t is_cw0_active = dl_harq0->status; - uint16_t nb_symb_sch = dlsch0->dlsch_config.number_symbols; - uint16_t start_symbol = dlsch0->dlsch_config.start_symbol; - uint8_t dmrs_type = dlsch0->dlsch_config.dmrsConfigType; + uint8_t is_cw1_active = dl_harq1->status; + uint16_t nb_symb_sch = dlsch[0].dlsch_config.number_symbols; + uint16_t start_symbol = dlsch[0].dlsch_config.start_symbol; + uint8_t dmrs_type = dlsch[0].dlsch_config.dmrsConfigType; uint8_t nb_re_dmrs; if (dmrs_type==NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch0->dlsch_config.n_dmrs_cdm_groups; + nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; } else { - nb_re_dmrs = 4*dlsch0->dlsch_config.n_dmrs_cdm_groups; + nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; } - uint8_t is_cw1_active = 0; - if(dlsch1) - is_cw1_active = dl_harq1->status; - LOG_D(PHY,"AbsSubframe %d.%d Start LDPC Decoder for CW0 [harq_pid %d] ? %d \n", frame_rx%1024, nr_slot_rx, harq_pid, is_cw0_active); LOG_D(PHY,"AbsSubframe %d.%d Start LDPC Decoder for CW1 [harq_pid %d] ? %d \n", frame_rx%1024, nr_slot_rx, harq_pid, is_cw1_active); - pdsch_vars = ue->pdsch_vars[gNB_id]; - // exit dlsch procedures as there are no active dlsch if (is_cw0_active != ACTIVE && is_cw1_active != ACTIVE) return false; // start ldpc decode for CW 0 - dl_harq0->G = nr_get_G(dlsch0->dlsch_config.number_rbs, + dl_harq0->G = nr_get_G(dlsch[0].dlsch_config.number_rbs, nb_symb_sch, nb_re_dmrs, dmrs_len, - dlsch0->dlsch_config.qamModOrder, - dlsch0->Nl); + dlsch[0].dlsch_config.qamModOrder, + dlsch[0].Nl); start_meas(&ue->dlsch_unscrambling_stats); - nr_dlsch_unscrambling(pdsch_vars->llr[0], + nr_dlsch_unscrambling(llr[0], dl_harq0->G, 0, ue->frame_parms.Nid_cell, - dlsch0->rnti); + dlsch[0].rnti); stop_meas(&ue->dlsch_unscrambling_stats); @@ -742,9 +797,9 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, ret = nr_dlsch_decoding(ue, proc, gNB_id, - pdsch_vars->llr[0], + llr[0], &ue->frame_parms, - dlsch0, + &dlsch[0], dl_harq0, frame_rx, nb_symb_sch, @@ -758,7 +813,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, dec = true; int ind_type = -1; - switch(dlsch0->rnti_type) { + switch(dlsch[0].rnti_type) { case _RA_RNTI_: ind_type = FAPI_NR_RX_PDU_TYPE_RAR; break; @@ -772,14 +827,14 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, break; default: - AssertFatal(true, "Invalid DLSCH type %d\n", dlsch0->rnti_type); + AssertFatal(true, "Invalid DLSCH type %d\n", dlsch[0].rnti_type); break; } - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); - nr_fill_rx_indication(rx_ind, ind_type, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, NULL); + nr_fill_rx_indication(rx_ind, ind_type, ue, &dlsch[0], NULL, number_pdus, proc, NULL); - LOG_D(PHY, "In %s DL PDU length in bits: %d, in bytes: %d \n", __FUNCTION__, dlsch0->dlsch_config.TBS, dlsch0->dlsch_config.TBS / 8); + LOG_D(PHY, "In %s DL PDU length in bits: %d, in bytes: %d \n", __FUNCTION__, dlsch[0].dlsch_config.TBS, dlsch[0].dlsch_config.TBS / 8); stop_meas(&ue->dlsch_decoding_stats); if (cpumeas(CPUMEAS_GETSTATE)) { @@ -791,18 +846,18 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, if(is_cw1_active) { // start ldpc decode for CW 1 - dl_harq1->G = nr_get_G(dlsch1->dlsch_config.number_rbs, + dl_harq1->G = nr_get_G(dlsch[1].dlsch_config.number_rbs, nb_symb_sch, nb_re_dmrs, dmrs_len, - dlsch1->dlsch_config.qamModOrder, - dlsch1->Nl); + dlsch[1].dlsch_config.qamModOrder, + dlsch[1].Nl); start_meas(&ue->dlsch_unscrambling_stats); - nr_dlsch_unscrambling(pdsch_vars->llr[1], + nr_dlsch_unscrambling(llr[1], dl_harq1->G, 0, ue->frame_parms.Nid_cell, - dlsch1->rnti); + dlsch[1].rnti); stop_meas(&ue->dlsch_unscrambling_stats); start_meas(&ue->dlsch_decoding_stats); @@ -810,9 +865,9 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, ret1 = nr_dlsch_decoding(ue, proc, gNB_id, - pdsch_vars->llr[1], + llr[1], &ue->frame_parms, - dlsch1, + &dlsch[1], dl_harq1, frame_rx, nb_symb_sch, @@ -827,7 +882,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats.p_time)/(cpuf*1000.0)); } - LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch0->dlsch_config.TBS); + LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch[1].dlsch_config.TBS); } // send to mac if (ue->if_inst && ue->if_inst->dl_indication) { @@ -979,11 +1034,11 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, nr_phy_data_t *phy_data) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; + int gNB_id = proc->gNB_id; fapi_nr_config_request_t *cfg = &ue->nrUE_config; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; NR_UE_PDCCH_CONFIG *phy_pdcch_config = &phy_data->phy_pdcch_config; @@ -995,6 +1050,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_slot_rx); + const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP; + __attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz]; // checking if current frame is compatible with SSB periodicity if (cfg->ssb_table.ssb_period == 0 || !(frame_rx%(1<<(cfg->ssb_table.ssb_period-1)))){ @@ -1022,17 +1079,23 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_slot_fep(ue, proc, (ssb_start_symbol+i)%(fp->symbols_per_slot), - nr_slot_rx); + rxdataF); start_meas(&ue->dlsch_channel_estimation_stats); - nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, - dl_ch_estimates_time, proc, gNB_id, - nr_slot_rx, (ssb_start_symbol+i)%(fp->symbols_per_slot), - i-1, ssb_index&7, ssb_slot_2 == nr_slot_rx); + nr_pbch_channel_estimation(ue, + estimateSz, + dl_ch_estimates, + dl_ch_estimates_time, + proc, + (ssb_start_symbol+i)%(fp->symbols_per_slot), + i-1, + ssb_index&7, + ssb_slot_2 == nr_slot_rx, + rxdataF); stop_meas(&ue->dlsch_channel_estimation_stats); } - nr_ue_ssb_rsrp_measurements(ue, ssb_index, proc, nr_slot_rx); + nr_ue_ssb_rsrp_measurements(ue, ssb_index, proc, rxdataF); // resetting ssb index for PBCH detection if there is a stronger SSB index if(ue->measurements.ssb_rsrp_dBm[ssb_index] > ue->measurements.ssb_rsrp_dBm[fp->ssb_index]) @@ -1041,23 +1104,23 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if(ssb_index == fp->ssb_index) { LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); - nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_data); + nr_ue_pbch_procedures(ue, proc, estimateSz, dl_ch_estimates, phy_data, rxdataF); if (ue->no_timing_correction==0) { - LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); - nr_adjust_synch_ue(fp, - ue, - gNB_id, - fp->ofdm_symbol_size, - dl_ch_estimates_time, - frame_rx, - nr_slot_rx, - 0, - 16384); + LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); + nr_adjust_synch_ue(fp, + ue, + gNB_id, + fp->ofdm_symbol_size, + dl_ch_estimates_time, + frame_rx, + nr_slot_rx, + 0, + 16384); } } LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); - nr_ue_rrc_measurements(ue, proc, nr_slot_rx); + nr_ue_rrc_measurements(ue, proc, rxdataF); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_OUT); } } @@ -1079,9 +1142,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_slot_fep(ue, proc, (j%fp->symbols_per_slot), - nr_slot_rx); + rxdataF); } - nr_prs_channel_estimation(gNB_id,rsc_id,i,ue,proc,fp); + nr_prs_channel_estimation(rsc_id, + i, + ue, + proc, + fp, + rxdataF); } } // for i } // for rsc_id @@ -1115,7 +1183,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_slot_fep(ue, proc, l, - nr_slot_rx); + rxdataF); } // Hold the channel estimates in frequency domain. @@ -1130,19 +1198,18 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_pdcch_channel_estimation(ue, proc, - gNB_id, - nr_slot_rx, l, &phy_pdcch_config->pdcch_config[n_ss].coreset, fp->first_carrier_offset, phy_pdcch_config->pdcch_config[n_ss].BWPStart, pdcch_est_size, - pdcch_dl_ch_estimates); + pdcch_dl_ch_estimates, + rxdataF); stop_meas(&ue->ofdm_demod_stats); } - dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_data, n_ss); + dci_cnt = dci_cnt + nr_ue_pdcch_procedures(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_data, n_ss, rxdataF); } phy_pdcch_config->nb_search_space = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_OUT); @@ -1164,7 +1231,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_slot_fep(ue, proc, m, //to be updated from higher layer - nr_slot_rx); + rxdataF); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDSCH, VCD_FUNCTION_OUT); } @@ -1177,27 +1244,47 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, start_meas(&ue->generic_stat); // do procedures for C-RNTI int ret_pdsch = 0; - if (dlsch->active) { + if (dlsch[0].active) { + + uint8_t nb_re_dmrs; + if (dlsch[0].dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + } + else { + nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + } + uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); + + const uint32_t rx_llr_size = nr_get_G(dlsch[0].dlsch_config.number_rbs, + dlsch[0].dlsch_config.number_symbols, + nb_re_dmrs, + dmrs_len, + dlsch[0].dlsch_config.qamModOrder, + dlsch[0].Nl); + const uint32_t rx_llr_buf_sz = ((rx_llr_size+15)/16)*16; + const uint32_t nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; + int16_t* llr[2]; + for (int i=0; idlsch_procedures_stat); - NR_UE_DLSCH_t *dlsch1 = NULL; - if (NR_MAX_NB_LAYERS>4) - dlsch1 = &phy_data->dlsch[1]; - if (ret_pdsch >= 0) - nr_ue_dlsch_procedures(ue, proc, gNB_id, dlsch, dlsch1); + nr_ue_dlsch_procedures(ue, proc, dlsch, llr); stop_meas(&ue->dlsch_procedures_stat); if (cpumeas(CPUMEAS_GETSTATE)) { @@ -1205,8 +1292,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + if (ue->phy_sim_rxdataF) + memcpy(ue->phy_sim_rxdataF, rxdataF, sizeof(int32_t)*rxdataF_sz*ue->frame_parms.nb_antennas_rx); + if (ue->phy_sim_pdsch_llr) + memcpy(ue->phy_sim_pdsch_llr, llr[0], sizeof(int16_t)*rx_llr_buf_sz); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + for (int i=0; icsiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx]; if(nr_slot_fep_done == false) { - nr_slot_fep(ue, proc, ue->csiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx], nr_slot_rx); + nr_slot_fep(ue, proc, ue->csiim_vars[gNB_id]->csiim_config_pdu.l_csiim[symb_idx], rxdataF); } } - nr_ue_csi_im_procedures(ue, proc, gNB_id); + nr_ue_csi_im_procedures(ue, proc, rxdataF); ue->csiim_vars[gNB_id]->active = 0; } @@ -1232,10 +1325,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if ((ue->csirs_vars[gNB_id]) && (ue->csirs_vars[gNB_id]->active == 1)) { for(int symb = 0; symb < NR_SYMBOLS_PER_SLOT; symb++) { if(is_csi_rs_in_symbol(ue->csirs_vars[gNB_id]->csirs_config_pdu,symb)) { - nr_slot_fep(ue, proc, symb, nr_slot_rx); + nr_slot_fep(ue, proc, symb, rxdataF); } } - nr_ue_csi_rs_procedures(ue, proc, gNB_id); + nr_ue_csi_rs_procedures(ue, proc, rxdataF); ue->csirs_vars[gNB_id]->active = 0; } @@ -1281,14 +1374,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx.p_time/(cpuf*1000.0)); LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, nr_slot_rx); + UEscopeCopy(ue, commonRxdataF, rxdataF, sizeof(int32_t), ue->frame_parms.nb_antennas_rx, rxdataF_sz); return (0); } // todo: // - power control as per 38.213 ch 7.4 -void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id) { +void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc) { + int gNB_id = proc->gNB_id; int frame_tx = proc->frame_tx, nr_slot_tx = proc->nr_slot_tx, prach_power; // tx_amp uint8_t mod_id = ue->Mod_id; diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index a10e6a29b4..5e53b3e17b 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -199,11 +199,10 @@ void nr_generate_pucch3_4(int32_t **txdataF, *********************************************************************/ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, - uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data) { - int nr_slot_tx = proc->nr_slot_tx; + int nr_slot_tx = proc->nr_slot_tx; fapi_nr_ul_config_pucch_pdu *pucch_pdu; NR_UE_PUCCH *pucch_vars = &phy_data->pucch_vars; diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h index 7f8bf13da3..26404427ce 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h @@ -60,7 +60,6 @@ /*************** FUNCTIONS ****************************************/ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, - uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 46c5ed636d..5d1cbb7fbe 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -410,7 +410,7 @@ int main(int argc, char **argv) nr_ue_dlsch_init(dlsch_ue, num_codeword, 5); for (int i=0; i < num_codeword; i++) dlsch_ue[0].rnti = n_rnti; - nr_init_dl_harq_processes(UE->dl_harq_processes[0], 8, nb_rb); + nr_init_dl_harq_processes(UE->dl_harq_processes, 8, nb_rb); unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; processingData_L1tx_t msgDataTx; @@ -616,9 +616,7 @@ int main(int argc, char **argv) free(RC.gNB[0]); free(RC.gNB); - int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; - for (int i = 0; i < num_cw; i++) - free_nr_ue_dl_harq(UE->dl_harq_processes[i], 8, nb_rb); + free_nr_ue_dl_harq(UE->dl_harq_processes, 8, nb_rb); term_nr_ue_signal(UE, 1); free(UE); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 906613ef7c..671e613679 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -1051,6 +1051,14 @@ int main(int argc, char **argv) msgDataTx->frame = frame; memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); + // Buffers to store internal memory of slot process + UE->phy_sim_rxdataF = calloc(frame_parms->samples_per_slot_wCP*sizeof(int32_t), frame_parms->nb_antennas_rx); + UE->phy_sim_pdsch_llr = calloc((8*(3*8*8448))*sizeof(int16_t), 1); //Max length + UE->phy_sim_pdsch_rxdataF_ext = calloc(14*frame_parms->N_RB_DL*12*sizeof(int32_t), frame_parms->nb_antennas_rx); + UE->phy_sim_pdsch_rxdataF_comp = calloc(14*frame_parms->N_RB_DL*12*sizeof(int32_t), frame_parms->nb_antennas_rx); + UE->phy_sim_pdsch_dl_ch_estimates = calloc(14*frame_parms->ofdm_symbol_size*sizeof(int32_t), frame_parms->nb_antennas_rx); + UE->phy_sim_pdsch_dl_ch_estimates_ext = calloc(14*frame_parms->N_RB_DL*12*sizeof(int32_t), frame_parms->nb_antennas_rx); + for (SNR = snr0; SNR < snr1; SNR += .2) { varArray_t *table_tx=initVarArray(1000,sizeof(double)); @@ -1089,6 +1097,7 @@ int main(int argc, char **argv) UE->rx_offset=0; UE_proc.frame_rx = frame; UE_proc.nr_slot_rx = slot; + UE_proc.gNB_id = 0; dcireq.frame = frame; dcireq.slot = slot; @@ -1270,7 +1279,6 @@ int main(int argc, char **argv) phy_procedures_nrUE_RX(UE, &UE_proc, - 0, &phy_data); //---------------------------------------------------------- @@ -1280,8 +1288,7 @@ int main(int argc, char **argv) if (dlsch0->last_iteration_cnt >= dlsch0->max_ldpc_iterations+1) n_errors[round]++; - NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars; - int16_t *UE_llr = pdsch_vars[0]->llr[0]; + int16_t *UE_llr = (int16_t*)UE->phy_sim_pdsch_llr; TBS = dlsch0->dlsch_config.TBS;//rel15->TBSize[0]; uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos); @@ -1419,11 +1426,11 @@ int main(int argc, char **argv) LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1); if (UE->frame_parms.nb_antennas_rx>1) LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1); - LOG_M("rxF0.m","rxF0", UE->common_vars.rxdataF[0], frame_parms->samples_per_slot_wCP, 1, 1); - LOG_M("rxF_ext.m","rxFe",&UE->pdsch_vars[0]->rxdataF_ext[0][0],g_rbSize*12*14,1,1); - LOG_M("chestF0.m","chF0",&UE->pdsch_vars[0]->dl_ch_estimates_ext[0][0],g_rbSize*12*14,1,1); - write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1); - LOG_M("rxF_llr.m","rxFllr",UE->pdsch_vars[0]->llr[0],available_bits,1,0); + LOG_M("rxF0.m","rxF0", UE->phy_sim_rxdataF, frame_parms->samples_per_slot_wCP, 1, 1); + LOG_M("rxF_ext.m","rxFe",UE->phy_sim_pdsch_rxdataF_ext,g_rbSize*12*14,1,1); + LOG_M("chestF0.m","chF0",UE->phy_sim_pdsch_dl_ch_estimates_ext,g_rbSize*12*14,1,1); + write_output("rxF_comp.m","rxFc",UE->phy_sim_pdsch_rxdataF_comp,N_RB_DL*12*14,1,1); + LOG_M("rxF_llr.m","rxFllr",UE->phy_sim_pdsch_llr,available_bits,1,0); break; } @@ -1454,6 +1461,12 @@ int main(int argc, char **argv) free(txdata); free(test_input_bit); free(estimated_output_bit); + free(UE->phy_sim_rxdataF); + free(UE->phy_sim_pdsch_llr); + free(UE->phy_sim_pdsch_rxdataF_ext); + free(UE->phy_sim_pdsch_rxdataF_comp); + free(UE->phy_sim_pdsch_dl_ch_estimates); + free(UE->phy_sim_pdsch_dl_ch_estimates_ext); if (output_fd) fclose(output_fd); diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index ca9cf61115..dd5082d756 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -78,11 +78,9 @@ void nr_fill_dl_indication(nr_downlink_indication_t *dl_ind, fapi_nr_rx_indication_t *rx_ind, UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, - uint8_t gNB_id, void *phy_data) {} void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, uint8_t pdu_type, - uint8_t gNB_id, PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 8a2e062a7d..cb193e83e8 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -81,28 +81,28 @@ nrUE_params_t *get_nrUE_params(void) { void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} -int nr_ue_pdcch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, +int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, - int n_ss) { + int n_ss, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { return 0; } int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int eNB_id, - NR_UE_DLSCH_t *dlsch) { + NR_UE_DLSCH_t dlsch[2], + int16_t *llr[2], + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { return 0; } bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int gNB_id, - NR_UE_DLSCH_t *dlsch0, - NR_UE_DLSCH_t *dlsch1) { + NR_UE_DLSCH_t dlsch[2], + int16_t *llr[2]) { return false; } @@ -592,6 +592,8 @@ int main(int argc, char **argv) processingData_L1tx_t msgDataTx; // generate signal + const uint32_t rxdataF_sz = UE->frame_parms.samples_per_slot_wCP; + __attribute__ ((aligned(32))) c16_t rxdataF[UE->frame_parms.nb_antennas_rx][rxdataF_sz]; if (input_fd==NULL) { for (i=0; iLmax; i++) { @@ -756,14 +758,16 @@ int main(int argc, char **argv) UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index); int ssb_slot = (UE->symbol_offset/14)+(n_hf*(frame_parms->slots_per_frame>>1)); + proc.nr_slot_rx = ssb_slot; + proc.gNB_id = 0; for (int i=UE->symbol_offset+1; isymbol_offset+4; i++) { nr_slot_fep(UE, &proc, i%frame_parms->symbols_per_slot, - ssb_slot); + rxdataF); nr_pbch_channel_estimation(UE,estimateSz, dl_ch_estimates, dl_ch_estimates_time, &proc, - 0,ssb_slot,i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf); + i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf,rxdataF); } fapiPbch_t result; @@ -772,11 +776,11 @@ int main(int argc, char **argv) estimateSz, dl_ch_estimates, UE->pbch_vars[0], frame_parms, - 0, ssb_index%8, SISO, &phy_data, - &result); + &result, + rxdataF); if (ret==0) { //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 315fa9a013..071c04d498 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -304,7 +304,6 @@ int main(int argc, char **argv) uint16_t nb_rb = 50; int Imcs = 9; uint8_t precod_nbr_layers = 1; - int gNB_id = 0; int tx_offset; int32_t txlev_sum = 0, atxlev[4]; int start_rb = 0; @@ -1101,6 +1100,7 @@ int main(int argc, char **argv) UE_proc.nr_slot_tx = slot; UE_proc.frame_tx = frame; + UE_proc.gNB_id = 0; UL_tti_req->SFN = frame; UL_tti_req->Slot = slot; @@ -1244,7 +1244,7 @@ int main(int argc, char **argv) /////////////////////////phy_procedures_nr_ue_TX/////////////////////// /////////// - phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, &phy_data); + phy_procedures_nrUE_TX(UE, &UE_proc, &phy_data); if (n_trials == 1) { LOG_M("txsig0.m", "txs0", &UE->common_vars.txdata[0][slot_offset], slot_length, 1, 1);