From 8950a77999717977315b75d7d5f57cc3b25f28c1 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 8 Mar 2019 18:21:44 +0100 Subject: [PATCH 01/23] SSB periodicity at gNB hardcoded in config_common and passed down, to be taken from config file in next commit --- openair1/PHY/INIT/nr_init.c | 1 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 30 +++++++++++++++++------ openair2/LAYER2/NR_MAC_gNB/config.c | 1 + 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index c52f5e5245..5c1d9fe008 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -403,6 +403,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { gNB_config->sch_config.n_ssb_crb.value = (phy_config->cfg->rf_config.dl_carrier_bandwidth.value-20); gNB_config->sch_config.physical_cell_id.value = phy_config->cfg->sch_config.physical_cell_id.value; gNB_config->sch_config.ssb_scg_position_in_burst.value= phy_config->cfg->sch_config.ssb_scg_position_in_burst.value; + gNB_config->sch_config.ssb_periodicity.value = phy_config->cfg->sch_config.ssb_periodicity.value; if (phy_config->cfg->subframe_config.duplex_mode.value == 0) { gNB_config->subframe_config.duplex_mode.value = TDD; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index aeda4b3549..c23af9c4ea 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -91,12 +91,20 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; uint8_t ssb_index, n_hf; int ssb_start_symbol, rel_slot; - + printf("Frame %d\n",frame); n_hf = cfg->sch_config.half_frame_index.value; + + // if SSB periodicity is 5ms, they are transmitted in both half frames + if ( cfg->sch_config.ssb_periodicity.value == 5) { + if (slot<10) + n_hf=0; + else + n_hf=1; + } + // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be rel_slot = (n_hf)? (slot-10) : slot; - LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot); if(rel_slot<10 && rel_slot>=0) { @@ -114,7 +122,10 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); - nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); + if (fp->Lmax == 4) + nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); + else + nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[0][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_pbch(&gNB->pbch, pbch_pdu, @@ -139,6 +150,12 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; int offset = gNB->CC_id; + uint8_t ssb_frame_periodicity; // every how many frames SSB are generated + + if (cfg->sch_config.ssb_periodicity.value < 20) + ssb_frame_periodicity = 1; + else + ssb_frame_periodicity = (cfg->sch_config.ssb_periodicity.value)/10 ; // 10ms is the frame length if ((cfg->subframe_config.duplex_mode.value == TDD) && (nr_slot_select(cfg,slot)==SF_UL)) return; @@ -151,10 +168,9 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, memset(gNB->common_vars.txdataF[aa],0,fp->samples_per_slot_wCP*sizeof(int32_t)); } - if (nfapi_mode == 0 || nfapi_mode == 1) { - nr_common_signal_procedures(gNB,frame, slot); - //if (frame == 9) - //write_output("txdataF.m","txdataF",gNB->common_vars.txdataF[aa],fp->samples_per_frame_wCP, 1, 1); + if (nfapi_mode == 0 || nfapi_mode == 1) { + if (!(frame%ssb_frame_periodicity)) // generate SSB only for given frames according to SSB periodicity + nr_common_signal_procedures(gNB,frame, slot); } num_dci = gNB->pdcch_vars.num_dci; diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 12d01981d2..d48e8f013e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -197,6 +197,7 @@ void config_common(int Mod_idP, cfg->sch_config.physical_cell_id.value = cellid; cfg->sch_config.ssb_scg_position_in_burst.value = ssb_pattern; + cfg->sch_config.ssb_periodicity.value = 20; // FDD cfg->subframe_config.duplex_mode.value = 1; From 6e33fcfe28eeed78dc8b97d009fc7f6ffb9b77d7 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 11 Mar 2019 10:54:20 +0100 Subject: [PATCH 02/23] SSB periodicity at gNB from config file --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair2/LAYER2/NR_MAC_gNB/config.c | 27 +++++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 ++- openair2/RRC/NR/rrc_gNB.c | 2 +- .../gnb.band22.tm1.106PRB.adrv9371zc706.conf | 2 +- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 2 +- .../CONF/gnb.band78.tm1.217PRB.usrpn300.conf | 2 +- 8 files changed, 35 insertions(+), 7 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index c23af9c4ea..cd25ebc15a 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -91,7 +91,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; uint8_t ssb_index, n_hf; int ssb_start_symbol, rel_slot; - printf("Frame %d\n",frame); + n_hf = cfg->sch_config.half_frame_index.value; // if SSB periodicity is 5ms, they are transmitted in both half frames diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index d48e8f013e..a12981dafa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -187,6 +187,7 @@ void config_common(int Mod_idP, int cellid, int nr_bandP, uint64_t ssb_pattern, + uint16_t ssb_periodicity, uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP ){ @@ -242,6 +243,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, int p_gNB, int nr_bandP, uint64_t ssb_pattern, + uint16_t ssb_enum_periodicity, uint64_t dl_CarrierFreqP, int dl_BandwidthP, NR_BCCH_BCH_Message_t *mib, @@ -249,6 +251,30 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, ){ + uint16_t ssb_periodicity; + + switch (ssb_enum_periodicity) { + case 0: + ssb_periodicity = 5; + break; + case 1: + ssb_periodicity = 10; + break; + case 2: + ssb_periodicity = 20; + break; + case 3: + ssb_periodicity = 40; + break; + case 4: + ssb_periodicity = 80; + break; + case 5: + ssb_periodicity = 160; + break; + + } + if( mib != NULL ){ config_nr_mib(Mod_idP, CC_idP, @@ -273,6 +299,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, cellid, nr_bandP, ssb_pattern, + ssb_periodicity, dl_CarrierFreqP, dl_BandwidthP ); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index a214b160a2..36adc84d19 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,10 +38,11 @@ void mac_top_init_gNB(void); int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_id, - int cellid, + int cellid, int p_gNB, int nr_bandP, uint64_t ssb_pattern, + uint16_t ssb_periodicity, uint64_t dl_CarrierFreqP, int dl_BandwidthP, NR_BCCH_BCH_Message_t *mib, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 801673b2ef..5af4ad0f4e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -260,13 +260,13 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, ); LOG_I(NR_RRC,"Done init_NR_SI\n"); - rrc_mac_config_req_gNB(ctxt_pP->module_id, CC_id, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB, configuration->nr_band[CC_id], + configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id], configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id], RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, configuration->N_RB_DL[CC_id], diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf index 5fd4b465b3..c121cce0aa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_ssb_periodicityServingCell = 20; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 077d1e5bd3..774fabd60f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_ssb_periodicityServingCell = 20; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index be98106d1e..3593f2681a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_ssb_periodicityServingCell = 20; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index dbd937d61a..36c0fb58ea 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_ssb_periodicityServingCell = 20; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; From aa12c954c1c5b61c69edad42808454eb4e0f7829 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 11 Mar 2019 12:36:57 +0100 Subject: [PATCH 03/23] bugfix --- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- openair2/RRC/NR/rrc_gNB.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index a12981dafa..257687b99b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -198,7 +198,7 @@ void config_common(int Mod_idP, cfg->sch_config.physical_cell_id.value = cellid; cfg->sch_config.ssb_scg_position_in_burst.value = ssb_pattern; - cfg->sch_config.ssb_periodicity.value = 20; + cfg->sch_config.ssb_periodicity.value = ssb_periodicity; // FDD cfg->subframe_config.duplex_mode.value = 1; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 5af4ad0f4e..4f83b4fd8a 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -266,8 +266,8 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB, configuration->nr_band[CC_id], - configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id], configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id], + configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id], RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, configuration->N_RB_DL[CC_id], (NR_BCCH_BCH_Message_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].mib, From 41b18e210b4e96d4a51e358ea900196d028bbbb0 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 11 Mar 2019 17:22:59 +0100 Subject: [PATCH 04/23] UE SSB periodicity (hardcoded) --- openair1/SCHED_NR_UE/defs.h | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 20 ++++++++++---------- targets/RT/USER/nr-ue.c | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 5a8dc96fab..ad06543718 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -123,7 +123,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t e @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying @param phy_vars_rn pointer to RN variables */ -int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t do_pdcch_flag,runmode_t mode); +int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t do_pdcch_flag,runmode_t mode,fapi_nr_pbch_config_t pbch_config); int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 89ae3c0696..224ced0468 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4958,18 +4958,20 @@ int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_pr int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t do_pdcch_flag,runmode_t mode) { + uint8_t do_pdcch_flag,runmode_t mode, + fapi_nr_pbch_config_t pbch_config) { int l,l2; int pilot1; - int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; uint16_t nb_symb_sch = 8; // to be updated by higher layer uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; + uint8_t ssb_periodicity = 20; // TODO hardcoded to be taken from upper layers? + uint8_t ssb_frame_periodicity; LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx); @@ -5094,18 +5096,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); } + ssb_frame_periodicity = ssb_periodicity/10 ; // 10ms is the frame length - - if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1)) + // looking for pbch only in frames according to ssb periodicity + if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1) && !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) { LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); - uint8_t i_ssb = ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index; - uint8_t n_hf = (((ue->rx_ind.rx_indication_body[0].mib_pdu.additional_bits)>>4)&0x01); - for (int i=1; i<4; i++) { nr_slot_fep(ue, - (ue->symbol_offset+i), //mu=1 case B + (ue->symbol_offset+i), nr_tti_rx, 0, 0, @@ -5114,7 +5114,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); #endif - nr_pbch_channel_estimation(ue,0,0,ue->symbol_offset+i,i-1,i_ssb,n_hf); + nr_pbch_channel_estimation(ue,0,0,ue->symbol_offset+i,i-1,(pbch_config.ssb_index)&7,pbch_config.half_frame_bit); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); #endif @@ -5183,7 +5183,7 @@ start_meas(&ue->generic_stat); if(nr_tti_rx==5 && ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid]->nb_rb > 20){ //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); //write_output("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); - +openair1/SCHED_NR/phy_procedures_nr_gNB.c write_output("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); //write_output("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 020dd9adbf..2bce41a4f5 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -638,7 +638,7 @@ static void *UE_thread_synch(void *arg) { return &UE_thread_synch_retval; } -void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { +void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { // Process Rx data for one sub-frame if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { //clean previous FAPI MESSAGE @@ -661,7 +661,7 @@ void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else - phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode); + phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode, UE_mac->phy_config.config_req.pbch_config); // printf(">>> nr_ue_pdcch_procedures ended\n"); #endif } @@ -725,7 +725,7 @@ static void *UE_thread_rxn_txnp4(void *arg) { } AssertFatal ( 0== pthread_mutex_unlock(&proc->mutex_rxtx), "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" ); - processSubframeRX(UE, proc); + processSlotRX(UE, proc); //printf(">>> mac ended\n"); // Prepare the future Tx data #if 0 @@ -1123,7 +1123,7 @@ void *UE_thread(void *arg) { // pickStaticTime(lastTime); } //UE->mode != loop_through_memory else { - processSubframeRX(UE,proc); + processSlotRX(UE,proc); getchar(); } // else loop_through_memory } // while !oai_exit From aab238173fa26a6a6cfd89ec26b04a4020f0b76c Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 22 Mar 2019 13:07:26 +0100 Subject: [PATCH 05/23] taking into account trashed frames (and commenting ghost frame addition) --- openair1/PHY/defs_nr_UE.h | 2 ++ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 6 +++++- targets/RT/USER/nr-ue.c | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a482a48207..40f9d2d46c 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1019,6 +1019,8 @@ typedef struct { NR_DL_FRAME_PARMS frame_parms_before_ho; NR_UE_COMMON common_vars; + int16_t trashed_frames; + nr_ue_if_module_t *if_inst; nr_downlink_indication_t dl_indication; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 224ced0468..1bc4017cfc 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2978,6 +2978,8 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ue->high_speed_flag); if (ret==0) { + + ue->trashed_frames = 0; ue->pbch_vars[eNB_id]->pdu_errors_conseq = 0; @@ -5098,6 +5100,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ssb_frame_periodicity = ssb_periodicity/10 ; // 10ms is the frame length + frame_rx += ue->trashed_frames; + // looking for pbch only in frames according to ssb periodicity if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1) && !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) { @@ -5183,7 +5187,7 @@ start_meas(&ue->generic_stat); if(nr_tti_rx==5 && ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid]->nb_rb > 20){ //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); //write_output("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); -openair1/SCHED_NR/phy_procedures_nr_gNB.c + write_output("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); //write_output("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 2bce41a4f5..0d024ce697 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -456,7 +456,7 @@ static void *UE_thread_synch(void *arg) { #else LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); #endif - + UE->trashed_frames = 0; if (nr_initial_sync( UE, UE->mode ) == 0) { //write_output("txdata_sym.m", "txdata_sym", UE->common_vars.rxdata[0], (10*UE->frame_parms.samples_per_slot), 1, 1); freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync @@ -936,6 +936,7 @@ void *UE_thread(void *arg) { } else { // grab 10 ms of signal into dummy buffer to wait result of sync detection trashFrame(UE, ×tamp); + UE->trashed_frames++; } } @@ -949,12 +950,12 @@ void *UE_thread(void *arg) { syncInFrame(UE, ×tamp); UE->rx_offset=0; UE->time_sync_cell=0; - UE->proc.proc_rxtx[0].frame_rx++; + /*UE->proc.proc_rxtx[0].frame_rx++; //UE->proc.proc_rxtx[1].frame_rx++; for (th_id=1; th_id < RX_NB_TH; th_id++) { UE->proc.proc_rxtx[th_id].frame_rx = UE->proc.proc_rxtx[0].frame_rx; - } + }*/ //printf("first stream frame rx %d\n",UE->proc.proc_rxtx[0].frame_rx); // read in first symbol From e6fa2079b7ce9689fea7f16b017cfcbcb36c0a0b Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 27 Mar 2019 10:29:51 +0100 Subject: [PATCH 06/23] ssb periodicity in UE and initialized at nr_ue_init --- openair1/PHY/INIT/nr_init_ue.c | 2 ++ openair1/PHY/defs_nr_UE.h | 1 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index a150717e42..858b587507 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -906,6 +906,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ue->decode_MIB = 1; ue->decode_SIB = 1; + ue->ssb_periodicity = 20; // initialization of ssb periodicity + init_prach_tables(839); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 40f9d2d46c..c521b05db4 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1143,6 +1143,7 @@ typedef struct { // uint8_t prach_timer; uint8_t decode_SIB; uint8_t decode_MIB; + uint8_t ssb_periodicity; /// temporary offset during cell search prior to MIB decoding int ssb_offset; uint16_t symbol_offset; // offset in terms of symbols for detected ssb in sync diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1bc4017cfc..1d3646bc4c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4972,7 +4972,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; uint16_t nb_symb_sch = 8; // to be updated by higher layer uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; - uint8_t ssb_periodicity = 20; // TODO hardcoded to be taken from upper layers? + uint8_t ssb_periodicity = ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now uint8_t ssb_frame_periodicity; LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx); From a8e8d55f29e3c4b2ddf6b0562fd36526b3dc5e97 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 2 Apr 2019 10:02:32 +0200 Subject: [PATCH 07/23] changing calls to slot fep and ch estimation in procedure_nr_ue for slot based processing --- executables/nr-ue.c | 6 ++--- openair1/PHY/MODULATION/slot_fep_nr.c | 15 +++++------ .../nr_dl_channel_estimation.c | 25 ++++++++++--------- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 2 -- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 13 +++++----- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 13 ++++++---- .../gnb.band22.tm1.106PRB.adrv9371zc706.conf | 2 +- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 2 +- .../CONF/gnb.band78.tm1.217PRB.usrpn300.conf | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 402c379687..e22ed52f99 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -358,7 +358,7 @@ static void UE_synch(void *arg) { } } -void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { +void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { // Process Rx data for one sub-frame if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { //clean previous FAPI MESSAGE @@ -381,7 +381,7 @@ void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else - phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode); + phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode, UE_mac->phy_config.config_req.pbch_config); // printf(">>> nr_ue_pdcch_procedures ended\n"); #endif } @@ -417,7 +417,7 @@ void UE_processing(void *arg) { processingData_t *rxtxD=(processingData_t *) arg; UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; - processSubframeRX(UE, proc); + processSlotRX(UE, proc); //printf(">>> mac ended\n"); // Prepare the future Tx data #if 0 diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 6ce486e3a0..717633c1f5 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -35,7 +35,7 @@ #endif*/ int nr_slot_fep(PHY_VARS_NR_UE *ue, - unsigned char l, + unsigned char symbol, unsigned char Ns, int sample_offset, int no_prefix, @@ -44,7 +44,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_UE_COMMON *common_vars = &ue->common_vars; unsigned char aa; - unsigned char symbol = l;//+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame unsigned int nb_prefix_samples; unsigned int nb_prefix_samples0; if (ue->is_synchronized) { @@ -146,7 +145,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, nb_prefix_samples,nb_prefix_samples0,slot_offset,sample_offset,rx_offset,frame_length_samples); #endif - if (l==0) { + if (symbol==0) { if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) memcpy((short *)&common_vars->rxdata[aa][frame_length_samples], @@ -171,8 +170,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, #endif } } else { - rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*l;// + - // (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); + rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol; + // + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) memcpy((void *)&common_vars->rxdata[aa][frame_length_samples], @@ -215,14 +214,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, case NR_PDCCH_EST: #ifdef DEBUG_FEP - printf("PDCCH Channel estimation aatx %d, slot %d, symbol %d start_sc %d\n",aa,Ns,l,coreset_start_subcarrier); + printf("PDCCH Channel estimation aatx %d, slot %d, symbol %d start_sc %d\n",aa,Ns,symbol,coreset_start_subcarrier); #endif #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); #endif nr_pdcch_channel_estimation(ue,0, Ns, - l, symbol, coreset_start_subcarrier, nb_rb_coreset); @@ -234,7 +232,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, case NR_PDSCH_EST: #ifdef DEBUG_FEP - printf("Channel estimation aatx %d, slot %d, symbol %d\n",aa,Ns,l); + printf("Channel estimation aatx %d, slot %d, symbol %d\n",aa,Ns,symbol); #endif #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); @@ -246,7 +244,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, nr_pdsch_channel_estimation(ue,0, Ns, p, - l, symbol, bwp_start_subcarrier, nb_rb_pdsch); 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 917734f8ec..711a06d7a6 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -67,7 +67,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, k = nushift; #ifdef DEBUG_CH - printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns>>1], eNB_offset,ue->frame_parms.ofdm_symbol_size, + printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp,Ns,k, symbol); #endif @@ -326,6 +326,9 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + #ifdef DEBUG_CH printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -413,7 +416,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, - unsigned char l, unsigned char symbol, unsigned short coreset_start_subcarrier, unsigned short nb_rb_coreset) @@ -444,8 +446,8 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, k = coreset_start_subcarrier; #ifdef DEBUG_PDCCH - printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, - ue->frame_parms.Ncp,l,Ns,k, symbol); + printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, + ue->frame_parms.Ncp,Ns,k, symbol); #endif fl = filt16a_l1; @@ -616,14 +618,14 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, break; } - if( (Ns== 1) && (l == 0)) + if( (Ns== 1) && (symbol == 0)) { // do ifft of channel estimate for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) for (p=0; pframe_parms.nb_antenna_ports_eNB; p++) { if (ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_offset][(p<<1)+aarx]) { - LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d \n", Ns, ue->current_thread_id[Ns], l); + LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d \n", Ns, ue->current_thread_id[Ns], symbol); idft((int16_t*) &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_offset][(p<<1)+aarx][0], (int16_t*) ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates_time[eNB_offset][(p<<1)+aarx],1); } @@ -637,11 +639,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, unsigned short p, - unsigned char l, unsigned char symbol, - unsigned short bwp_start_subcarrier, - unsigned short nb_rb_pdsch) -{ + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pdsch) { + int pilot[1320] __attribute__((aligned(16))); unsigned char aarx; unsigned short k; @@ -669,8 +670,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, int re_offset = k; #ifdef DEBUG_CH - printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size, - ue->frame_parms.Ncp,l,Ns,k, symbol); + printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size, + ue->frame_parms.Ncp,Ns,k, symbol); #endif switch (nushift) { diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 29400bbdc7..1a4250028e 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -45,7 +45,6 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, - unsigned char l, unsigned char symbol, unsigned short coreset_start_subcarrier, unsigned short nb_rb_coreset); @@ -69,7 +68,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, unsigned short p, - unsigned char l, unsigned char symbol, unsigned short bwp_start_subcarrier, unsigned short nb_rb_pdsch); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index a50edecb2c..f9a8057db0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -410,7 +410,7 @@ unsigned char sign(int8_t x) { uint8_t pbch_deinterleaving_pattern[32] = {28,0,31,30,7,29,25,27,5,8,24,9,10,11,12,13,1,4,3,14,15,16,17,2,26,18,19,20,21,22,6,23}; int nr_rx_pbch( PHY_VARS_NR_UE *ue, - int subframe_rx, + int Ns, NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, @@ -443,20 +443,21 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, int symbol_offset=1; if (ue->is_synchronized > 0) - symbol_offset=ue->symbol_offset; + symbol_offset=(ue->symbol_offset)%(frame_parms->symbols_per_slot); else symbol_offset=0; + #ifdef DEBUG_PBCH - //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF); + //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF); write_output("rxdataF0_pbch.m","rxF0pbch", - &nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); + &nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].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 for (symbol=1; symbol<4; symbol++) { - nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF, - nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].dl_ch_estimates[eNB_id], + nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF, + nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_id], nr_ue_pbch_vars->rxdataF_ext, nr_ue_pbch_vars->dl_ch_estimates_ext, symbol, diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 20cae07a89..3ca667616a 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2938,7 +2938,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN); //LOG_I(PHY,"[UE %d] Frame %d, Trying PBCH %d (NidCell %d, eNB_id %d)\n",ue->Mod_id,frame_rx,pbch_phase,ue->frame_parms.Nid_cell,eNB_id); - ret = nr_rx_pbch(ue, proc->subframe_rx, + ret = nr_rx_pbch(ue, nr_tti_rx, ue->pbch_vars[eNB_id], &ue->frame_parms, eNB_id, @@ -4941,7 +4941,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; uint16_t nb_symb_sch = 8; // to be updated by higher layer uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; - uint8_t ssb_periodicity = ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now + uint8_t ssb_periodicity = 10; //ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now uint8_t ssb_frame_periodicity; uint8_t dci_cnt = 0; @@ -5085,15 +5085,18 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ssb_frame_periodicity = ssb_periodicity/10 ; // 10ms is the frame length frame_rx += ue->trashed_frames; + int ssb_slot = (pbch_config.ssb_index)/2; + // looking for pbch only in frames according to ssb periodicity - if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1) && !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) + if ((ue->decode_MIB == 1) && (nr_tti_rx == ssb_slot) )//&& !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) { LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); for (int i=1; i<4; i++) { + nr_slot_fep(ue, - (ue->symbol_offset+i), + (ue->symbol_offset+i)%(ue->frame_parms.symbols_per_slot), nr_tti_rx, 0, 0, @@ -5102,7 +5105,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); #endif - nr_pbch_channel_estimation(ue,0,0,ue->symbol_offset+i,i-1,(pbch_config.ssb_index)&7,pbch_config.half_frame_bit); + nr_pbch_channel_estimation(ue,0,nr_tti_rx,(ue->symbol_offset+i)%(ue->frame_parms.symbols_per_slot),i-1,(pbch_config.ssb_index)&7,pbch_config.half_frame_bit); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); #endif diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf index c121cce0aa..5fd4b465b3 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 20; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 4d0df95225..f22abf3112 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 20; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 3593f2681a..be98106d1e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 20; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 36c0fb58ea..dbd937d61a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 20; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; From 385dcea7ebbd0e668e81de9131023c4d6b1a2851 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 3 Apr 2019 15:07:45 +0200 Subject: [PATCH 08/23] intial sync over two frames (not working, still need to debug) --- executables/nr-ue.c | 8 +- openair1/PHY/INIT/nr_init_ue.c | 5 +- openair1/PHY/MODULATION/slot_fep_nr.c | 19 +-- openair1/PHY/NR_REFSIG/pss_nr.h | 3 +- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 108 +++++++++--------- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 65 ++++++----- openair1/PHY/defs_nr_UE.h | 5 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- 9 files changed, 118 insertions(+), 99 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e22ed52f99..e7c71aede8 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -444,16 +444,16 @@ void UE_processing(void *arg) { #endif } -void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { +void readFrames(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { void *rxp[NB_ANTENNAS_RX]; void *dummy_tx[UE->frame_parms.nb_antennas_tx]; for (int i=0; iframe_parms.nb_antennas_tx; i++) dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4); - for(int x=0; x<10; x++) { + for(int x=0; x<20; x++) { // two frames for initial sync for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) + 4*x*UE->frame_parms.samples_per_subframe; + rxp[i] = ((void *)&UE->common_vars.rxdata_is[i][0]) + 4*x*UE->frame_parms.samples_per_subframe; AssertFatal( UE->frame_parms.samples_per_subframe == UE->rfdevice.trx_read_func(&UE->rfdevice, @@ -575,7 +575,7 @@ void *UE_thread(void *arg) { } else trashFrame(UE, ×tamp); } else { - readFrame(UE, ×tamp); + readFrames(UE, ×tamp); pushTpool(Tpool, syncMsg); syncRunning=true; } diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 3a2ca5a172..226e89e489 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -710,14 +710,15 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, } // init RX buffers - + common_vars->rxdata_is= (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); for (th_id=0; th_idcommon_vars_rx_data_per_thread[th_id].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( (fp->samples_per_subframe*10+2048)*sizeof(int32_t) ); + common_vars->rxdata_is[i] = (int32_t*) malloc16_clear( (fp->samples_per_frame*2+2048)*sizeof(int32_t) ); + common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_frame+2048)*sizeof(int32_t) ); for (th_id=0; th_idcommon_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 717633c1f5..86ca29d902 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -46,11 +46,14 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, unsigned char aa; unsigned int nb_prefix_samples; unsigned int nb_prefix_samples0; + int **rxdata = NULL; if (ue->is_synchronized) { + rxdata = common_vars->rxdata; nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); } else { + rxdata = common_vars->rxdata_is; nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples); } @@ -148,13 +151,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, if (symbol==0) { if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) - memcpy((short *)&common_vars->rxdata[aa][frame_length_samples], - (short *)&common_vars->rxdata[aa][0], + memcpy((short*) &(rxdata[aa][frame_length_samples]), + (short*) &(rxdata[aa][0]), frame_parms->ofdm_symbol_size*sizeof(int)); if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs memcpy((void *)tmp_dft_in, - (void *)&common_vars->rxdata[aa][rx_offset % frame_length_samples], + (void *) &(rxdata[aa][rx_offset % frame_length_samples]), frame_parms->ofdm_symbol_size*sizeof(int)); dft((int16_t *)tmp_dft_in, (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); @@ -163,7 +166,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, start_meas(&ue->rx_dft_stats); #endif - dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + dft((int16_t *) &(rxdata[aa][(rx_offset) % frame_length_samples]), (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); #if UE_TIMING_TRACE stop_meas(&ue->rx_dft_stats); @@ -174,8 +177,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, // + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) - memcpy((void *)&common_vars->rxdata[aa][frame_length_samples], - (void *)&common_vars->rxdata[aa][0], + memcpy((void *) &(rxdata[aa][frame_length_samples]), + (void *) &(rxdata[aa][0]), frame_parms->ofdm_symbol_size*sizeof(int)); #if UE_TIMING_TRACE start_meas(&ue->rx_dft_stats); @@ -183,13 +186,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, if ((rx_offset&7)!=0) { // if input to dft is not 128-bit aligned, issue for size 6 and 15 PRBs memcpy((void *)tmp_dft_in, - (void *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + (void *) &(rxdata[aa][(rx_offset) % frame_length_samples]), frame_parms->ofdm_symbol_size*sizeof(int)); dft((int16_t *)tmp_dft_in, (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); } else { // use dft input from RX buffer directly - dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + dft((int16_t *) &(rxdata[aa][(rx_offset) % frame_length_samples]), (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); } #if UE_TIMING_TRACE diff --git a/openair1/PHY/NR_REFSIG/pss_nr.h b/openair1/PHY/NR_REFSIG/pss_nr.h index dc20ab24d7..5233acac15 100644 --- a/openair1/PHY/NR_REFSIG/pss_nr.h +++ b/openair1/PHY/NR_REFSIG/pss_nr.h @@ -134,10 +134,11 @@ void free_context_synchro_nr(void); void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue); void free_context_pss_nr(void); int set_pss_nr(int ofdm_symbol_size); -int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change); +int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change); int pss_search_time_nr(int **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, + int corr_samples, int *eNB_id, int *f_off); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 40cbb0d23e..e2e837398f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -222,10 +222,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,0); LOG_D(PHY,"nr_initial sync ue RB_DL %d\n", fp->N_RB_DL); - /* - write_output("rxdata0.m","rxd0",ue->common_vars.rxdata[0],10*fp->samples_per_subframe,1,1); - exit(-1); - */ + /* Initial synchronisation * @@ -242,26 +239,27 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) cnt++; if (1){ // (cnt>100) - cnt =0; + cnt =0; - /* process pss search on received buffer */ - sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE); + // initial sync performed on two successive frames, if pbch passes on first frame, no need to process second frame + for(int is=0; is<2;is++) { + + /* process pss search on received buffer */ + sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE); - if (sync_pos >= fp->nb_prefix_samples) - ue->ssb_offset = sync_pos - fp->nb_prefix_samples; - else - ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples; + if (sync_pos >= fp->nb_prefix_samples) + ue->ssb_offset = sync_pos - fp->nb_prefix_samples; + else + ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples; - //write_output("rxdata1.m","rxd1",ue->common_vars.rxdata[0],10*fp->samples_per_subframe,1,1); - #ifdef DEBUG_INITIAL_SYNCH - LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id); - LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); + LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id); + LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); #endif - // digital compensation of FFO for SSB symbols - if (ue->UE_fo_compensation){ + // digital compensation of FFO for SSB symbols + if (ue->UE_fo_compensation){ double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample @@ -270,17 +268,17 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) for(int n=start; nnb_antennas_rx; ar++) { - re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]); - im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]); - ((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); - ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); + re = ((double)(((short *)ue->common_vars.rxdata_is[ar]))[2*n]); + im = ((double)(((short *)ue->common_vars.rxdata_is[ar]))[2*n+1]); + ((short *)ue->common_vars.rxdata_is[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); + ((short *)ue->common_vars.rxdata_is[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); } } - } + } - /* check that SSS/PBCH block is continuous inside the received buffer */ - if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) { + /* check that SSS/PBCH block is continuous inside the received buffer */ + if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) { /* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */ /* for NR this is not the case but slot_fep is still used for computing FFT of samples */ @@ -288,37 +286,37 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) /* symbol number are from beginning of SS/PBCH blocks as below: */ /* Signal PSS PBCH SSS PBCH */ /* symbol number 0 1 2 3 */ - /* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ + /* time samples in buffer rxdata_is are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */ - for(int i=0; i<4;i++) - nr_slot_fep(ue, - i, - 0, - ue->ssb_offset, - 0, - NR_PBCH_EST); + for(int i=0; i<4;i++) + nr_slot_fep(ue, + i, + 0, + ue->ssb_offset, + 0, + NR_PBCH_EST); #ifdef DEBUG_INITIAL_SYNCH - LOG_I(PHY,"Calling sss detection (normal CP)\n"); + LOG_I(PHY,"Calling sss detection (normal CP)\n"); #endif - rx_sss_nr(ue,&metric_tdd_ncp,&phase_tdd_ncp); + rx_sss_nr(ue,&metric_tdd_ncp,&phase_tdd_ncp); - //FK: why do we need to do this again here? - //nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0); + //FK: why do we need to do this again here? + //nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0); - nr_gold_pbch(ue); - ret = nr_pbch_detection(ue,1,mode); // start pbch detection at first symbol after pss + nr_gold_pbch(ue); + ret = nr_pbch_detection(ue,1,mode); // start pbch detection at first symbol after pss - if (ret == 0) { - // sync at symbol ue->symbol_offset - // computing the offset wrt the beginning of the frame - sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples); - ue->rx_offset = ue->ssb_offset - sync_pos_frame; - } + if (ret == 0) { + // sync at symbol ue->symbol_offset + // computing the offset wrt the beginning of the frame + sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples); + ue->rx_offset = ue->ssb_offset - sync_pos_frame; + } - nr_gold_pdcch(ue,0, 2); + nr_gold_pdcch(ue,0, 2); /* int nb_prefix_samples0 = fp->nb_prefix_samples0; fp->nb_prefix_samples0 = fp->nb_prefix_samples; @@ -334,16 +332,20 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ue->common_vars.freq_offset ); */ + #ifdef DEBUG_INITIAL_SYNCH - LOG_I(PHY,"TDD Normal prefix: CellId %d metric %d, phase %d, pbch %d\n", - fp->Nid_cell,metric_tdd_ncp,phase_tdd_ncp,ret); + LOG_I(PHY,"TDD Normal prefix: CellId %d metric %d, phase %d, pbch %d\n", + fp->Nid_cell,metric_tdd_ncp,phase_tdd_ncp,ret); #endif - } - else { + + } + else { #ifdef DEBUG_INITIAL_SYNCH - LOG_I(PHY,"TDD Normal prefix: SSS error condition: sync_pos %d\n", sync_pos); + LOG_I(PHY,"TDD Normal prefix: SSS error condition: sync_pos %d\n", sync_pos); #endif - } + } + if (ret == 0) break; + } } else { ret = -1; @@ -432,13 +434,13 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) // do a measurement on the best guess of the PSS //for (aarx=0; aarxnb_antennas_rx; aarx++) - // rx_power += signal_energy(&ue->common_vars.rxdata[aarx][sync_pos2], + // rx_power += signal_energy(&ue->common_vars.rxdata_is[aarx][sync_pos2], // frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples); /* // do a measurement on the full frame for (aarx=0; aarxnb_antennas_rx; aarx++) - rx_power += signal_energy(&ue->common_vars.rxdata[aarx][0], + rx_power += signal_energy(&ue->common_vars.rxdata_is[aarx][0], frame_parms->samples_per_subframe*10); */ diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 40945bebef..1e43a26be6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -608,10 +608,14 @@ void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_ch * ********************************************************************/ -void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **rxdata) +void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int is, int **rxdata) { + int samples_for_frame; NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); - int samples_for_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti; + if (is==0) + samples_for_frame = frame_parms->samples_per_frame + frame_parms->ofdm_symbol_size; + else + samples_for_frame = frame_parms->samples_per_frame; AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti); @@ -626,11 +630,11 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **r /* build with cic filter does not work properly. Performances are significantly deteriorated */ #ifdef CIC_DECIMATOR - cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]), + cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][is*frame_parms->samples_per_frame]), (int16_t *)&(rxdata[0][0]), samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE); #else - fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]), + fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][frame_parms->samples_per_frame]), (int16_t *)&(rxdata[0][0]), samples_for_frame, rate_change, 0); #endif @@ -658,37 +662,43 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **r * *********************************************************************/ -int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change) +int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) { NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); int synchro_position; - int **rxdata = NULL; + int **rxdata; int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation + int samples_for_frame; + + // to take into account the possibility of PSS to be found between the two frames + // the analysis of the first of two frames is extended by one symbol (duration of PSS) + if (is==0) + samples_for_frame = frame_parms->samples_per_frame + frame_parms->ofdm_symbol_size; + else + samples_for_frame = frame_parms->samples_per_frame; #ifdef DBG_PSS_NR - - int samples_for_frame = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; - - LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], samples_for_frame, 1, 1); - + LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], 2*frame_parms->samples_per_frame, 1, 1); #endif + rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); + for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) + rxdata[aa] = (int32_t*) malloc16_clear( (samples_for_frame+8192)*sizeof(int32_t)); + if (rate_change != 1) { - rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); - - for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) { - rxdata[aa] = (int32_t*) malloc16_clear( (frame_parms->samples_per_subframe*10+8192)*sizeof(int32_t)); - } #ifdef SYNCHRO_DECIMAT - decimation_synchro_nr(PHY_vars_UE, rate_change, rxdata); + decimation_synchro_nr(PHY_vars_UE, rate_change, is, rxdata); #endif } else { + for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) + memcpy(&(rxdata[aa][0]), + &(PHY_vars_UE->common_vars.rxdata[aa][is*frame_parms->samples_per_frame]), + samples_for_frame*sizeof(int32_t)); - rxdata = PHY_vars_UE->common_vars.rxdata; } #ifdef DBG_PSS_NR @@ -708,6 +718,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change) synchro_position = pss_search_time_nr(rxdata, frame_parms, fo_flag, + samples_for_frame, (int *)&PHY_vars_UE->common_vars.eNb_id, (int *)&PHY_vars_UE->common_vars.freq_offset); @@ -727,21 +738,16 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change) #endif #ifdef SYNCHRO_DECIMAT + if (rate_change != 1) + restore_frame_context_pss_nr(frame_parms, rate_change); +#endif - if (rate_change != 1) { - - if (rxdata[0] != NULL) { - - for (int aa=0;aanb_antennas_rx;aa++) { + if (rxdata[0] != NULL) { + for (int aa=0;aanb_antennas_rx;aa++) free(rxdata[aa]); - } free(rxdata); - } - - restore_frame_context_pss_nr(frame_parms, rate_change); } -#endif return synchro_position; } @@ -820,6 +826,7 @@ static inline double angle64(int64_t x) int pss_search_time_nr(int **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, + int corr_samples, int *eNB_id, int *f_off) { @@ -830,7 +837,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain double ffo_est=0; - unsigned int length = (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_subframe); /* 1 frame for now, it should be 2 TODO_NR */ + unsigned int length = corr_samples; AssertFatal(length>0,"illegal length %d\n",length); for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 155b34a948..8b812caba1 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -409,6 +409,11 @@ typedef struct { /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[ int32_t **rxdata; + /// \brief Holds the received data in time domain for initial sync. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: sample [0..2*FRAME_LENGTH_COMPLEX_SAMPLES+...[ + int32_t **rxdata_is; + NR_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX]; /// holds output of the sync correlator diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 3ca667616a..30870bf62e 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4941,7 +4941,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; uint16_t nb_symb_sch = 8; // to be updated by higher layer uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; - uint8_t ssb_periodicity = 10; //ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now + uint8_t ssb_periodicity = ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now uint8_t ssb_frame_periodicity; uint8_t dci_cnt = 0; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index f22abf3112..4d0df95225 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_ssb_periodicityServingCell = 20; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; From ecaa424cbb9cc3dd460826b0d4e62c62d1244557 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 3 Apr 2019 17:11:56 +0200 Subject: [PATCH 09/23] fixes in how sync for two frames is handled in pss functions, it works --- openair1/PHY/NR_REFSIG/pss_nr.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 88 ++++++++++--------- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/pss_nr.h b/openair1/PHY/NR_REFSIG/pss_nr.h index 5233acac15..a2e66d4e11 100644 --- a/openair1/PHY/NR_REFSIG/pss_nr.h +++ b/openair1/PHY/NR_REFSIG/pss_nr.h @@ -138,7 +138,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change); int pss_search_time_nr(int **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, - int corr_samples, + int is, int *eNB_id, int *f_off); diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 1e43a26be6..e637844ed7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -608,14 +608,10 @@ void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_ch * ********************************************************************/ -void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int is, int **rxdata) +void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **rxdata) { - int samples_for_frame; NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); - if (is==0) - samples_for_frame = frame_parms->samples_per_frame + frame_parms->ofdm_symbol_size; - else - samples_for_frame = frame_parms->samples_per_frame; + int samples_for_frame = 2*frame_parms->samples_per_frame; AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti); @@ -630,11 +626,11 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int is, /* build with cic filter does not work properly. Performances are significantly deteriorated */ #ifdef CIC_DECIMATOR - cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][is*frame_parms->samples_per_frame]), (int16_t *)&(rxdata[0][0]), + cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata_is[0][0]), (int16_t *)&(rxdata[0][0]), samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE); #else - fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][frame_parms->samples_per_frame]), (int16_t *)&(rxdata[0][0]), + fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata_is[0][0]), (int16_t *)&(rxdata[0][0]), samples_for_frame, rate_change, 0); #endif @@ -666,44 +662,36 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) { NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); int synchro_position; - int **rxdata; + int **rxdata = NULL; int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation - int samples_for_frame; - - // to take into account the possibility of PSS to be found between the two frames - // the analysis of the first of two frames is extended by one symbol (duration of PSS) - if (is==0) - samples_for_frame = frame_parms->samples_per_frame + frame_parms->ofdm_symbol_size; - else - samples_for_frame = frame_parms->samples_per_frame; #ifdef DBG_PSS_NR - LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], 2*frame_parms->samples_per_frame, 1, 1); -#endif - rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); - for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) - rxdata[aa] = (int32_t*) malloc16_clear( (samples_for_frame+8192)*sizeof(int32_t)); + LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata_is[0][0], frame_parms->samples_per_frame, 1, 1); + +#endif if (rate_change != 1) { + rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); + + for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) { + rxdata[aa] = (int32_t*) malloc16_clear( (frame_parms->samples_per_frame+8192)*sizeof(int32_t)); + } #ifdef SYNCHRO_DECIMAT - decimation_synchro_nr(PHY_vars_UE, rate_change, is, rxdata); + decimation_synchro_nr(PHY_vars_UE, rate_change, rxdata); #endif } else { - for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) - memcpy(&(rxdata[aa][0]), - &(PHY_vars_UE->common_vars.rxdata[aa][is*frame_parms->samples_per_frame]), - samples_for_frame*sizeof(int32_t)); + rxdata = PHY_vars_UE->common_vars.rxdata_is; } #ifdef DBG_PSS_NR - LOG_M("rxdata0_des.m","rxd0_des", &rxdata[0][0], samples_for_frame,1,1); + LOG_M("rxdata0_des.m","rxd0_des", &rxdata[0][0], frame_parms->samples_per_frame,1,1); #endif @@ -718,7 +706,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) synchro_position = pss_search_time_nr(rxdata, frame_parms, fo_flag, - samples_for_frame, + is, (int *)&PHY_vars_UE->common_vars.eNb_id, (int *)&PHY_vars_UE->common_vars.freq_offset); @@ -738,20 +726,26 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) #endif #ifdef SYNCHRO_DECIMAT - if (rate_change != 1) - restore_frame_context_pss_nr(frame_parms, rate_change); -#endif - if (rxdata[0] != NULL) { - for (int aa=0;aanb_antennas_rx;aa++) + if (rate_change != 1) { + + if (rxdata[0] != NULL) { + + for (int aa=0;aanb_antennas_rx;aa++) { free(rxdata[aa]); + } free(rxdata); + } + + restore_frame_context_pss_nr(frame_parms, rate_change); } +#endif return synchro_position; } + static inline int abs32(int x) { return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1])); @@ -777,7 +771,7 @@ static inline double angle64(int64_t x) * * PARAMETERS : received buffer * frame parameters -* +*https://www.ilpost.it/ * RETURN : position of detected pss * * DESCRIPTION : Synchronisation on pss sequence is based on a time domain correlation between received samples and pss sequence @@ -826,7 +820,7 @@ static inline double angle64(int64_t x) int pss_search_time_nr(int **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, - int corr_samples, + int is, int *eNB_id, int *f_off) { @@ -836,13 +830,18 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain int64_t avg[NUMBER_PSS_SEQUENCE]; double ffo_est=0; - - unsigned int length = corr_samples; + // performing the correlation on a frame length plus one symbol for the first of the two frame + // to take into account the possibility of PSS in between the two frames + unsigned int length; + if (is==0) + length = frame_parms->samples_per_frame + (2*frame_parms->ofdm_symbol_size); + else + length = frame_parms->samples_per_frame; AssertFatal(length>0,"illegal length %d\n",length); for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i); - + printf("%d\n\n",length); peak_value = 0; peak_position = 0; pss_source = 0; @@ -878,7 +877,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain /* perform correlation of rx data and pss sequence ie it is a dot product */ result = dot_product64((short*)primary_synchro_time_nr[pss_index], - (short*) &(rxdata[ar][n]), + (short*) &(rxdata[ar][n])+(is*frame_parms->samples_per_frame), frame_parms->ofdm_symbol_size, shift); pss_corr_ue[pss_index][n] += abs64(result); @@ -912,13 +911,13 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain int64_t result1,result2; // Computing cross-correlation at peak on half the symbol size for first half of data result1 = dot_product64((short*)primary_synchro_time_nr[pss_source], - (short*) &(rxdata[0][peak_position]), + (short*) &(rxdata[0][peak_position])+(is*frame_parms->samples_per_frame), frame_parms->ofdm_symbol_size>>1, shift); // Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size // as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift result2 = dot_product64((short*)primary_synchro_time_nr[pss_source]+(frame_parms->ofdm_symbol_size), - (short*) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size), + (short*) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size+(is*frame_parms->samples_per_frame)), frame_parms->ofdm_symbol_size>>1, shift); @@ -957,7 +956,10 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6); LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6); LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6); - LOG_M("rxdata0.m","rxd0",rxdata[0],length,1,1); + if (is) + LOG_M("rxdata1.m","rxd0",rxdata[frame_parms->samples_per_frame],length,1,1); + else + LOG_M("rxdata0.m","rxd0",rxdata[0],length,1,1); } else { debug_cnt++; } diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 4d0df95225..f22abf3112 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -71,7 +71,7 @@ gNBs = UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 20; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; ServingCellConfigCommon_ss_PBCH_BlockPower = -60; From e5a682c690e76f94559861e95af73444eacb2942 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 3 Apr 2019 17:14:47 +0200 Subject: [PATCH 10/23] Update pss_nr.c --- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index e637844ed7..626ba15022 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -771,7 +771,7 @@ static inline double angle64(int64_t x) * * PARAMETERS : received buffer * frame parameters -*https://www.ilpost.it/ +* * RETURN : position of detected pss * * DESCRIPTION : Synchronisation on pss sequence is based on a time domain correlation between received samples and pss sequence From a08e120c1c73a27b98be06459cb527611497da35 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 3 Apr 2019 17:16:54 +0200 Subject: [PATCH 11/23] Removing an unwanted printf --- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 626ba15022..6875fdeab9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -841,7 +841,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain AssertFatal(length>0,"illegal length %d\n",length); for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i); - printf("%d\n\n",length); peak_value = 0; peak_position = 0; pss_source = 0; From e0986d2de3df653198fb6d2bdb6660019631b1b9 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 4 Apr 2019 18:01:13 +0200 Subject: [PATCH 12/23] removing my trashed frames --- openair1/PHY/defs_nr_UE.h | 2 -- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 9 +++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 53c21c726e..9270a96d95 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -913,8 +913,6 @@ typedef struct { NR_DL_FRAME_PARMS frame_parms_before_ho; NR_UE_COMMON common_vars; - int16_t trashed_frames; - nr_ue_if_module_t *if_inst; nr_downlink_indication_t dl_indication; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2638b2481b..2821c61a7f 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2835,7 +2835,6 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * if (ret==0) { - ue->trashed_frames = 0; ue->pbch_vars[eNB_id]->pdu_errors_conseq = 0; @@ -4314,7 +4313,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; uint16_t nb_symb_sch = 9; // to be updated by higher layer uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; - uint8_t ssb_periodicity = ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now + uint8_t ssb_periodicity = 10; //ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now uint8_t ssb_frame_periodicity; uint8_t dci_cnt = 0; @@ -4465,12 +4464,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ssb_frame_periodicity = ssb_periodicity/10 ; // 10ms is the frame length - frame_rx += ue->trashed_frames; int ssb_slot = (pbch_config.ssb_index)/2; - - // looking for pbch only in frames according to ssb periodicity - if ((ue->decode_MIB == 1) && (nr_tti_rx == ssb_slot) )//&& !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) + // looking for pbch only in frames according to ssb periodicity and in slot where decoded ssb is found + if ((ue->decode_MIB == 1) && (nr_tti_rx == ssb_slot) && !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) { LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); From 2feed73050d8a00252fac399b9c2739ba6f7dfb6 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 4 Apr 2019 18:36:31 +0200 Subject: [PATCH 13/23] fixing counter of trashed frames for two frames synchronization --- executables/nr-ue.c | 4 ++++ openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 5 ++++- openair1/PHY/defs_nr_UE.h | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index bca68ed37d..c8ed8d45cf 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -592,6 +592,10 @@ void *UE_thread(void *arg) { // and we shifted above to the first slot of next frame // the synch thread proc context is hard linked to regular processing thread context, thread id = 0 UE_nr_rxtx_proc_t *proc=&(((processingData_t *)NotifiedFifoData(processingMsg[0]))->proc); + // synchronization is on two frame basis + // if it succeeds on the first frame the second one needs to be considered as trashed + if(!UE->is_synchronized_on_frame) + trashed_frames++; // shift the frame index with all the frames we trashed meanwhile we perform the synch search proc->decoded_frame_rx=(proc->decoded_frame_rx + trashed_frames) % MAX_FRAME_NUMBER; decoded_frame_rx=proc->decoded_frame_rx; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 78dbe83b80..4ba7c67339 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -208,6 +208,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) int32_t metric_tdd_ncp=0; uint8_t phase_tdd_ncp; double im, re; + int is; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; int ret=-1; @@ -242,7 +243,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) cnt =0; // initial sync performed on two successive frames, if pbch passes on first frame, no need to process second frame - for(int is=0; is<2;is++) { + for(is=0; is<2;is++) { /* process pss search on received buffer */ sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE); @@ -372,6 +373,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) #endif //#endif + ue->is_synchronized_on_frame = is; // to notify on which of the two frames sync was successful + if (ue->UE_scan_carrier == 0) { #if UE_AUTOTEST_TRACE diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 9270a96d95..213ce98924 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -878,8 +878,10 @@ typedef struct { int UE_scan_carrier; /// \brief Indicator that UE should enable estimation and compensation of frequency offset int UE_fo_compensation; - /// \brief Indicator that UE is synchronized to an eNB + /// \brief Indicator that UE is synchronized to a gNB int is_synchronized; + /// \brief Indicates on which frame is synchronized in a two frame synchronization + int is_synchronized_on_frame; /// Data structure for UE process scheduling UE_nr_proc_t proc; /// Flag to indicate the UE shouldn't do timing correction at all From 91121c6bd31ae6e9a141e9fdc5d37a6567a797a4 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 5 Apr 2019 11:57:20 +0200 Subject: [PATCH 14/23] default ssb periodicity 5ms and function to compute if ssb is in slot --- openair1/PHY/INIT/nr_init_ue.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 32 ++++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 226e89e489..af3c548686 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -912,7 +912,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ue->decode_MIB = 1; ue->decode_SIB = 1; - ue->ssb_periodicity = 20; // initialization of ssb periodicity + ue->ssb_periodicity = 5; // initialization of ssb periodicity to 5ms according to TS38.213 section 4.1 init_prach_tables(839); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2821c61a7f..01bd952e81 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4299,6 +4299,26 @@ void *UE_thread_slot1_dl_processing(void *arg) { #endif +int is_pbch_in_slot(fapi_nr_pbch_config_t pbch_config, int frame, int slot, int periodicity, uint16_t slots_per_frame) { + + int ssb_slot_decoded = (pbch_config.ssb_index)/2; + + if (periodicity == 5) { + // check for pbch in corresponding slot each half frame + if (pbch_config.half_frame_bit) + return(slot == ssb_slot_decoded || slot == ssb_slot_decoded - slots_per_frame/2); + else + return(slot == ssb_slot_decoded || slot == ssb_slot_decoded + slots_per_frame/2); + } + else { + // if the current frame is supposed to contain ssb + if (!((frame-(pbch_config.system_frame_number))%(periodicity/10))) + return(slot == ssb_slot_decoded); + else + return 0; + } +} + int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, uint8_t do_pdcch_flag,runmode_t mode, @@ -4310,11 +4330,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN int pilot1; int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; + int slot_pbch; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; uint16_t nb_symb_sch = 9; // to be updated by higher layer uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; - uint8_t ssb_periodicity = 10; //ue->ssb_periodicity; // initialized to 20ms in nr_init_ue and never changed for now - uint8_t ssb_frame_periodicity; + uint8_t ssb_periodicity = 10;// ue->ssb_periodicity; // initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE) uint8_t dci_cnt = 0; LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx); @@ -4462,12 +4482,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); } - ssb_frame_periodicity = ssb_periodicity/10 ; // 10ms is the frame length + slot_pbch = is_pbch_in_slot(pbch_config, frame_rx, nr_tti_rx, ssb_periodicity, ue->frame_parms.slots_per_frame); - int ssb_slot = (pbch_config.ssb_index)/2; - - // looking for pbch only in frames according to ssb periodicity and in slot where decoded ssb is found - if ((ue->decode_MIB == 1) && (nr_tti_rx == ssb_slot) && !((frame_rx-(pbch_config.system_frame_number))%ssb_frame_periodicity)) + // looking for pbch only in slot where it is supposed to be + if ((ue->decode_MIB == 1) && slot_pbch) { LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); From 43a98185db2e920e0733bffa37b2ec48c7cde48b Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 5 Apr 2019 18:02:26 +0200 Subject: [PATCH 15/23] fix on pbchsim for -I but still not working without initial sync --- executables/nr-ue.c | 2 +- openair1/PHY/MODULATION/slot_fep_nr.c | 2 -- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 6 ++--- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 4 +++- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 23 ++++++++----------- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index c8ed8d45cf..56a6aa68a4 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -239,7 +239,7 @@ static void UE_synch(void *arg) { case pbch: LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); - if (nr_initial_sync( syncD->proc, UE, UE->mode ) == 0) { + if (nr_initial_sync( syncD->proc, UE, UE->mode,2) == 0) { freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_slot; LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n", diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 86ca29d902..0c17b5d964 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -133,8 +133,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, return(-1); } - - for (aa=0; aanb_antennas_rx; aa++) { memset(&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int)); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 4ba7c67339..94dffb07fa 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -201,7 +201,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini char duplex_string[2][4] = {"FDD","TDD"}; char prefix_string[2][9] = {"NORMAL","EXTENDED"}; -int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) +int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, int n_frames) { int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2, @@ -243,7 +243,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) cnt =0; // initial sync performed on two successive frames, if pbch passes on first frame, no need to process second frame - for(is=0; is<2;is++) { + // only one frame is used for symulation tools + for(is=0; isssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples; - #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id); LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); 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 6290a700c5..408331c137 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1435,7 +1435,9 @@ void generate_RIV_tables(void); @param mode current running mode */ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *phy_vars_ue, runmode_t mode); + PHY_VARS_NR_UE *phy_vars_ue, + runmode_t mode, + int n_frames); /*! diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index ae8d3062ad..424ac6db7a 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -685,7 +685,7 @@ int main(int argc, char **argv) } if (UE->is_synchronized == 0) { UE_nr_rxtx_proc_t proc={0}; - ret = nr_initial_sync(&proc, UE, normal_txrx); + ret = nr_initial_sync(&proc, UE, normal_txrx,1); printf("nr_initial_sync1 returns %d\n",ret); if (ret<0) n_errors++; } diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 36a913f939..b50b2d4cb0 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -478,8 +478,7 @@ int main(int argc, char **argv) if(eps!=0.0) UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation - if (init_nr_ue_signal(UE, 1, 0) != 0) - { + if (init_nr_ue_signal(UE, 1, 0) != 0) { printf("Error at UE NR initialisation\n"); exit(-1); } @@ -588,39 +587,37 @@ int main(int argc, char **argv) for (i=0; inb_antennas_rx; aa++) { - ((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); - ((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); + ((short*) UE->common_vars.rxdata_is[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); + ((short*) UE->common_vars.rxdata_is[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); } } if (n_trials==1) { - LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0],frame_parms->samples_per_frame,1,1); + LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata_is[0],frame_parms->samples_per_frame,1,1); if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1],frame_parms->samples_per_frame,1,1); + LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata_is[1],frame_parms->samples_per_frame,1,1); } if (UE->is_synchronized == 0) { UE_nr_rxtx_proc_t proc={0}; - ret = nr_initial_sync(&proc, UE, normal_txrx); + ret = nr_initial_sync(&proc, UE, normal_txrx,1); printf("nr_initial_sync1 returns %d\n",ret); if (ret<0) n_errors++; } else { UE->rx_offset=0; - uint8_t ssb_index = 0; while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb - UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf); + int ssb_slot = (ssb_index/2)+(n_hf*frame_parms->slots_per_frame); for (int i=UE->symbol_offset+1; isymbol_offset+4; i++) { nr_slot_fep(UE, - i, - 0, + i%frame_parms->symbols_per_slot, + ssb_slot, 0, 0, NR_PBCH_EST); - - nr_pbch_channel_estimation(UE,0,0,i,i-(UE->symbol_offset+1),ssb_index%8,n_hf); + nr_pbch_channel_estimation(UE,0,ssb_slot,i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf); } UE_nr_rxtx_proc_t proc={0}; From f5d6aa4ca6ce737f4d28e0ccea7940e31765fa14 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 5 Apr 2019 18:18:49 +0200 Subject: [PATCH 16/23] fix on pbchsim without -I --- openair1/PHY/MODULATION/slot_fep_nr.c | 1 - openair1/SIMULATION/NR_PHY/pbchsim.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 0c17b5d964..e4e4d185f3 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -173,7 +173,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, } else { rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol; // + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); - if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) memcpy((void *) &(rxdata[aa][frame_length_samples]), (void *) &(rxdata[aa][0]), diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index b50b2d4cb0..72ab7e93f3 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -605,6 +605,7 @@ int main(int argc, char **argv) if (ret<0) n_errors++; } else { + UE->common_vars.rxdata = UE->common_vars.rxdata_is; UE->rx_offset=0; uint8_t ssb_index = 0; while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb From 09cca53829e0a8cb7c3d332101b481706c766e0b Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 8 Apr 2019 17:17:48 +0200 Subject: [PATCH 17/23] using only one structure for rxdata --- executables/nr-ue.c | 2 +- openair1/PHY/INIT/nr_init_ue.c | 4 +--- openair1/PHY/MODULATION/slot_fep_nr.c | 19 ++++++++----------- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 14 +++++++------- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 8 ++++---- openair1/PHY/defs_nr_UE.h | 7 +------ openair1/SIMULATION/NR_PHY/pbchsim.c | 9 ++++----- 7 files changed, 26 insertions(+), 37 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 56a6aa68a4..dad6a6147f 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -442,7 +442,7 @@ void readFrames(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { for(int x=0; x<20; x++) { // two frames for initial sync for (int i=0; iframe_parms.nb_antennas_rx; i++) - rxp[i] = ((void *)&UE->common_vars.rxdata_is[i][0]) + 4*x*UE->frame_parms.samples_per_subframe; + rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) + 4*x*UE->frame_parms.samples_per_subframe; AssertFatal( UE->frame_parms.samples_per_subframe == UE->rfdevice.trx_read_func(&UE->rfdevice, diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index af3c548686..1846b06b47 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -710,15 +710,13 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, } // init RX buffers - common_vars->rxdata_is= (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); for (th_id=0; th_idcommon_vars_rx_data_per_thread[th_id].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); } for (i=0; inb_antennas_rx; i++) { - common_vars->rxdata_is[i] = (int32_t*) malloc16_clear( (fp->samples_per_frame*2+2048)*sizeof(int32_t) ); - common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_frame+2048)*sizeof(int32_t) ); + common_vars->rxdata[i] = (int32_t*) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) ); for (th_id=0; th_idcommon_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index e4e4d185f3..f096499580 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -46,14 +46,11 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, unsigned char aa; unsigned int nb_prefix_samples; unsigned int nb_prefix_samples0; - int **rxdata = NULL; if (ue->is_synchronized) { - rxdata = common_vars->rxdata; nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); } else { - rxdata = common_vars->rxdata_is; nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples); } @@ -149,13 +146,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, if (symbol==0) { if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) - memcpy((short*) &(rxdata[aa][frame_length_samples]), - (short*) &(rxdata[aa][0]), + memcpy((short*) &common_vars->rxdata[aa][frame_length_samples], + (short*) &common_vars->rxdata[aa][0], frame_parms->ofdm_symbol_size*sizeof(int)); if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs memcpy((void *)tmp_dft_in, - (void *) &(rxdata[aa][rx_offset % frame_length_samples]), + (void *) &common_vars->rxdata[aa][rx_offset % frame_length_samples], frame_parms->ofdm_symbol_size*sizeof(int)); dft((int16_t *)tmp_dft_in, (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); @@ -164,7 +161,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, start_meas(&ue->rx_dft_stats); #endif - dft((int16_t *) &(rxdata[aa][(rx_offset) % frame_length_samples]), + dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); #if UE_TIMING_TRACE stop_meas(&ue->rx_dft_stats); @@ -174,8 +171,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol; // + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) - memcpy((void *) &(rxdata[aa][frame_length_samples]), - (void *) &(rxdata[aa][0]), + memcpy((void *) &common_vars->rxdata[aa][frame_length_samples], + (void *) &common_vars->rxdata[aa][0], frame_parms->ofdm_symbol_size*sizeof(int)); #if UE_TIMING_TRACE start_meas(&ue->rx_dft_stats); @@ -183,13 +180,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, if ((rx_offset&7)!=0) { // if input to dft is not 128-bit aligned, issue for size 6 and 15 PRBs memcpy((void *)tmp_dft_in, - (void *) &(rxdata[aa][(rx_offset) % frame_length_samples]), + (void *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], frame_parms->ofdm_symbol_size*sizeof(int)); dft((int16_t *)tmp_dft_in, (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); } else { // use dft input from RX buffer directly - dft((int16_t *) &(rxdata[aa][(rx_offset) % frame_length_samples]), + dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); } #if UE_TIMING_TRACE diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 94dffb07fa..860f36ab3c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -269,10 +269,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, for(int n=start; nnb_antennas_rx; ar++) { - re = ((double)(((short *)ue->common_vars.rxdata_is[ar]))[2*n]); - im = ((double)(((short *)ue->common_vars.rxdata_is[ar]))[2*n+1]); - ((short *)ue->common_vars.rxdata_is[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); - ((short *)ue->common_vars.rxdata_is[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); + re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]); + im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]); + ((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); + ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); } } } @@ -286,7 +286,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, /* symbol number are from beginning of SS/PBCH blocks as below: */ /* Signal PSS PBCH SSS PBCH */ /* symbol number 0 1 2 3 */ - /* time samples in buffer rxdata_is are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ + /* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */ for(int i=0; i<4;i++) @@ -436,13 +436,13 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, // do a measurement on the best guess of the PSS //for (aarx=0; aarxnb_antennas_rx; aarx++) - // rx_power += signal_energy(&ue->common_vars.rxdata_is[aarx][sync_pos2], + // rx_power += signal_energy(&ue->common_vars.rxdata[aarx][sync_pos2], // frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples); /* // do a measurement on the full frame for (aarx=0; aarxnb_antennas_rx; aarx++) - rx_power += signal_energy(&ue->common_vars.rxdata_is[aarx][0], + rx_power += signal_energy(&ue->common_vars.rxdata[aarx][0], frame_parms->samples_per_subframe*10); */ diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 990d89a545..a880959864 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -626,11 +626,11 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **r /* build with cic filter does not work properly. Performances are significantly deteriorated */ #ifdef CIC_DECIMATOR - cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata_is[0][0]), (int16_t *)&(rxdata[0][0]), + cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]), samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE); #else - fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata_is[0][0]), (int16_t *)&(rxdata[0][0]), + fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]), samples_for_frame, rate_change, 0); #endif @@ -667,7 +667,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) #ifdef DBG_PSS_NR - LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata_is[0][0], frame_parms->samples_per_frame, 1, 1); + LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], frame_parms->samples_per_frame, 1, 1); #endif @@ -686,7 +686,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) } else { - rxdata = PHY_vars_UE->common_vars.rxdata_is; + rxdata = PHY_vars_UE->common_vars.rxdata; } #ifdef DBG_PSS_NR diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 213ce98924..b47e288607 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -303,14 +303,9 @@ typedef struct { /// \brief Holds the received data in time domain. /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[ + /// - second index: sample [0..2*FRAME_LENGTH_COMPLEX_SAMPLES+2048[ int32_t **rxdata; - /// \brief Holds the received data in time domain for initial sync. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: sample [0..2*FRAME_LENGTH_COMPLEX_SAMPLES+...[ - int32_t **rxdata_is; - NR_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX]; /// holds output of the sync correlator diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 72ab7e93f3..54687d6b68 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -587,15 +587,15 @@ int main(int argc, char **argv) for (i=0; inb_antennas_rx; aa++) { - ((short*) UE->common_vars.rxdata_is[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); - ((short*) UE->common_vars.rxdata_is[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); + ((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); + ((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); } } if (n_trials==1) { - LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata_is[0],frame_parms->samples_per_frame,1,1); + LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0],frame_parms->samples_per_frame,1,1); if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata_is[1],frame_parms->samples_per_frame,1,1); + LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1],frame_parms->samples_per_frame,1,1); } if (UE->is_synchronized == 0) { @@ -605,7 +605,6 @@ int main(int argc, char **argv) if (ret<0) n_errors++; } else { - UE->common_vars.rxdata = UE->common_vars.rxdata_is; UE->rx_offset=0; uint8_t ssb_index = 0; while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb From ca4627836fb7135598e1987d01c46d35c9738ff9 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 15 Apr 2019 15:46:37 +0200 Subject: [PATCH 18/23] fixing compilation error --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 4152ef9322..b56573f2b3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -460,7 +460,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, for (symbol=1; symbol<4; symbol++) { nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF, - nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_id], + nr_ue_pbch_vars->dl_ch_estimates, nr_ue_pbch_vars->rxdataF_ext, nr_ue_pbch_vars->dl_ch_estimates_ext, symbol, From f6fbd72cae93eae616eab89aa8d6243b91fb2639 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 17 Apr 2019 12:15:27 +0200 Subject: [PATCH 19/23] initialization of nr_tti_rx in initial sync --- executables/nr-ue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e7150463fe..54a9dfdd96 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -164,10 +164,12 @@ static void UE_synch(void *arg) { syncData_t *syncD=(syncData_t *) arg; int i, hw_slot_offset; PHY_VARS_NR_UE *UE = syncD->UE; + UE_nr_rxtx_proc_t *proc = syncD->proc; sync_mode_t sync_mode = pbch; int CC_id = UE->CC_id; int freq_offset=0; UE->is_synchronized = 0; + proc->nr_tti_rx = 0; if (UE->UE_scan == 0) { get_band(downlink_frequency[CC_id][0], &UE->frame_parms.eutra_band, &uplink_frequency_offset[CC_id][0], &UE->frame_parms.frame_type); From c254ce07a06b323fc6921b9c19a26025a6bb5da9 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 14 May 2019 14:39:39 +0200 Subject: [PATCH 20/23] a unnotified conflict resolved --- openair2/LAYER2/NR_MAC_gNB/config.c | 3 +-- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 417caabf17..81e59a7dd2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -85,8 +85,7 @@ void config_common(int Mod_idP, uint64_t ssb_pattern, uint16_t ssb_periodicity, uint64_t dl_CarrierFreqP, - uint32_t dl_BandwidthP - ){ + uint32_t dl_BandwidthP){ nfapi_nr_config_request_t *cfg = &RC.nrmac[Mod_idP]->config[CC_idP]; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 32e3f6a6d0..4f5e3b5938 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,9 +38,10 @@ void mac_top_init_gNB(void); void config_common(int Mod_idP, int CC_idP, - int Nid_cell, + int Nid_cell, int nr_bandP, - uint64_t ssb_pattern, + uint64_t ssb_pattern, + uint16_t ssb_periodicity, uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP); From f1539df7f176ebd24cd59d6fb7401e856ae64a62 Mon Sep 17 00:00:00 2001 From: laurent Date: Sat, 18 May 2019 14:31:41 +0200 Subject: [PATCH 21/23] fix UE switch from read only to R+W --- targets/ARCH/rfsimulator/simulator.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 099e1c190a..e1ca17a5a1 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -3,6 +3,12 @@ copyleft: OpenAirInterface Software Alliance and it's licence */ +/* + * Open issues and limitations + * The read and write should be called in the same thread, that is not new USRP UHD design + * When the opposite side switch from passive reading to active R+Write, the synchro is not fully deterministic + */ + #include #include #include @@ -111,7 +117,7 @@ void setblocking(int sock, enum blocking_t active) { AssertFatal(fcntl(sock, F_SETFL, opts) >= 0, ""); } -static bool flushInput(rfsimulator_state_t *t); +static bool flushInput(rfsimulator_state_t *t, int timeout); void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) { if (t->saveIQfile != -1) { @@ -134,7 +140,9 @@ void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) { continue; if(errno==EAGAIN) { - flushInput(t); + // The opposite side is saturated + // we read incoming sockets meawhile waiting + flushInput(t, 5); continue; } else return; @@ -229,14 +237,17 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi lastW=timestamp; LOG_D(HW,"sent %d samples at time: %ld->%ld, energy in first antenna: %d\n", nsamps, timestamp, timestamp+nsamps, signal_energy(samplesVoid[0], nsamps) ); + // Let's verify we don't have incoming data + // This is mandatory when the opposite side don't transmit + flushInput(t, 0); return nsamps; } -static bool flushInput(rfsimulator_state_t *t) { +static bool flushInput(rfsimulator_state_t *t, int timeout) { // Process all incoming events on sockets // store the data in lists struct epoll_event events[FD_SETSIZE]= {0}; - int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, 20); + int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, timeout); if ( nfds==-1 ) { if ( errno==EINTR || errno==EAGAIN ) @@ -356,7 +367,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo if ( first_sock == FD_SETSIZE ) { // no connected device (we are eNB, no UE is connected) - if (!flushInput(t)) { + if (!flushInput(t, 10)) { for (int x=0; x < nbAnt; x++) memset(samplesVoid[x],0,sampleToByte(nsamps,1)); @@ -385,7 +396,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ptr->lastReceivedTS, t->nextTimestamp+nsamps); */ - flushInput(t); + flushInput(t, 3); } while (have_to_wait); } From cc239de2c79168832708d83252cfb1c0f2881bc7 Mon Sep 17 00:00:00 2001 From: laurent Date: Sat, 18 May 2019 15:03:23 +0200 Subject: [PATCH 22/23] fix UE switch from read only to R+W --- executables/nr-uesoftmodem.c | 2 +- executables/nr-uesoftmodem.h | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 2 +- targets/ARCH/rfsimulator/simulator.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 8300f10675..c8143879b1 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -393,7 +393,7 @@ static void get_options(void) { uint32_t online_log_messages; uint32_t glog_level, glog_verbosity; uint32_t start_telnetsrv=0; - paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; + paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC_UE ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 078a8066c3..4d45e08722 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -150,7 +150,7 @@ /* command line parameters common to eNodeB and UE */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -#define CMDLINE_PARAMS_DESC { \ +#define CMDLINE_PARAMS_DESC_UE { \ {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 92409d96dc..c7b500007d 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -1181,7 +1181,7 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) ctxt_pP->subframe, ctxt_pP->module_id); - for (dst_id = 0; dst_id Date: Tue, 21 May 2019 15:07:26 +0200 Subject: [PATCH 23/23] make dlsim compile again --- openair1/SIMULATION/NR_PHY/dlsim.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 7af35f760d..f1991dfc35 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -113,7 +113,8 @@ void config_common(int Mod_idP, int CC_idP, int Nid_cell, int nr_bandP, - uint64_t ssb_pattern, + uint64_t SSB_positions, + uint16_t ssb_periodicity, uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP ); @@ -166,7 +167,7 @@ int main(int argc, char **argv) //int pbch_tx_ant; int N_RB_DL=273,mu=1; - uint64_t ssb_pattern = 0x01; + uint16_t ssb_periodicity = 10; //unsigned char frame_type = 0; unsigned char pbch_phase = 0; @@ -520,7 +521,7 @@ int main(int argc, char **argv) mac_top_init_gNB(); gNB_mac = RC.nrmac[0]; - config_common(0,0,Nid_cell,78,ssb_pattern,(uint64_t)3640000000L,N_RB_DL); + config_common(0,0,Nid_cell,78,SSB_positions,ssb_periodicity,(uint64_t)3640000000L,N_RB_DL); config_nr_mib(0,0,1,kHz30,0,0,0,0,0); nr_l2_init_ue(); @@ -681,6 +682,10 @@ int main(int argc, char **argv) UE_mac->scheduled_response.frame = frame; UE_mac->scheduled_response.slot = slot; + UE_mac->phy_config.config_req.pbch_config.system_frame_number = frame; + UE_mac->phy_config.config_req.pbch_config.ssb_index = 0; + UE_mac->phy_config.config_req.pbch_config.half_frame_bit = 0; + for (SNR=snr0; SNRphy_config.config_req.pbch_config); if (n_trials==1) { LOG_M("rxsigF0.m","rxsF0", UE->common_vars.common_vars_rx_data_per_thread[0].rxdataF[0],slot_length_complex_samples_no_prefix,1,1);