From 102ec93096e11186de176636449eebe3a4058369 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 11 Feb 2019 18:45:28 +0100 Subject: [PATCH 01/54] first implementation of multiple ssb at gnb --- openair1/PHY/INIT/nr_parms.c | 3 + openair1/PHY/NR_TRANSPORT/nr_pbch.c | 1 - openair1/PHY/NR_TRANSPORT/nr_pss.c | 1 - openair1/PHY/defs_nr_common.h | 5 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 90 ++++++++++++++++------- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index f37883b388..273bfbfe1a 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -46,7 +46,10 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->numerology_index = mu; fp->Ncp = Ncp; fp->N_RB_DL = N_RB_DL; + fp->L_ssb = 8; // TODO get the number of SSB value from higher layers (and config file finally) + fp->ssb_type = nr_ssb_type_B; // TODO get the type from higher layers (and config file finally) + switch(mu) { case NR_MU_0: //15kHz scs diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 2e2c99f106..3b81aae04e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -443,6 +443,5 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, k-=frame_parms->ofdm_symbol_size; } - return 0; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_pss.c b/openair1/PHY/NR_TRANSPORT/nr_pss.c index 29dbe4ec99..e0d7b6ae33 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pss.c @@ -59,7 +59,6 @@ int nr_generate_pss( int16_t *d_pss, /// Resource mapping a = amp; - // PSS occupies a predefined position (subcarriers 56-182, symbol 0) within the SSB block starting from k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 58a8833b18..8f6f22f6a4 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -303,11 +303,13 @@ typedef struct NR_DL_FRAME_PARMS { /// TDD configuration uint16_t tdd_uplink_nr[2*NR_MAX_SLOTS_PER_FRAME]; /* this is a bitmap of symbol of each slot given for 2 frames */ - //SSB related params + //SSB related params /// Start in Subcarrier index of the SSB block uint16_t ssb_start_subcarrier; /// SSB type nr_ssb_type_e ssb_type; + /// Number of SSB + uint8_t L_ssb; /// PBCH polar encoder params t_nrPolar_params pbch_polar_params; @@ -317,5 +319,4 @@ typedef struct NR_DL_FRAME_PARMS { } NR_DL_FRAME_PARMS; - #endif diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index a7f8ef6884..6827b082d1 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -76,28 +76,47 @@ int return_ssb_type(nfapi_config_request_t *cfg) }*/ + // First SSB starting symbol candidate is used and type B is chosen for 30kHz SCS -int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) +int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp, uint8_t i_ssb) { int mu = cfg->subframe_config.numerology_index_mu.value; int symbol = 0; + uint8_t n, n_temp; + nr_ssb_type_e type = fp->ssb_type; + int case_AC[2] = {2,8}; + int case_BD[4] = {4,8,16,20}; + int case_E[8] = {8, 12, 16, 20, 32, 36, 40, 44}; + switch(mu) { - case NR_MU_0: - symbol = 2; + case NR_MU_0: // case A + n = i_ssb >> 1; + symbol = case_AC[i_ssb % 2] + 14*n; break; - case NR_MU_1: // case B - symbol = 4; + case NR_MU_1: + if (type == 1){ // case B + n = i_ssb >> 2; + symbol = case_BD[i_ssb % 4] + 28*n; + } + if (type == 2){ // case C + n = i_ssb >> 1; + symbol = case_AC[i_ssb % 2] + 14*n; + } break; - case NR_MU_3: - symbol = 4; + case NR_MU_3: // case D + n_temp = i_ssb >> 2; + n = n_temp + (n_temp >> 2); + symbol = case_BD[i_ssb % 4] + 28*n; break; - case NR_MU_4: - symbol = 8; + case NR_MU_4: // case E + n_temp = i_ssb >> 3; + n = n_temp + (n_temp >> 2); + symbol = case_E[i_ssb % 8] + 56*n; break; default: @@ -122,33 +141,46 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { nfapi_nr_config_request_t *cfg = &gNB->gNB_config; int **txdataF = gNB->common_vars.txdataF; uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; - int ss_slot = (cfg->sch_config.half_frame_index.value)? 10 : 0; - uint8_t Lmax, ssb_index=0, n_hf=0; + // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be + uint8_t Lmax, ssb_index, n_hf; + int ssb_start_symbol, rel_slot; + + n_hf = cfg->sch_config.half_frame_index.value; + rel_slot = (n_hf)? (slot-10) : slot; + + Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; // max number of ssb + + if (fp->L_ssb > Lmax) + AssertFatal(0==1, "Invalid number of SSB larger than %d \n", Lmax); LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot); - int ssb_start_symbol = nr_get_ssb_start_symbol(cfg, fp); - nr_set_ssb_first_subcarrier(cfg, fp); - Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; - - - if (slot == ss_slot) + if(rel_slot<10 && rel_slot>=0) { - // Current implementation is based on SSB in first half frame, first candidate - LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); + for (int i=0; i<2; i++) // max two SSB per frame + { + ssb_index = i + 2*rel_slot; // computing the ssb_index + if (ssb_index < (fp->L_ssb)) // generating the ssb only if the current ssb index is lower than number of SSB configured + { + int ssb_start_symbol_abs = nr_get_ssb_start_symbol(cfg, fp, ssb_index); // computing the starting symbol for current ssb + ssb_start_symbol = ssb_start_symbol_abs % 14; // start symbol wrt 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_set_ssb_first_subcarrier(cfg, fp); + + LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); - if (!(frame&7)){ - LOG_D(PHY,"%d.%d : pbch_configured %d\n",frame,slot,gNB->pbch_configured); - if (gNB->pbch_configured != 1)return; - gNB->pbch_configured = 0; - } + 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 (!(frame&7)){ + LOG_D(PHY,"%d.%d : pbch_configured %d\n",frame,slot,gNB->pbch_configured); + if (gNB->pbch_configured != 1)return; + gNB->pbch_configured = 0; + } - nr_generate_pbch(&gNB->pbch, + nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); + + nr_generate_pbch(&gNB->pbch, gNB->nrPolar_params, pbch_pdu, gNB->nr_pbch_interleaver, @@ -157,6 +189,8 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { ssb_start_symbol, n_hf,Lmax,ssb_index, frame, cfg, fp); + } + } } } From 0a9ea26b9ec9926bb53d6a6c32acc0663eb512d0 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 12 Feb 2019 10:28:57 +0100 Subject: [PATCH 02/54] bit-wise choice of SSB to transmit --- openair1/PHY/INIT/nr_parms.c | 2 +- openair1/PHY/defs_nr_common.h | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 273bfbfe1a..b8aa48c10b 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -46,7 +46,7 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->numerology_index = mu; fp->Ncp = Ncp; fp->N_RB_DL = N_RB_DL; - fp->L_ssb = 8; // TODO get the number of SSB value from higher layers (and config file finally) + fp->L_ssb = 255; // TODO get the number of SSB value from higher layers (and config file finally) fp->ssb_type = nr_ssb_type_B; // TODO get the type from higher layers (and config file finally) diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 8f6f22f6a4..0d491b887d 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -309,7 +309,7 @@ typedef struct NR_DL_FRAME_PARMS { /// SSB type nr_ssb_type_e ssb_type; /// Number of SSB - uint8_t L_ssb; + uint64_t L_ssb; /// PBCH polar encoder params t_nrPolar_params pbch_polar_params; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 6827b082d1..e89c0480d0 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -150,9 +150,6 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; // max number of ssb - if (fp->L_ssb > Lmax) - AssertFatal(0==1, "Invalid number of SSB larger than %d \n", Lmax); - LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot); if(rel_slot<10 && rel_slot>=0) @@ -160,7 +157,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { for (int i=0; i<2; i++) // max two SSB per frame { ssb_index = i + 2*rel_slot; // computing the ssb_index - if (ssb_index < (fp->L_ssb)) // generating the ssb only if the current ssb index is lower than number of SSB configured + if ((fp->L_ssb >> ssb_index) & 0x01) // generating the ssb only if the bit of L_ssb at current ssb index is 1 { int ssb_start_symbol_abs = nr_get_ssb_start_symbol(cfg, fp, ssb_index); // computing the starting symbol for current ssb ssb_start_symbol = ssb_start_symbol_abs % 14; // start symbol wrt slot @@ -229,7 +226,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, num_dci = gNB->pdcch_vars.num_dci; num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti; - if (num_dci) { + /*if (num_dci) { LOG_I(PHY, "[gNB %d] Frame %d slot %d \ Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, slot, num_dci); @@ -248,7 +245,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, AMP, slot, *fp, *cfg); } } - } + }*/ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0); } From 0348ce15981309d494fa6167850002691ff93b22 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 12 Feb 2019 11:50:21 +0100 Subject: [PATCH 03/54] bug fix in nr gold for pbch --- openair1/PHY/NR_REFSIG/nr_gold.c | 2 +- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 968f7fa7a4..08e6022764 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -38,7 +38,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) for (n_hf = 0; n_hf < N_hf; n_hf++) { for (l = 0; l < Lmax ; l++) { i_ssb = l & (Lmax-1); - i_ssb2 = (i_ssb<<2) + n_hf; + i_ssb2 = i_ssb + (n_hf<<2); reset = 1; x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3); diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 3bb8745875..78b92959e1 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -37,7 +37,7 @@ void nr_gold_pbch(PHY_VARS_NR_UE* ue) for (l = 0; l < Lmax ; l++) { i_ssb = l & (Lmax-1); - i_ssb2 = (i_ssb<<2) + n_hf; + i_ssb2 = i_ssb + (n_hf<<2); x1 = 1 + (1<<31); x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index e89c0480d0..674021d99f 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -165,7 +165,6 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { nr_set_ssb_first_subcarrier(cfg, fp); LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); - nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); @@ -226,7 +225,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, num_dci = gNB->pdcch_vars.num_dci; num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti; - /*if (num_dci) { + if (num_dci) { LOG_I(PHY, "[gNB %d] Frame %d slot %d \ Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, slot, num_dci); @@ -245,7 +244,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, AMP, slot, *fp, *cfg); } } - }*/ + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0); } From 186269cd5d690556c7e4dcbac25b4715dec95616 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 12 Feb 2019 15:37:24 +0100 Subject: [PATCH 04/54] removed pbch_configured issue for frames multiple of 8 --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 674021d99f..bfa785095b 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -141,11 +141,11 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { nfapi_nr_config_request_t *cfg = &gNB->gNB_config; int **txdataF = gNB->common_vars.txdataF; uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; - // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be uint8_t Lmax, ssb_index, n_hf; int ssb_start_symbol, rel_slot; n_hf = cfg->sch_config.half_frame_index.value; + // 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; Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; // max number of ssb @@ -162,18 +162,12 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { int ssb_start_symbol_abs = nr_get_ssb_start_symbol(cfg, fp, ssb_index); // computing the starting symbol for current ssb ssb_start_symbol = ssb_start_symbol_abs % 14; // start symbol wrt slot - nr_set_ssb_first_subcarrier(cfg, fp); + nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); - if (!(frame&7)){ - LOG_D(PHY,"%d.%d : pbch_configured %d\n",frame,slot,gNB->pbch_configured); - if (gNB->pbch_configured != 1)return; - gNB->pbch_configured = 0; - } - nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_pbch(&gNB->pbch, From db1eb5d92118e9f98905669c429e83d37be38820 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 13 Feb 2019 17:49:16 +0100 Subject: [PATCH 05/54] CellID taken from config file --- openair2/LAYER2/NR_MAC_gNB/config.c | 5 +++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 + openair2/RRC/NR/rrc_gNB.c | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 30917fd543..9b2a61b39e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -184,6 +184,7 @@ void config_nr_mib(int Mod_idP, void config_common(int Mod_idP, int CC_idP, + int cellid, int nr_bandP, uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP @@ -193,6 +194,8 @@ void config_common(int Mod_idP, int mu = 1; + cfg->sch_config.physical_cell_id.value = cellid; + // FDD cfg->subframe_config.duplex_mode.value = 1; cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG; @@ -232,6 +235,7 @@ void config_common(int Mod_idP, int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_idP, + int cellid, int p_gNB, int nr_bandP, uint64_t dl_CarrierFreqP, @@ -261,6 +265,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if( servingcellconfigcommon != NULL ){ config_common(Mod_idP, CC_idP, + cellid, nr_bandP, 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 784496ff9e..94226f4f8e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,6 +38,7 @@ void mac_top_init_gNB(void); int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_id, + int cellid, int p_gNB, int nr_bandP, uint64_t dl_CarrierFreqP, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 10fc6b6a4e..bbf6e475e7 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -236,7 +236,7 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp_UL = configuration->UL_prefix_type[CC_id]; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq = configuration->downlink_frequency[CC_id]; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id]; - + ///MIB RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB = 0; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4); @@ -264,6 +264,7 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, 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], RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, From 5c2f57369d0032b6c5b5edf7cd77313ea05beafe Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 14 Feb 2019 16:29:35 +0100 Subject: [PATCH 06/54] Implementation of SS block pattern choice --- openair1/PHY/INIT/nr_parms.c | 18 +++++++++++++++--- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index b8aa48c10b..f67170a69d 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -47,20 +47,29 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->Ncp = Ncp; fp->N_RB_DL = N_RB_DL; fp->L_ssb = 255; // TODO get the number of SSB value from higher layers (and config file finally) - fp->ssb_type = nr_ssb_type_B; // TODO get the type from higher layers (and config file finally) - switch(mu) { case NR_MU_0: //15kHz scs fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_0]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_0]; + fp->ssb_type = nr_ssb_type_A; break; case NR_MU_1: //30kHz scs fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_1]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_1]; + // selection of SS block pattern according to TS 38101-1 Table 5.4.3.3-1 for SCS 30kHz + if (fp->eutra_band == 5 || fp->eutra_band == 66) + fp->ssb_type = nr_ssb_type_B; + else{ + if (fp->eutra_band == 41 || ( fp->eutra_band > 76 && fp->eutra_band < 80) ) + fp->ssb_type = nr_ssb_type_C; + else + AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->eutra_band, mu); + } + switch(N_RB_DL){ case 11: case 24: @@ -147,11 +156,13 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, case NR_MU_3: fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_3]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_3]; + fp->ssb_type = nr_ssb_type_D; break; case NR_MU_4: fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_4]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_4]; + fp->ssb_type = nr_ssb_type_E; break; default: @@ -184,7 +195,8 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, NR_DL_FRAME_PARMS *fp) { - + fp->eutra_band = config->nfapi_config.rf_bands.rf_band[0]; + fp->frame_type = !(config->subframe_config.duplex_mode.value); return nr_init_frame_parms0(fp, config->subframe_config.numerology_index_mu.value, config->subframe_config.dl_cyclic_prefix_type.value, 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 d62b06aaa5..f170d7ce87 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 @@ -26,10 +26,10 @@ gNBs = node_function = "3GPP_gNODEB"; node_timing = "synch_to_ext_device"; node_synch_ref = 0; - frame_type = "FDD"; + frame_type = "TDD"; DL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL"; - eutra_band = 22; + eutra_band = 78; downlink_frequency = 3510000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; From 688830e83ec60c646ed416666f217d89884c9da3 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 15 Feb 2019 17:01:58 +0100 Subject: [PATCH 07/54] SSB pattern now hardcoded in rrc, to be taken from config file in the next commit --- nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h | 8 ++++---- openair1/PHY/INIT/nr_init.c | 1 + openair1/PHY/INIT/nr_parms.c | 2 +- openair1/PHY/defs_nr_common.h | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 6 +++++- openair2/LAYER2/NR_MAC_gNB/config.c | 9 ++++++++- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 ++- openair2/RRC/NR/rrc_gNB.c | 3 ++- 8 files changed, 24 insertions(+), 10 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 4273186dcf..1747e4f71b 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -28,12 +28,12 @@ typedef struct { /*typedef struct { nfapi_tl_t tl; int64_t value; -} nfapi_int64_tlv_t; +} nfapi_int64_tlv_t;*/ typedef struct { nfapi_tl_t tl; uint64_t value; -} nfapi_uint64_tlv_t;*/ +} nfapi_uint64_tlv_t; // nFAPI enums typedef enum { @@ -175,8 +175,8 @@ typedef struct { nfapi_uint16_tlv_t physical_cell_id; nfapi_uint16_tlv_t half_frame_index; nfapi_uint16_tlv_t ssb_subcarrier_offset; - nfapi_uint16_tlv_t ssb_sib1_position_in_burst; - nfapi_uint16_tlv_t ssb_scg_position_in_burst; + nfapi_uint16_tlv_t ssb_sib1_position_in_burst; // in sib1 + nfapi_uint64_tlv_t ssb_scg_position_in_burst; // in servingcellconfigcommon nfapi_uint16_tlv_t ssb_periodicity; nfapi_uint16_tlv_t ss_pbch_block_power; nfapi_uint16_tlv_t n_ssb_crb; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 1866eac96d..7f52c80992 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -438,6 +438,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) gNB_config->sch_config.ssb_subcarrier_offset.value = phy_config->cfg->sch_config.ssb_subcarrier_offset.value;//0; 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; if (phy_config->cfg->subframe_config.duplex_mode.value == 0) { gNB_config->subframe_config.duplex_mode.value = TDD; diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index f67170a69d..a5eb2e659b 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -46,7 +46,6 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->numerology_index = mu; fp->Ncp = Ncp; fp->N_RB_DL = N_RB_DL; - fp->L_ssb = 255; // TODO get the number of SSB value from higher layers (and config file finally) switch(mu) { @@ -197,6 +196,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, fp->eutra_band = config->nfapi_config.rf_bands.rf_band[0]; fp->frame_type = !(config->subframe_config.duplex_mode.value); + fp->L_ssb = config->sch_config.ssb_scg_position_in_burst.value; return nr_init_frame_parms0(fp, config->subframe_config.numerology_index_mu.value, config->subframe_config.dl_cyclic_prefix_type.value, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 0d491b887d..4267b79144 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -308,7 +308,7 @@ typedef struct NR_DL_FRAME_PARMS { uint16_t ssb_start_subcarrier; /// SSB type nr_ssb_type_e ssb_type; - /// Number of SSB + /// SS block pattern (max 64 ssb, each bit is on/off ssb) uint64_t L_ssb; /// PBCH polar encoder params t_nrPolar_params pbch_polar_params; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 1d440c5d0d..b6125ce7b7 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -101,7 +101,9 @@ int rrc_init_nr_global_param(void){return(0);} void config_common(int Mod_idP, int CC_idP, + int Nid_cell, int nr_bandP, + uint64_t ssb_pattern, uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP ); @@ -151,6 +153,8 @@ int main(int argc, char **argv) int pbch_tx_ant; int N_RB_DL=273,mu=1; + uint64_t ssb_pattern = 0; + unsigned char frame_type = 0; unsigned char pbch_phase = 0; @@ -496,7 +500,7 @@ int main(int argc, char **argv) mac_top_init_gNB(); gNB_mac = RC.nrmac[0]; - config_common(0,0,78,(uint64_t)3640000000L,N_RB_DL); + config_common(0,0,Nid_cell,78,ssb_pattern,(uint64_t)3640000000L,N_RB_DL); config_nr_mib(0,0,1,kHz30,0,0,0,0); nr_l2_init_ue(); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 9b2a61b39e..b2ea58d362 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -186,7 +186,8 @@ void config_common(int Mod_idP, int CC_idP, int cellid, int nr_bandP, - uint64_t dl_CarrierFreqP, + uint64_t ssb_pattern, + uint64_t dl_CarrierFreqP, uint32_t dl_BandwidthP ){ @@ -195,6 +196,7 @@ void config_common(int Mod_idP, int mu = 1; cfg->sch_config.physical_cell_id.value = cellid; + cfg->sch_config.ssb_scg_position_in_burst.value = ssb_pattern; // FDD cfg->subframe_config.duplex_mode.value = 1; @@ -238,6 +240,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, int cellid, int p_gNB, int nr_bandP, + uint64_t ssb_pattern, uint64_t dl_CarrierFreqP, int dl_BandwidthP, NR_BCCH_BCH_Message_t *mib, @@ -262,11 +265,15 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, ); }// END if( mib != NULL ) + + + if( servingcellconfigcommon != NULL ){ config_common(Mod_idP, CC_idP, cellid, nr_bandP, + ssb_pattern, 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 94226f4f8e..6db3b9202b 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); 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, 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 bbf6e475e7..daf368f50d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -261,12 +261,13 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, LOG_I(NR_RRC,"Done init_NR_SI\n"); - + uint64_t ssb_pattern = 255; 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], + ssb_pattern, 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 15f07d2bb1e77febefcc0be7e7c669f128d6881b Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 21 Feb 2019 13:33:19 +0100 Subject: [PATCH 08/54] multiple SSB generation in pbchsim --- openair1/PHY/INIT/nr_init.c | 4 +-- openair1/PHY/INIT/phy_init.h | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 53 ++++++++++++++++------------ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 7f52c80992..84f8888eff 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -387,7 +387,7 @@ void install_schedule_handlers(IF_Module_t *if_inst) /// this function is a temporary addition for NR configuration -void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell) +void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst) { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; nfapi_nr_config_request_t *gNB_config = &gNB->gNB_config; @@ -404,7 +404,7 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu, gNB_config->sch_config.n_ssb_crb.value = (N_RB_DL-20); gNB_config->sch_config.ssb_subcarrier_offset.value = 0; gNB_config->sch_config.physical_cell_id.value=Nid_cell; - + gNB_config->sch_config.ssb_scg_position_in_burst.value=position_in_burst; gNB->mac_enabled = 1; diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 2a7dcf88fd..a454fb8e80 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -383,7 +383,7 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag); void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms); int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char abstraction_flag); void nr_phy_config_request(NR_PHY_Config_t *gNB); -void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell); +void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst); void phy_free_nr_gNB(PHY_VARS_gNB *gNB); int l1_north_init_gNB(void); void init_nr_transport(PHY_VARS_gNB *gNB); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 214a33fb73..c023a69671 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -105,6 +105,7 @@ int main(int argc, char **argv) int trial,n_trials=1,n_errors=0,n_errors_payload=0; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; + uint64_t SSB_positions=0x01; channel_desc_t *gNB2UE; @@ -280,6 +281,10 @@ int main(int argc, char **argv) break; + case 'M': + SSB_positions = atoi(optarg); + break; + case 'N': Nid_cell = atoi(optarg); break; @@ -333,6 +338,7 @@ int main(int argc, char **argv) printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-o Carrier frequency offset in Hz\n"); + printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -366,32 +372,34 @@ int main(int argc, char **argv) frame_parms->N_RB_UL = N_RB_DL; frame_parms->Nid_cell = Nid_cell; - nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell); + nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,0); double fs,bw,scs,eps; - - if (mu == 1 && N_RB_DL == 217) { - fs = 122.88e6; - bw = 80e6; - scs = 30000; - } - else if (mu == 1 && N_RB_DL == 245) { - fs = 122.88e6; - bw = 90e6; - scs = 30000; + + switch (mu) { + case 1: + scs = 30000; + if (N_RB_DL == 217) { + fs = 122.88e6; + bw = 80e6; + + } + else if (N_RB_DL == 245) { + fs = 122.88e6; + bw = 90e6; + } + else if (N_RB_DL == 273) { + fs = 122.88e6; + bw = 100e6; + } + else if (N_RB_DL == 106) { + fs = 61.44e6; + bw = 40e6; + } + else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); + break; } - else if (mu == 1 && N_RB_DL == 273) { - fs = 122.88e6; - bw = 100e6; - scs = 30000; - } - else if (mu == 1 && N_RB_DL == 106) { - fs = 61.44e6; - bw = 40e6; - scs = 30000; - } - else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); // cfo with respect to sub-carrier spacing eps = cfo/scs; @@ -476,6 +484,7 @@ int main(int argc, char **argv) if (input_fd==NULL) { gNB->pbch_configured = 1; for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1; + nr_common_signal_procedures (gNB,frame,subframe); LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); From a5025d4c4fbb930b923c322361e6e1897b15a638 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 21 Feb 2019 15:30:09 +0100 Subject: [PATCH 09/54] SSB positions in burst from config file --- openair2/COMMON/rrc_messages_types.h | 2 +- openair2/GNB_APP/gnb_config.c | 33 ++++++++++--------- openair2/GNB_APP/gnb_paramdef.h | 2 +- openair2/LAYER2/NR_MAC_gNB/config.c | 2 -- openair2/RRC/NR/MESSAGES/asn1_msg.c | 17 +++++++--- openair2/RRC/NR/rrc_gNB.c | 6 ++-- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 2 +- 7 files changed, 36 insertions(+), 28 deletions(-) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 922c949307..1c12f41150 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -361,7 +361,7 @@ typedef struct NRRrcConfigurationReq_s { lte_prefix_type_t UL_BWP_prefix_type[MAX_NUM_CCs]; long UL_timeAlignmentTimerCommon[MAX_NUM_CCs]; long ServingCellConfigCommon_n_TimingAdvanceOffset[MAX_NUM_CCs]; - long ServingCellConfigCommon_ssb_PositionsInBurst_PR[MAX_NUM_CCs]; + uint64_t ServingCellConfigCommon_ssb_PositionsInBurst_PR[MAX_NUM_CCs]; long ServingCellConfigCommon_ssb_periodicityServingCell[MAX_NUM_CCs]; //ServingCellConfigCommon long ServingCellConfigCommon_dmrs_TypeA_Position[MAX_NUM_CCs]; //ServingCellConfigCommon long NIA_SubcarrierSpacing[MAX_NUM_CCs]; //ServingCellConfigCommon Used only for non-initial access diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 4484cc18a8..99b6286483 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -103,7 +103,6 @@ void RCconfig_nr_flexran() *UL_frequencyShift7p5khz, *UL_SCS_SubcarrierSpacing, *UL_BWP_SubcarrierSpacing, *UL_BWP_prefix_type, *UL_timeAlignmentTimerCommon, *ServingCellConfigCommon_n_TimingAdvanceOffset, - *ServingCellConfigCommon_ssb_PositionsInBurst_PR, *NIA_SubcarrierSpacing, *referenceSubcarrierSpacing, *dl_UL_TransmissionPeriodicity, *rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice, *rach_groupBconfigured, *rach_messagePowerOffsetGroupB, @@ -118,7 +117,7 @@ void RCconfig_nr_flexran() *SearchSpace_searchSpaceType, *ue_Specific__dci_Formats, *RateMatchPatternLTE_CRS_subframeAllocation_choice; - uint64_t downlink_frequency; + uint64_t downlink_frequency, ServingCellConfigCommon_ssb_PositionsInBurst_PR; int32_t nr_band, uplink_frequency_offset, N_RB_DL, nb_antenna_ports, MIB_subCarrierSpacingCommon, MIB_ssb_SubcarrierOffset, MIB_dmrs_TypeA_Position, @@ -484,7 +483,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { char* UL_timeAlignmentTimerCommon = 0; char* ServingCellConfigCommon_n_TimingAdvanceOffset = 0; - char* ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0; + uint64_t ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0; int32_t ServingCellConfigCommon_ssb_periodicityServingCell = 0; int32_t ServingCellConfigCommon_dmrs_TypeA_Position = 0; char* NIA_SubcarrierSpacing = 0; @@ -1125,19 +1124,23 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { RC.config_file_name, i, ServingCellConfigCommon_n_TimingAdvanceOffset); } - if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"shortBitmap")==0) { - NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap; - }else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"mediumBitmap")==0) { - NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap; - }else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"longBitmap")==0) { - NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap; - }else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"NOTHING")==0) { - NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_NOTHING; - }else { - AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for ServingCellConfigCommon_ssb_PositionsInBurst_PR choice !\n", - RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR); - } + uint64_t t_freq; + if(nr_band == 41 || (nr_band > 76 && nr_band < 80)) + t_freq = 2400000000; + else + t_freq = 3000000000; + + if (downlink_frequency 15)) + AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n", + RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency); + else { + if(downlink_frequency<6000000000 && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 255)) + AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n", + RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency); + else + NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon_ssb_PositionsInBurst_PR; + } switch (ServingCellConfigCommon_ssb_periodicityServingCell) { case 5: diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index 15a2e97239..6ac5bfc42d 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -640,7 +640,7 @@ typedef enum { {GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE, NULL, 0, strptr:&UL_BWP_prefix_type, defstrval:"NORMAL", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_UL_TIMEALIGNMENTTIMERCOMMON, NULL, 0, strptr:&UL_timeAlignmentTimerCommon, defstrval:"infinity", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_N_TIMINGADVANCEOFFSET, NULL, 0, strptr:&ServingCellConfigCommon_n_TimingAdvanceOffset, defstrval:"n0", TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR, NULL, 0, strptr:&ServingCellConfigCommon_ssb_PositionsInBurst_PR, defstrval:"shortBitmap", TYPE_STRING, 0}, \ +{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR, NULL, 0, i64ptr:(int64_t *)&ServingCellConfigCommon_ssb_PositionsInBurst_PR, defint64val:0, TYPE_UINT64, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL, NULL, 0, iptr:&ServingCellConfigCommon_ssb_periodicityServingCell, defintval:10, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION, NULL, 0, iptr:&ServingCellConfigCommon_dmrs_TypeA_Position, defintval:0, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING, NULL, 0, strptr:&NIA_SubcarrierSpacing, defstrval:"kHz15", TYPE_STRING, 0}, \ diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index b2ea58d362..12d01981d2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -266,8 +266,6 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, }// END if( mib != NULL ) - - if( servingcellconfigcommon != NULL ){ config_common(Mod_idP, CC_idP, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index df45ae5e05..1b3e367ec7 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -747,15 +747,21 @@ void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id, //ssb_PositionsInBurst (*servingcellconfigcommon)->ssb_PositionsInBurst->present = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id]; - if((*servingcellconfigcommon)->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap){ + uint64_t t_freq; + if(configuration->nr_band[CC_id] == 41 || (configuration->nr_band[CC_id] > 76 && configuration->nr_band[CC_id] < 80)) + t_freq = 2400000000; + else + t_freq = 3000000000; + + if(configuration->downlink_frequency[CC_id]ssb_PositionsInBurst->choice.shortBitmap.size = 1; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.bits_unused = 4; - (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.buf[0] = 0x0f; - }else if((*servingcellconfigcommon)->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap){ + (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.buf[0] = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id]; + }else if(configuration->downlink_frequency[CC_id]<6000000000){ (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.size = 1; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.bits_unused = 0; - (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] = 0xff; - }else if((*servingcellconfigcommon)->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap){ + (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id]; + }else { (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.size = 8; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.bits_unused = 0; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[0] = 0xff; @@ -768,6 +774,7 @@ void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id, (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[7] = 0xff; } + //ssb_periodicityServingCell *(*servingcellconfigcommon)->ssb_periodicityServingCell = configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id]; //dmrs_TypeA_Position diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index daf368f50d..de9d8fb60d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -261,13 +261,13 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, LOG_I(NR_RRC,"Done init_NR_SI\n"); - uint64_t ssb_pattern = 255; + 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], - ssb_pattern, + configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[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, @@ -332,7 +332,7 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu gnb_mod_idP, RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[0], RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[1], RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[2], - RC.nrrrc[ctxt.module_id]->carrier[CC_id].cba_rnti[3], + RC.nrrrc[ctxt.module_id]->caNRRRC_CONFIGURATION_REQrrier[CC_id].cba_rnti[3], RC.nrrrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups); } 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 f170d7ce87..385064b667 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 @@ -70,7 +70,7 @@ gNBs = UL_BWP_prefix_type = "NORMAL"; UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" - ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0xff; ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; From 5a9fb475f2361ff0d3f8c181728deb1c2f07beae Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 21 Feb 2019 17:29:15 +0100 Subject: [PATCH 10/54] Lmax in frame_parms and nr_band number from freq at UE --- openair1/PHY/INIT/nr_parms.c | 10 +++ openair1/PHY/NR_REFSIG/nr_gold.c | 2 +- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 3 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 2 +- openair1/PHY/defs_nr_common.h | 2 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 5 +- targets/RT/USER/nr-ue.c | 75 +++++++++++++---------- targets/RT/USER/nr-uesoftmodem.c | 2 +- 8 files changed, 59 insertions(+), 42 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index a5eb2e659b..14d95ad488 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -179,6 +179,16 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2; + // definition of Lmax according to ts 38.213 section 4.1 + if (fp->dl_CarrierFreq < 6e9){ + if(fp->frame_type && (fp->ssb_type==2)) + fp->Lmax = (fp->dl_CarrierFreq < 2.4e9)? 4 : 8; + else + fp->Lmax = (fp->dl_CarrierFreq < 3e9)? 4 : 8; + } + else + fp->Lmax = 64; + // Initial bandwidth part configuration -- full carrier bandwidth fp->initial_bwp_dl.bwp_id = 0; fp->initial_bwp_dl.scs = fp->subcarrier_spacing; diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 08e6022764..bd60933155 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -32,7 +32,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) Nid = cfg->sch_config.physical_cell_id.value; - Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; + Lmax = fp->Lmax; N_hf = (Lmax == 4)? 2:1; for (n_hf = 0; n_hf < N_hf; n_hf++) { diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 78b92959e1..726aab8a37 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -29,8 +29,7 @@ void nr_gold_pbch(PHY_VARS_NR_UE* ue) unsigned char Lmax, l, n_hf, N_hf; Nid = ue->frame_parms.Nid_cell; - - Lmax = 8; //(fp->dl_CarrierFreq < 3e9)? 4:8; + Lmax = ue->frame_parms.Lmax; N_hf = (Lmax == 4)? 2:1; for (n_hf = 0; n_hf < N_hf; n_hf++) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index a0b150eda1..dc8fb09e2a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -531,7 +531,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; uint8_t nushift; uint16_t M; - uint8_t Lmax=8; //to update + uint8_t Lmax=frame_parms->Lmax; uint8_t ssb_index=0; //uint16_t crc; //unsigned short idx_demod =0; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 4267b79144..267c156184 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -308,6 +308,8 @@ typedef struct NR_DL_FRAME_PARMS { uint16_t ssb_start_subcarrier; /// SSB type nr_ssb_type_e ssb_type; + /// Max number of SSB in frame + uint8_t Lmax; /// SS block pattern (max 64 ssb, each bit is on/off ssb) uint64_t L_ssb; /// PBCH polar encoder params diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index bfa785095b..e64d2d8635 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -141,14 +141,13 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { nfapi_nr_config_request_t *cfg = &gNB->gNB_config; int **txdataF = gNB->common_vars.txdataF; uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; - uint8_t Lmax, ssb_index, n_hf; + uint8_t ssb_index, n_hf; int ssb_start_symbol, rel_slot; n_hf = cfg->sch_config.half_frame_index.value; // 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; - Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; // max number of ssb LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot); @@ -177,7 +176,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { txdataF[0], AMP, ssb_start_symbol, - n_hf,Lmax,ssb_index, + n_hf,fp->Lmax,ssb_index, frame, cfg, fp); } } diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 3f0545c4cf..5cd4db26d2 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -175,35 +175,38 @@ typedef struct band_info_s { band_info_t bands_to_scan; static const eutra_band_t eutra_bands[] = { - { 1, 1920 * MHz, 1980 * MHz, 2110 * MHz, 2170 * MHz, FDD}, - { 2, 1850 * MHz, 1910 * MHz, 1930 * MHz, 1990 * MHz, FDD}, - { 3, 1710 * MHz, 1785 * MHz, 1805 * MHz, 1880 * MHz, FDD}, - { 4, 1710 * MHz, 1755 * MHz, 2110 * MHz, 2155 * MHz, FDD}, - { 5, 824 * MHz, 849 * MHz, 869 * MHz, 894 * MHz, FDD}, - { 6, 830 * MHz, 840 * MHz, 875 * MHz, 885 * MHz, FDD}, - { 7, 2500 * MHz, 2570 * MHz, 2620 * MHz, 2690 * MHz, FDD}, - { 8, 880 * MHz, 915 * MHz, 925 * MHz, 960 * MHz, FDD}, - { 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD}, - {10, 1710 * MHz, 1770 * MHz, 2110 * MHz, 2170 * MHz, FDD}, - {11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD}, - {12, 698 * MHz, 716 * MHz, 728 * MHz, 746 * MHz, FDD}, - {13, 777 * MHz, 787 * MHz, 746 * MHz, 756 * MHz, FDD}, - {14, 788 * MHz, 798 * MHz, 758 * MHz, 768 * MHz, FDD}, - {17, 704 * MHz, 716 * MHz, 734 * MHz, 746 * MHz, FDD}, - {20, 832 * MHz, 862 * MHz, 791 * MHz, 821 * MHz, FDD}, - {22, 3510 * MHz, 3590 * MHz, 3410 * MHz, 3490 * MHz, FDD}, - {33, 1900 * MHz, 1920 * MHz, 1900 * MHz, 1920 * MHz, TDD}, - {34, 2010 * MHz, 2025 * MHz, 2010 * MHz, 2025 * MHz, TDD}, - {35, 1850 * MHz, 1910 * MHz, 1850 * MHz, 1910 * MHz, TDD}, - {36, 1930 * MHz, 1990 * MHz, 1930 * MHz, 1990 * MHz, TDD}, - {37, 1910 * MHz, 1930 * MHz, 1910 * MHz, 1930 * MHz, TDD}, - {38, 2570 * MHz, 2620 * MHz, 2570 * MHz, 2630 * MHz, TDD}, - {39, 1880 * MHz, 1920 * MHz, 1880 * MHz, 1920 * MHz, TDD}, - {40, 2300 * MHz, 2400 * MHz, 2300 * MHz, 2400 * MHz, TDD}, - {41, 2496 * MHz, 2690 * MHz, 2496 * MHz, 2690 * MHz, TDD}, - {42, 3400 * MHz, 3600 * MHz, 3400 * MHz, 3600 * MHz, TDD}, - {43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD}, - {44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD}, + {1, 1920000, 1980000, 2110000, 2170000, FDD}, + {2, 1850000, 1910000, 1930000, 1990000, FDD}, + {3, 1710000, 1785000, 1805000, 1880000, FDD}, + {5, 824000, 849000, 869000, 894000, FDD}, + {7, 2500000, 2570000, 2620000, 2690000, FDD}, + {8, 880000, 915000, 925000, 960000, FDD}, + {12, 698000, 716000, 728000, 746000, FDD}, + {20, 832000, 862000, 791000, 821000, FDD}, + {25, 1850000, 1915000, 1930000, 1995000, FDD}, + {28, 703000, 758000, 758000, 813000, FDD}, + {34, 2010000, 2025000, 2010000, 2025000, TDD}, + {38, 2570000, 2620000, 2570000, 2630000, TDD}, + {39, 1880000, 1920000, 1880000, 1920000, TDD}, + {40, 2300000, 2400000, 2300000, 2400000, TDD}, + {41, 2496000, 2690000, 2496000, 2690000, TDD}, + {50, 1432000, 1517000, 1432000, 1517000, TDD}, + {51, 1427000, 1432000, 1427000, 1432000, TDD}, + {66, 1710000, 1780000, 2110000, 2200000, FDD}, + {70, 1695000, 1710000, 1995000, 2020000, FDD}, + {71, 663000, 698000, 617000, 652000, FDD}, + {74, 1427000, 1470000, 1475000, 1518000, FDD}, + {75, 000, 000, 1432000, 1517000, FDD}, + {76, 000, 000, 1427000, 1432000, FDD}, + {77, 3300000, 4200000, 3300000, 4200000, TDD}, + {78, 3300000, 3800000, 3300000, 3800000, TDD}, + {79, 4400000, 5000000, 4400000, 5000000, TDD}, + {80, 1710000, 1785000, 000, 000, FDD}, + {81, 860000, 915000, 000, 000, FDD}, + {82, 832000, 862000, 000, 000, FDD}, + {83, 703000, 748000, 000, 000, FDD}, + {84, 1920000, 1980000, 000, 000, FDD}, + {86, 1710000, 1785000, 000, 000, FDD} }; PHY_VARS_NR_UE* init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, @@ -333,6 +336,7 @@ static void *UE_thread_synch(void *arg) { int i, hw_slot_offset; PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE*) arg; int current_band = 0; + lte_frame_type_t current_type; int current_offset = 0; sync_mode_t sync_mode = pbch; int CC_id = UE->CC_id; @@ -351,19 +355,22 @@ static void *UE_thread_synch(void *arg) { if (UE->UE_scan == 0) { int ind; - for ( ind=0; - ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]); - ind++) { + int64_t dl_freq_khz = downlink_frequency[0][0]/1000; + for ( ind=0; ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]); ind++) { current_band = eutra_bands[ind].band; + current_type = eutra_bands[ind].frame_type; LOG_D(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", current_band, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min); - if ( eutra_bands[ind].dl_min <= downlink_frequency[0][0] && eutra_bands[ind].dl_max >= downlink_frequency[0][0] ) { + if ( eutra_bands[ind].dl_min <= dl_freq_khz && eutra_bands[ind].dl_max >= dl_freq_khz ) { for (i=0; i<4; i++) - uplink_frequency_offset[CC_id][i] = eutra_bands[ind].ul_min - eutra_bands[ind].dl_min; + uplink_frequency_offset[CC_id][i] = (eutra_bands[ind].ul_min - eutra_bands[ind].dl_min) *1000; break; } } AssertFatal( ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]), "Can't find EUTRA band for frequency"); + UE->frame_parms.eutra_band = current_band; + UE->frame_parms.frame_type = current_type; + LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n", downlink_frequency[0][0], downlink_frequency[0][0]+uplink_frequency_offset[0][0], oai_exit, openair0_cfg[0].rx_num_channels); diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index d3d660e7f5..0321906b77 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -661,7 +661,7 @@ void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { config[CC_id]->rf_config.dl_carrier_bandwidth.value = 106; config[CC_id]->rf_config.ul_carrier_bandwidth.value = 106; config[CC_id]->sch_config.physical_cell_id.value = 0; - + frame_parms[CC_id]->eutra_band = 78; frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->tdd_config = 3; //frame_parms[CC_id]->tdd_config_S = 0; From 2156ba10d595a5cd935a4fce1ba9f51edcda2021 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 25 Feb 2019 16:51:41 +0100 Subject: [PATCH 11/54] config files changed and pdcch/pdsch enabled --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 ++-- .../CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf | 6 +++--- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 6 +++--- .../CONF/gnb.band78.tm1.217PRB.usrpn300.conf | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index f1db75d534..d922a3143d 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -213,7 +213,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, num_dci = gNB->pdcch_vars.num_dci; num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti; - /*if (num_dci) { + if (num_dci) { LOG_I(PHY, "[gNB %d] Frame %d slot %d \ Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, slot, num_dci); @@ -232,7 +232,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, AMP, slot, *fp, *cfg); } } - }*/ + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0); } 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 258d6c5f03..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 @@ -26,10 +26,10 @@ gNBs = node_function = "3GPP_gNODEB"; node_timing = "synch_to_ext_device"; node_synch_ref = 0; - frame_type = "FDD"; + frame_type = "TDD"; DL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL"; - eutra_band = 22; + eutra_band = 78; downlink_frequency = 3510000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; @@ -70,7 +70,7 @@ gNBs = UL_BWP_prefix_type = "NORMAL"; UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" - ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; 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 3aaf0c5506..077d1e5bd3 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 @@ -26,10 +26,10 @@ gNBs = node_function = "3GPP_gNODEB"; node_timing = "synch_to_ext_device"; node_synch_ref = 0; - frame_type = "FDD"; + frame_type = "TDD"; DL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL"; - eutra_band = 22; + eutra_band = 78; downlink_frequency = 3510000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; @@ -70,7 +70,7 @@ gNBs = UL_BWP_prefix_type = "NORMAL"; UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" - ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; 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 a604feabec..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 @@ -26,10 +26,10 @@ gNBs = node_function = "3GPP_gNODEB"; node_timing = "synch_to_ext_device"; node_synch_ref = 0; - frame_type = "FDD"; + frame_type = "TDD"; DL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL"; - eutra_band = 22; + eutra_band = 78; downlink_frequency = 3510000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; @@ -70,7 +70,7 @@ gNBs = UL_BWP_prefix_type = "NORMAL"; UL_timeAlignmentTimerCommon = "infinity"; ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" - ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_dmrs_TypeA_Position = 2; NIA_SubcarrierSpacing = "kHz15"; From 353f153353863b97fad69d3a0c59494ffac0f448 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 26 Feb 2019 18:06:43 +0100 Subject: [PATCH 12/54] slot_fep for ssb done once before sss and pbch channel estimation moved out of slot_fep --- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/MODULATION/modulation_UE.h | 3 +- openair1/PHY/MODULATION/slot_fep_nr.c | 49 ++--------------- .../nr_dl_channel_estimation.c | 8 +-- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 4 -- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 52 +++++++++---------- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 3 +- openair1/PHY/NR_UE_TRANSPORT/sss_nr.c | 18 ------- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 3 -- openair1/SIMULATION/NR_PHY/pbchsim.c | 40 +++++--------- targets/RT/USER/nr-ue.c | 2 +- 11 files changed, 48 insertions(+), 136 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 568070df93..2f613152dd 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -363,7 +363,7 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu, NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; nfapi_nr_config_request_t *gNB_config = &gNB->gNB_config; //overwrite for new NR parameters - gNB_config->nfapi_config.rf_bands.rf_band[0] = 78; + gNB_config->nfapi_config.rf_bands.rf_band[0] = 5; gNB_config->nfapi_config.nrarfcn.value = 620000; gNB_config->subframe_config.numerology_index_mu.value = mu; gNB_config->subframe_config.duplex_mode.value = TDD; diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h index 9734c02907..63c3637886 100644 --- a/openair1/PHY/MODULATION/modulation_UE.h +++ b/openair1/PHY/MODULATION/modulation_UE.h @@ -53,8 +53,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *phy_vars_ue, unsigned char Ns, int sample_offset, int no_prefix, - int reset_freq_est, - NR_CHANNEL_EST_t channel); + NR_CHANNEL_EST_t channel); int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, unsigned char l, diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 1e1751fe24..f41212e543 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -39,12 +39,10 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, unsigned char Ns, int sample_offset, int no_prefix, - int reset_freq_est, NR_CHANNEL_EST_t channel) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_UE_COMMON *common_vars = &ue->common_vars; - uint8_t eNB_id = 0;//ue_common_vars->eNb_id; unsigned char aa; unsigned char symbol = l;//+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame unsigned int nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); @@ -204,56 +202,17 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, switch(channel){ case NR_PBCH_EST: - -#ifdef DEBUG_FEP - printf("Channel estimation eNB %d, slot %d, symbol %d\n",eNB_id,Ns,l); -#endif -#if UE_TIMING_TRACE - start_meas(&ue->dlsch_channel_estimation_stats); -#endif - nr_pbch_channel_estimation(ue,eNB_id,0, - Ns, - l, - symbol); - //} -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_channel_estimation_stats); -#endif - - // do frequency offset estimation here! - // use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1}) -#ifdef DEBUG_FEP - printf("Frequency offset estimation\n"); -#endif - - if (l==(4-frame_parms->Ncp)) { - -#if UE_TIMING_TRACE - start_meas(&ue->dlsch_freq_offset_estimation_stats); -#endif - - /*lte_est_freq_offset(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[0], - frame_parms, - l, - &common_vars->freq_offset, - reset_freq_est);*/ -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_freq_offset_estimation_stats); -#endif - - } - break; case NR_PDCCH_EST: #ifdef DEBUG_FEP - printf("PDCCH Channel estimation eNB %d, aatx %d, slot %d, symbol %d start_sc %d\n",eNB_id,aa,Ns,l,coreset_start_subcarrier); + printf("PDCCH Channel estimation aatx %d, slot %d, symbol %d start_sc %d\n",aa,Ns,l,coreset_start_subcarrier); #endif #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); #endif - nr_pdcch_channel_estimation(ue,eNB_id,0, + nr_pdcch_channel_estimation(ue,0, Ns, l, symbol, @@ -267,7 +226,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, case NR_PDSCH_EST: #ifdef DEBUG_FEP - printf("Channel estimation eNB %d, aatx %d, slot %d, symbol %d\n",eNB_id,aa,Ns,l); + printf("Channel estimation aatx %d, slot %d, symbol %d\n",aa,Ns,l); #endif #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); @@ -276,7 +235,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ue->frame_parms.nushift = (p>>1)&1;; if (symbol ==l0) - nr_pdsch_channel_estimation(ue,eNB_id,0, + nr_pdsch_channel_estimation(ue,0, Ns, p, l, 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 a90450b0a5..05ee82ae29 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -33,10 +33,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, - unsigned char l, unsigned char symbol) { int pilot[200] __attribute__((aligned(16))); @@ -78,8 +76,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, k = nushift; #ifdef DEBUG_CH - printf("PBCH 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>>1], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, - ue->frame_parms.Ncp,l,Ns,k, symbol); + printf("PBCH 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>>1], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, + ue->frame_parms.Ncp,Ns,k, symbol); #endif switch (k) { @@ -254,7 +252,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, unsigned char l, @@ -478,7 +475,6 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, } int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, unsigned short p, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index ae4295a99b..a6ede43504 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -43,7 +43,6 @@ \param symbol symbol within frame */ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, unsigned char l, @@ -52,14 +51,11 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned short nb_rb_coreset); int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, - unsigned char l, unsigned char symbol); int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, unsigned short p, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index e5f079ebc3..ea4745fe23 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -35,6 +35,7 @@ #include "PHY/INIT/phy_init.h" #include "PHY/MODULATION/modulation_UE.h" #include "nr_transport_proto_ue.h" +#include "PHY/NR_UE_ESTIMATION/nr_estimation.h" //#include "SCHED/defs.h" //#include "SCHED/extern.h" @@ -68,32 +69,18 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) frame_parms->nb_prefix_samples0 = frame_parms->nb_prefix_samples; - //symbol 1 - nr_slot_fep(ue, - 1, - 0, - ue->ssb_offset, - 0, - 1, - NR_PBCH_EST); - - //symbol 2 - nr_slot_fep(ue, - 2, - 0, - ue->ssb_offset, - 0, - 1, - NR_PBCH_EST); - - //symbol 3 - nr_slot_fep(ue, - 3, - 0, - ue->ssb_offset, - 0, - 1, - NR_PBCH_EST); + for(int i=1; i<4;i++) { + +#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); +#endif + nr_pbch_channel_estimation(ue,0, + 0, + i); +#if UE_TIMING_TRACE + stop_meas(&ue->dlsch_channel_estimation_stats); +#endif + } //put back nb_prefix_samples0 frame_parms->nb_prefix_samples0 = nb_prefix_samples0; @@ -224,6 +211,15 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) /* 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))) { + + 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"); #endif @@ -241,8 +237,8 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) int nb_prefix_samples0 = fp->nb_prefix_samples0; fp->nb_prefix_samples0 = fp->nb_prefix_samples; - nr_slot_fep(ue,0, 0, ue->ssb_offset, 0, 1, NR_PDCCH_EST); - nr_slot_fep(ue,1, 0, ue->ssb_offset, 0, 1, NR_PDCCH_EST); + nr_slot_fep(ue,0, 0, ue->ssb_offset, 0, NR_PDCCH_EST); + nr_slot_fep(ue,1, 0, ue->ssb_offset, 0, NR_PDCCH_EST); fp->nb_prefix_samples0 = nb_prefix_samples0; LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n", diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 9b09a846bb..e4495a5526 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -898,6 +898,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain } if (fo_flag){ + // fractional frequency offser computation according to Cross-correlation Synchronization Algorithm Using PSS // Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012. @@ -922,7 +923,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain // estimation of fractional frequency offset: angle[(result1)'*(result2)]/pi ffo_est=atan2(re1*im2-re2*im1,re1*re2+im1*im2)/M_PI; - + #ifdef DBG_PSS_NR printf("ffo %lf\n",ffo_est); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c index 26639a5134..493672f890 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c @@ -443,24 +443,6 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric,uint8_t *phase_max) // For now, symbol 0 = PSS/PBCH and it is never in symbol 0 or 7*2^mu (i.e. always shorter prefix) frame_parms->nb_prefix_samples0 = frame_parms->nb_prefix_samples; - // Do FFTs for SSS/PSS - // SSS - nr_slot_fep(ue, - SSS_SYMBOL_NB-PSS_SYMBOL_NB, // symbol number w.r.t. PSS - 0, // Ns slot number - ue->ssb_offset, // sample_offset of int16_t - 0, // no_prefix - 1, // reset frequency estimation - NR_SSS_EST); - - // PSS - nr_slot_fep(ue, - 0, - 0, - ue->ssb_offset, - 0, - 1, - NR_SSS_EST); frame_parms->nb_prefix_samples0 = nb_prefix_samples0; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1a631000f5..a2388def23 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4991,7 +4991,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN nr_tti_rx, 0, 0, - 1, NR_PDCCH_EST); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE @@ -5022,7 +5021,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN nr_tti_rx, 0, 0, - 1, NR_PDSCH_EST); //printf("phy procedure pdsch start measurement\n"); @@ -5106,7 +5104,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN nr_tti_rx, 0, 0, - 1, NR_PBCH_EST); nr_ue_pbch_procedures(eNB_id,ue,proc,0); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index a52c6ecf0d..74850d2509 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -43,6 +43,7 @@ #include "PHY/INIT/phy_init.h" #include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +#include "PHY/NR_UE_ESTIMATION/nr_estimation.h" #include "SCHED_NR/sched_nr.h" @@ -371,6 +372,7 @@ int main(int argc, char **argv) frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_DL; frame_parms->Nid_cell = Nid_cell; + frame_parms->ssb_type = nr_ssb_type_B; nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,0); @@ -545,7 +547,6 @@ int main(int argc, char **argv) n_errors_payload = 0; for (trial=0; trialrx_offset=0; - //symbol 1 - nr_slot_fep(UE, - 5, - 0, - 0, - 0, - 1, - NR_PBCH_EST); - - //symbol 2 - nr_slot_fep(UE, - 6, - 0, - 0, - 0, - 1, - NR_PBCH_EST); - - //symbol 3 - nr_slot_fep(UE, - 7, - 0, - 0, - 0, - 1, - NR_PBCH_EST); + + for (int i=5; i<8; i++) { + nr_slot_fep(UE, + i, + 0, + 0, + 0, + NR_PBCH_EST); + + nr_pbch_channel_estimation(UE,0,0,i); + } ret = nr_rx_pbch(UE, &UE->proc.proc_rxtx[0], diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 1dc3085edf..020dd9adbf 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -965,7 +965,7 @@ void *UE_thread(void *arg) { UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, UE->frame_parms.nb_antennas_rx),""); //write_output("txdata_sym.m", "txdata_sym", UE->common_vars.rxdata[0], (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0), 1, 1); - //nr_slot_fep(UE,0, 0, 0, 1, 1, NR_PDCCH_EST); + //nr_slot_fep(UE,0, 0, 0, 1, NR_PDCCH_EST); } //UE->mode != loop_through_memory else rt_sleep_ns(1000*1000); From 49e9baee5b3605e0e0dde4963ccb5db4619b44d6 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 1 Mar 2019 13:04:23 +0100 Subject: [PATCH 13/54] brute force ssb detection --- .../nfapi/public_inc/nfapi_nr_interface.h | 2 +- openair1/PHY/INIT/nr_init.c | 7 ++- openair1/PHY/MODULATION/slot_fep_nr.c | 12 +++- .../nr_dl_channel_estimation.c | 17 +++--- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 11 ++-- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 60 +++++++++++-------- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 2 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 4 ++ openair1/PHY/NR_UE_TRANSPORT/sss_nr.c | 15 ----- openair1/PHY/defs_nr_UE.h | 3 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 11 +++- openair1/SIMULATION/NR_PHY/pbchsim.c | 15 ++--- 12 files changed, 87 insertions(+), 72 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 69b1c5c3ac..7c78d817a6 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -75,7 +75,7 @@ typedef struct // These TLVs are used by the VNF to configure the RF in the PNF // nfapi_uint16_tlv_t max_transmit_power; - nfapi_uint16_tlv_t nrarfcn; + nfapi_uint32_tlv_t nrarfcn; // nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands; // nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 2f613152dd..3a116de25f 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -363,7 +363,7 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu, NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; nfapi_nr_config_request_t *gNB_config = &gNB->gNB_config; //overwrite for new NR parameters - gNB_config->nfapi_config.rf_bands.rf_band[0] = 5; + gNB_config->nfapi_config.rf_bands.rf_band[0] = 78; gNB_config->nfapi_config.nrarfcn.value = 620000; gNB_config->subframe_config.numerology_index_mu.value = mu; gNB_config->subframe_config.duplex_mode.value = TDD; @@ -377,12 +377,13 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu, gNB_config->sch_config.ssb_scg_position_in_burst.value=position_in_burst; gNB->mac_enabled = 1; - fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); - fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); + fp->dl_CarrierFreq = 3500000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); + fp->ul_CarrierFreq = 3500000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); fp->threequarter_fs = 0; nr_init_frame_parms(gNB_config, fp); gNB->configured = 1; LOG_I(PHY,"gNB configured\n"); + } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index f41212e543..6ce486e3a0 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -45,8 +45,16 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, 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 = (no_prefix ? 0 : frame_parms->nb_prefix_samples); - unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); + unsigned int nb_prefix_samples; + unsigned int nb_prefix_samples0; + if (ue->is_synchronized) { + nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); + nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); + } + else { + nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); + nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples); + } //unsigned int subframe_offset;//,subframe_offset_F; unsigned int slot_offset; //int i; 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 05ee82ae29..20227b827b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -32,6 +32,7 @@ //#define DEBUG_PDCCH + int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, @@ -47,13 +48,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; - uint8_t nushift, ssb_index=0, n_hf=0; + uint8_t nushift; + uint8_t ssb_index=ue->i_ssb; + uint8_t n_hf=ue->n_hf; int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset]; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; - unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size; @@ -120,7 +122,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, pil = (int16_t *)&pilot[0]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; - + memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), @@ -137,6 +139,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, // Treat first 2 pilots specially (left edge) 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("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); @@ -154,6 +157,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, 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 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -165,9 +170,6 @@ 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 @@ -195,6 +197,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } 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 %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -213,6 +216,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, 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 %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -247,7 +251,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, //} } - return(0); } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index a6ede43504..ed24edaf56 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -51,9 +51,9 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned short nb_rb_coreset); int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, - uint8_t eNB_offset, - unsigned char Ns, - unsigned char symbol); + uint8_t eNB_offset, + unsigned char Ns, + unsigned char symbol); int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, @@ -61,8 +61,9 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, 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); + void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *ue, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index ea4745fe23..dce3bb51f1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -53,48 +53,48 @@ int cnt=0; #define DEBUG_INITIAL_SYNCH -int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) + +int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mode) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; - #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync: starting PBCH detection (rx_offset %d)\n",ue->Mod_id, ue->rx_offset); #endif - // save the nb_prefix_samples0 since we are not synchronized to subframes yet and the SSB has all symbols with nb_prefix_samples - int nb_prefix_samples0 = frame_parms->nb_prefix_samples0; - frame_parms->nb_prefix_samples0 = frame_parms->nb_prefix_samples; + uint8_t N_L = (frame_parms->Lmax == 4)? 4:8; + uint8_t N_hf = (frame_parms->Lmax == 4)? 2:1; + // loops over possible pbch dmrs cases to retrive best estimated i_ssb (and n_hf for Lmax=4) for multiple ssb detection + for (int hf = 0; hf < N_hf; hf++) { + for (int l = 0; l < N_L ; l++) { + if (ret !=0) { + ue->i_ssb = l; + ue->n_hf = hf; - for(int i=1; i<4;i++) { - #if UE_TIMING_TRACE - start_meas(&ue->dlsch_channel_estimation_stats); + start_meas(&ue->dlsch_channel_estimation_stats); #endif - nr_pbch_channel_estimation(ue,0, - 0, - i); + for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); + stop_meas(&ue->dlsch_channel_estimation_stats); #endif + + ret = nr_rx_pbch(ue, + &ue->proc.proc_rxtx[0], + ue->pbch_vars[0], + frame_parms, + 0, + SISO, + ue->high_speed_flag); + + } + } } - //put back nb_prefix_samples0 - frame_parms->nb_prefix_samples0 = nb_prefix_samples0; - - - ret = nr_rx_pbch(ue, - &ue->proc.proc_rxtx[0], - ue->pbch_vars[0], - frame_parms, - 0, - SISO, - ue->high_speed_flag); - - if (ret==0) { frame_parms->nb_antenna_ports_eNB = 1; //pbch_tx_ant; @@ -211,6 +211,14 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) /* 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 */ + /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ + /* 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 */ + /* 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, @@ -230,7 +238,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) //nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0); nr_gold_pbch(ue); - ret = nr_pbch_detection(ue,mode); + ret = nr_pbch_detection(ue,1,mode); // start pbch detection at first symbol after pss nr_gold_pdcch(ue,0, 2); /* diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index a88b51e37a..49d8d80b04 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -426,7 +426,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, uint8_t nushift; uint16_t M; uint8_t Lmax=frame_parms->Lmax; - uint8_t ssb_index=0; + uint8_t ssb_index=ue->i_ssb; //uint16_t crc; //unsigned short idx_demod =0; uint32_t decoderState=0; 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 3c272b9c17..36158fa259 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1125,6 +1125,10 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, MIMO_mode_t mimo_mode, uint32_t high_speed_flag); +int nr_pbch_detection(PHY_VARS_NR_UE *ue, + int pbch_initial_symbol, + runmode_t mode); + uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue, uint8_t eNB_id, uint8_t pbch_phase); diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c index 493672f890..3d36822956 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c @@ -430,21 +430,6 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric,uint8_t *phase_max) int32_t metric, metric_re; int16_t *d; - /* 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 */ - /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ - /* 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 */ - /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */ - - int nb_prefix_samples0 = frame_parms->nb_prefix_samples0; - // For now, symbol 0 = PSS/PBCH and it is never in symbol 0 or 7*2^mu (i.e. always shorter prefix) - frame_parms->nb_prefix_samples0 = frame_parms->nb_prefix_samples; - - - frame_parms->nb_prefix_samples0 = nb_prefix_samples0; // pss sss extraction pss_sss_extract_nr(ue, diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a3c404ba61..f384bcaccf 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1143,6 +1143,8 @@ typedef struct { uint8_t decode_MIB; /// temporary offset during cell search prior to MIB decoding int ssb_offset; + uint8_t i_ssb; + uint8_t n_hf; int rx_offset; /// Timing offset int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP int time_sync_cell; @@ -1307,6 +1309,7 @@ typedef struct { } PHY_VARS_NR_UE; + /* this structure is used to pass both UE phy vars and * proc to the function UE_thread_rxn_txnp4 */ diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index a2388def23..3b04a79321 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -5098,14 +5098,23 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1)) { LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); - for (int i=0; i<3; i++) + for (int i=0; i<3; i++) { nr_slot_fep(ue, (5+i), //mu=1 case B nr_tti_rx, 0, 0, NR_PBCH_EST); + +#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); +#endif + nr_pbch_channel_estimation(ue,0,0,5+i); +#if UE_TIMING_TRACE + stop_meas(&ue->dlsch_channel_estimation_stats); +#endif + } nr_ue_pbch_procedures(eNB_id,ue,proc,0); } diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 74850d2509..f424dc9f29 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -372,7 +372,8 @@ int main(int argc, char **argv) frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_DL; frame_parms->Nid_cell = Nid_cell; - frame_parms->ssb_type = nr_ssb_type_B; + frame_parms->nushift = Nid_cell%4; + frame_parms->ssb_type = nr_ssb_type_C; nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,0); @@ -605,17 +606,9 @@ int main(int argc, char **argv) 0, 0, NR_PBCH_EST); - - nr_pbch_channel_estimation(UE,0,0,i); } - - ret = nr_rx_pbch(UE, - &UE->proc.proc_rxtx[0], - UE->pbch_vars[0], - frame_parms, - 0, - SISO, - UE->high_speed_flag); + + ret = nr_pbch_detection(UE,5,0); // start pbch detection from symbol 5 and mode 0 if (ret==0) { //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically From 568fa2375ca0df2a4f323751109e66f81a5698fb Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 1 Mar 2019 15:41:17 +0100 Subject: [PATCH 14/54] adding loop over slots in nr_pbchsim --- openair1/SIMULATION/NR_PHY/pbchsim.c | 47 ++++++++++++++++------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index f424dc9f29..8811ae97f7 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -488,28 +488,35 @@ int main(int argc, char **argv) gNB->pbch_configured = 1; for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1; - nr_common_signal_procedures (gNB,frame,subframe); - - LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); - if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1); - - //TODO: loop over slots - for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { - if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { - PHY_ofdm_mod(gNB->common_vars.txdataF[aa], - txdata[aa], - frame_parms->ofdm_symbol_size, - 12, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); - } else { - nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], - txdata[aa], - 14, - frame_parms); + for (int slot=0;slotslots_per_frame;slot++) { + for (aa=0; aaframe_parms.nb_antennas_tx; aa++) + memset(gNB->common_vars.txdataF[aa],0,frame_parms->samples_per_slot_wCP*sizeof(int32_t)); + + nr_common_signal_procedures (gNB,frame,slot); + + //TODO: loop over slots + for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { + if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { + PHY_ofdm_mod(gNB->common_vars.txdataF[aa], + &txdata[aa][slot*frame_parms->samples_per_slot], + frame_parms->ofdm_symbol_size, + 12, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); + } else { + nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], + &txdata[aa][slot*frame_parms->samples_per_slot], + 14, + frame_parms); + } } } + + LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1); + + } else { printf("Reading %d samples from file to antenna buffer %d\n",frame_length_complex_samples,0); From 62e56f212e9f6594a6e4a9386584f230b4b2ea79 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 1 Mar 2019 17:57:53 +0100 Subject: [PATCH 15/54] some hardcoding removed in pbch detection still some left --- openair1/PHY/INIT/nr_parms.c | 53 +++++++++++++++++ openair1/PHY/INIT/phy_init.h | 1 + .../nr_dl_channel_estimation.c | 14 ++--- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 3 +- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 3 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 57 +------------------ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 11 +++- 9 files changed, 75 insertions(+), 71 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 14d95ad488..a2471d6d55 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -27,6 +27,59 @@ uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 16, 32}; +int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index) +{ + + int mu = fp->numerology_index; + int symbol = 0; + uint8_t n, n_temp; + nr_ssb_type_e type = fp->ssb_type; + int case_AC[2] = {2,8}; + int case_BD[4] = {4,8,16,20}; + int case_E[8] = {8, 12, 16, 20, 32, 36, 40, 44}; + + switch(mu) { + + case NR_MU_0: // case A + n = i_ssb >> 1; + symbol = case_AC[i_ssb % 2] + 14*n; + break; + + case NR_MU_1: + if (type == 1){ // case B + n = i_ssb >> 2; + symbol = case_BD[i_ssb % 4] + 28*n; + } + if (type == 2){ // case C + n = i_ssb >> 1; + symbol = case_AC[i_ssb % 2] + 14*n; + } + break; + + case NR_MU_3: // case D + n_temp = i_ssb >> 2; + n = n_temp + (n_temp >> 2); + symbol = case_BD[i_ssb % 4] + 28*n; + break; + + case NR_MU_4: // case E + n_temp = i_ssb >> 3; + n = n_temp + (n_temp >> 2); + symbol = case_E[i_ssb % 8] + 56*n; + break; + + + default: + AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu); + } + + if (half_frame_index) + symbol += (5 * fp->symbols_per_slot * fp->slots_per_subframe); + + return symbol; +} + + int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, int mu, int Ncp, diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index a454fb8e80..ddda39a4c8 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -376,6 +376,7 @@ void phy_config_request(PHY_Config_t *phy_config); int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf); void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms); +int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index); int nr_init_frame_parms(nfapi_nr_config_request_t* config, NR_DL_FRAME_PARMS *frame_parms); int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,int mu,int Ncp,int N_RB_DL,int n_ssb_crb,int ssb_subcarrier_offset); int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag); 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 20227b827b..15e83b51d0 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -36,7 +36,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, - unsigned char symbol) + unsigned char symbol, + int dmrss) { int pilot[200] __attribute__((aligned(16))); unsigned char aarx; @@ -44,7 +45,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned int pilot_cnt; int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; int ch_offset,symbol_offset; - int dmrss; //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; @@ -59,18 +59,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size; - if (ue->is_synchronized ==0 ) dmrss = symbol-1; - else dmrss = symbol-5; - if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage ch_offset = ue->frame_parms.ofdm_symbol_size ; else ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; - AssertFatal((symbol > 0 && symbol < 4 && ue->is_synchronized == 0) || - (symbol > 4 && symbol < 8 && ue->is_synchronized == 1), - "symbol %d is illegal for PBCH DM-RS (is_synchronized %d)\n", - symbol,ue->is_synchronized); + AssertFatal(dmrss >= 0 && dmrss < 3, + "symbol %d is illegal for PBCH DM-RS \n", + dmrss); symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index ed24edaf56..5418b16d1b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -53,7 +53,8 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, - unsigned char symbol); + unsigned char symbol, + int dmrss); int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index dce3bb51f1..4f0f905e9f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -78,7 +78,7 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod start_meas(&ue->dlsch_channel_estimation_stats); #endif for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 49d8d80b04..4d8ce3dec9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -34,6 +34,7 @@ #include "PHY/phy_extern_nr_ue.h" #include "PHY/sse_intrin.h" #include "PHY/LTE_REFSIG/lte_refsig.h" +#include "PHY/INIT/phy_init.h" //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING @@ -442,7 +443,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, int symbol_offset=1; if (ue->is_synchronized > 0) - symbol_offset=4; + symbol_offset=2; else symbol_offset=0; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index d922a3143d..aeda4b3549 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -30,6 +30,7 @@ #include "SCHED/fapi_l1.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "PHY/INIT/phy_init.h" #include "T.h" @@ -77,60 +78,6 @@ int return_ssb_type(nfapi_config_request_t *cfg) }*/ -// First SSB starting symbol candidate is used and type B is chosen for 30kHz SCS - -int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp, uint8_t i_ssb) -{ - - int mu = cfg->subframe_config.numerology_index_mu.value; - int symbol = 0; - uint8_t n, n_temp; - nr_ssb_type_e type = fp->ssb_type; - int case_AC[2] = {2,8}; - int case_BD[4] = {4,8,16,20}; - int case_E[8] = {8, 12, 16, 20, 32, 36, 40, 44}; - - - switch(mu) { - - case NR_MU_0: // case A - n = i_ssb >> 1; - symbol = case_AC[i_ssb % 2] + 14*n; - break; - - case NR_MU_1: - if (type == 1){ // case B - n = i_ssb >> 2; - symbol = case_BD[i_ssb % 4] + 28*n; - } - if (type == 2){ // case C - n = i_ssb >> 1; - symbol = case_AC[i_ssb % 2] + 14*n; - } - break; - - case NR_MU_3: // case D - n_temp = i_ssb >> 2; - n = n_temp + (n_temp >> 2); - symbol = case_BD[i_ssb % 4] + 28*n; - break; - - case NR_MU_4: // case E - n_temp = i_ssb >> 3; - n = n_temp + (n_temp >> 2); - symbol = case_E[i_ssb % 8] + 56*n; - break; - - - default: - AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu); - } - - if (cfg->sch_config.half_frame_index.value) - symbol += (5 * fp->symbols_per_slot * fp->slots_per_subframe); - - return symbol; -} void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) { fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<subframe_config.numerology_index_mu.value); @@ -158,7 +105,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { ssb_index = i + 2*rel_slot; // computing the ssb_index if ((fp->L_ssb >> ssb_index) & 0x01) { // generating the ssb only if the bit of L_ssb at current ssb index is 1 - int ssb_start_symbol_abs = nr_get_ssb_start_symbol(cfg, fp, ssb_index); // computing the starting symbol for current ssb + int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp, ssb_index, n_hf); // computing the starting symbol for current ssb ssb_start_symbol = ssb_start_symbol_abs % 14; // start symbol wrt slot nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 3b04a79321..33b42749e0 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -5109,7 +5109,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,5+i); + nr_pbch_channel_estimation(ue,0,0,5+i,i); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); #endif diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 8811ae97f7..4b281184b8 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -378,6 +378,8 @@ int main(int argc, char **argv) nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); phy_init_nr_gNB(gNB,0,0); + uint8_t n_hf = gNB_config->sch_config.half_frame_index.value; + double fs,bw,scs,eps; switch (mu) { @@ -494,7 +496,6 @@ int main(int argc, char **argv) nr_common_signal_procedures (gNB,frame,slot); - //TODO: loop over slots for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { PHY_ofdm_mod(gNB->common_vars.txdataF[aa], @@ -605,8 +606,12 @@ int main(int argc, char **argv) } else { UE->rx_offset=0; + + uint8_t ssb_index = 0; + while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb - for (int i=5; i<8; i++) { + int start_symbol = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf); + for (int i=start_symbol+1; irx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically From 2aa32eff67f8edcc863fef749ceb56be6d4af1db Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Mon, 4 Mar 2019 15:32:43 +0100 Subject: [PATCH 16/54] brute force multiple ssb detection works in pbchsim --- .../nr_dl_channel_estimation.c | 6 ++-- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 4 ++- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 31 ++++++++++--------- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 22 +++++++++---- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 1 + openair1/PHY/defs_nr_UE.h | 3 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 11 +++++-- openair1/SIMULATION/NR_PHY/pbchsim.c | 8 ++--- 8 files changed, 53 insertions(+), 33 deletions(-) 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 15e83b51d0..d39677d232 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -37,7 +37,9 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, unsigned char symbol, - int dmrss) + int dmrss, + uint8_t ssb_index, + uint8_t n_hf) { int pilot[200] __attribute__((aligned(16))); unsigned char aarx; @@ -49,8 +51,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; uint8_t nushift; - uint8_t ssb_index=ue->i_ssb; - uint8_t n_hf=ue->n_hf; int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset]; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 5418b16d1b..591b4733ce 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -54,7 +54,9 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, unsigned char symbol, - int dmrss); + int dmrss, + uint8_t ssb_index, + uint8_t n_hf); int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 4f0f905e9f..0b9795b6bc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -71,14 +71,12 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod for (int hf = 0; hf < N_hf; hf++) { for (int l = 0; l < N_L ; l++) { if (ret !=0) { - ue->i_ssb = l; - ue->n_hf = hf; #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); #endif for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); #endif @@ -88,6 +86,7 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod ue->pbch_vars[0], frame_parms, 0, + l, SISO, ue->high_speed_flag); @@ -130,7 +129,7 @@ char prefix_string[2][9] = {"NORMAL","EXTENDED"}; int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) { - int32_t sync_pos, sync_pos_slot; // k_ssb, N_ssb_crb, sync_pos2, + int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2, int32_t metric_tdd_ncp=0; uint8_t phase_tdd_ncp; double im, re; @@ -173,20 +172,17 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) /* process pss search on received buffer */ sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE); - sync_pos_slot = (fp->samples_per_subframe/fp->slots_per_subframe) - 10*(fp->ofdm_symbol_size + 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; - 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;} - - ue->rx_offset = ue->ssb_offset - sync_pos_slot; //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 sync_pos_slot %d \n",sync_pos,ue->ssb_offset,sync_pos_slot); + LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); #endif // digital compensation of FFO for SSB symbols @@ -239,7 +235,14 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) 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; + } + nr_gold_pdcch(ue,0, 2); /* int nb_prefix_samples0 = fp->nb_prefix_samples0; @@ -263,7 +266,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) } else { #ifdef DEBUG_INITIAL_SYNCH - LOG_I(PHY,"TDD Normal prefix: SSS error condition: sync_pos %d, sync_pos_slot %d\n", sync_pos, sync_pos_slot); + LOG_I(PHY,"TDD Normal prefix: SSS error condition: sync_pos %d\n", sync_pos); #endif } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 4d8ce3dec9..11e3c5cfdf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -414,6 +414,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, + uint8_t i_ssb, MIMO_mode_t mimo_mode, uint32_t high_speed_flag) { NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; @@ -424,10 +425,9 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, //uint32_t pbch_a_prime; int16_t *pbch_e_rx; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; - uint8_t nushift; + uint8_t nushift,n_hf,ssb_index; uint16_t M; uint8_t Lmax=frame_parms->Lmax; - uint8_t ssb_index=ue->i_ssb; //uint16_t crc; //unsigned short idx_demod =0; uint32_t decoderState=0; @@ -443,7 +443,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, int symbol_offset=1; if (ue->is_synchronized > 0) - symbol_offset=2; + symbol_offset=ue->symbol_offset; else symbol_offset=0; @@ -527,7 +527,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, #endif //un-scrambling M = NR_POLAR_PBCH_E; - nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; + nushift = (Lmax==4)? i_ssb&3 : i_ssb&7; uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041; nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0); //polar decoding de-rate matching @@ -571,6 +571,16 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, for (int i=0; i<3; i++) decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); + n_hf = ((xtra_byte>>4)&0x01); // computing the half frame index from the extra byte + + ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8 + if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte + for (int i=0; i<3; i++) + ssb_index += (((xtra_byte>>(7-i))&0x01)<<(3+i)); + } + + ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf); + #ifdef DEBUG_PBCH printf("xtra_byte %x payload %x\n", xtra_byte, payload); @@ -578,14 +588,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, // printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]); } - #endif + ue->dl_indication.rx_ind = &ue->rx_ind; // hang on rx_ind instance //ue->rx_ind.sfn_slot = 0; //should be set by higher-1-layer, i.e. clean_and_set_if_instance() ue->rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_MIB; ue->rx_ind.rx_indication_body[0].mib_pdu.pdu = &decoded_output[0]; ue->rx_ind.rx_indication_body[0].mib_pdu.additional_bits = xtra_byte; - ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index = ssb_index; // confirm with TCL + ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index = i_ssb; // confirm with TCL ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_length = Lmax; // confirm with TCL ue->rx_ind.rx_indication_body[0].mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL ue->rx_ind.number_pdus = 1; 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 36158fa259..e9ccedd04b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1122,6 +1122,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, NR_UE_PBCH *nr_ue_pbch_vars, NR_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, + uint8_t i_ssb, MIMO_mode_t mimo_mode, uint32_t high_speed_flag); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index f384bcaccf..a482a48207 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1143,8 +1143,7 @@ typedef struct { uint8_t decode_MIB; /// temporary offset during cell search prior to MIB decoding int ssb_offset; - uint8_t i_ssb; - uint8_t n_hf; + uint16_t symbol_offset; // offset in terms of symbols for detected ssb in sync int rx_offset; /// Timing offset int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP int time_sync_cell; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 33b42749e0..89ae3c0696 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2973,6 +2973,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ue->pbch_vars[eNB_id], &ue->frame_parms, eNB_id, + ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index, SISO, ue->high_speed_flag); @@ -5098,9 +5099,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1)) { LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); - for (int i=0; i<3; i++) { + + 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, - (5+i), //mu=1 case B + (ue->symbol_offset+i), //mu=1 case B nr_tti_rx, 0, 0, @@ -5109,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,5+i,i); + nr_pbch_channel_estimation(ue,0,0,ue->symbol_offset+i,i-1,i_ssb,n_hf); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); #endif diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 4b281184b8..6891e5b875 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) unsigned char frame_type = 0; unsigned char pbch_phase = 0; - int frame=0,subframe=0; + int frame=0; int frame_length_complex_samples; int frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; @@ -610,8 +610,8 @@ int main(int argc, char **argv) uint8_t ssb_index = 0; while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb - int start_symbol = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf); - for (int i=start_symbol+1; isymbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf); + for (int i=UE->symbol_offset+1; isymbol_offset+4; i++) { nr_slot_fep(UE, i, 0, @@ -620,7 +620,7 @@ int main(int argc, char **argv) NR_PBCH_EST); } - ret = nr_pbch_detection(UE,start_symbol+1,0); + ret = nr_pbch_detection(UE,UE->symbol_offset+1,0); if (ret==0) { //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically From ab825dd68abdbea30ad3896e883a68cac0292076 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 6 Mar 2019 08:50:30 +0100 Subject: [PATCH 17/54] bugfix in pbch channel estimation and dci debug comment mode restored --- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 8 ++++---- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) 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 d39677d232..e6dab8e922 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -51,8 +51,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; uint8_t nushift; - int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset]; - int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; + int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_offset]; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 6f2f5bcf2d..e3e2331ac4 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -1418,11 +1418,11 @@ void nr_dci_decoding_procedure0(int s, *format_found=_format_2_3_found; } - //#ifdef NR_PDCCH_DCI_DEBUG + #ifdef NR_PDCCH_DCI_DEBUG printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d\n",*format_found); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled); + #endif - //#endif if (*format_found!=255) { dci_alloc[*dci_cnt].dci_length = sizeof_bits; dci_alloc[*dci_cnt].rnti = crc; @@ -1432,13 +1432,13 @@ void nr_dci_decoding_procedure0(int s, dci_alloc[*dci_cnt].dci_pdu[1] = dci_estimation[1]; dci_alloc[*dci_cnt].dci_pdu[2] = dci_estimation[2]; dci_alloc[*dci_cnt].dci_pdu[3] = dci_estimation[3]; - //#ifdef NR_PDCCH_DCI_DEBUG + #ifdef NR_PDCCH_DCI_DEBUG printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> rnti matches -> DCI FOUND !!! crc =>0x%x, sizeof_bits %d, sizeof_bytes %d \n", dci_alloc[*dci_cnt].rnti, dci_alloc[*dci_cnt].dci_length, sizeof_bytes); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> dci_cnt %d (format_css %d crc_scrambled %d) L %d, firstCCE %d pdu[0] 0x%lx pdu[1] 0x%lx \n", *dci_cnt, format_css,*crc_scrambled,dci_alloc[*dci_cnt].L, dci_alloc[*dci_cnt].firstCCE,dci_alloc[*dci_cnt].dci_pdu[0],dci_alloc[*dci_cnt].dci_pdu[1]); - //#endif + #endif if ((format_css == cformat0_0_and_1_0) || (format_uss == uformat0_0_and_1_0)) { if ((*crc_scrambled == _p_rnti) || (*crc_scrambled == _si_rnti) || (*crc_scrambled == _ra_rnti)) { dci_alloc[*dci_cnt].format = format1_0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index e821e9696a..c067142897 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -52,7 +52,7 @@ //#define DEBUG_DCI #define NR_PDCCH_DCI_TOOLS -#define NR_PDCCH_DCI_TOOLS_DEBUG +//#define NR_PDCCH_DCI_TOOLS_DEBUG typedef unsigned __int128 uint128_t; From 6ce8c3742af1efd3e72678e66dfc688096c57147 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 7 Mar 2019 10:10:06 +0100 Subject: [PATCH 18/54] minor fixes in pbchsim --- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/pss_nr.c | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) 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 e6dab8e922..f17f6eb9b8 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -74,7 +74,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, k = nushift; #ifdef DEBUG_CH - printf("PBCH 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>>1], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, + printf("PBCH 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 diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index e4495a5526..40945bebef 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -899,7 +899,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain if (fo_flag){ - // fractional frequency offser computation according to Cross-correlation Synchronization Algorithm Using PSS + // fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS // Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012. int64_t result1,result2; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 6891e5b875..cc01357868 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -412,6 +412,7 @@ int main(int argc, char **argv) // computation of integer and fractional FO to compare with estimation results int IFO; if(eps!=0.0){ + UE->UE_fo_compensation = 1; printf("Introducing a CFO of %lf relative to SCS of %d kHz\n",eps,(int)(scs/1000)); if (eps>0) IFO=(int)(eps+0.5); @@ -520,7 +521,7 @@ int main(int argc, char **argv) } else { printf("Reading %d samples from file to antenna buffer %d\n",frame_length_complex_samples,0); - + UE->UE_fo_compensation = 1; // perform fo compensation when samples from file are used if (fread(txdata[0], sizeof(int32_t), frame_length_complex_samples, @@ -594,9 +595,9 @@ int main(int argc, char **argv) } if (n_trials==1) { - LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0],frame_parms->samples_per_subframe,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[1],frame_parms->samples_per_subframe,1,1); + LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1],frame_parms->samples_per_frame,1,1); } if (UE->is_synchronized == 0) { From aadc28257005676b35234347a76bb63f7f043f79 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 7 Feb 2019 13:05:35 +0100 Subject: [PATCH 19/54] [ulschsim] Initial version (copy of dlschsim) --- cmake_targets/CMakeLists.txt | 3 + cmake_targets/build_oai | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 672 ++++++++++++++++++++++++++ 3 files changed, 676 insertions(+), 1 deletion(-) create mode 100644 openair1/SIMULATION/NR_PHY/ulschsim.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index af9c3edf68..949731a021 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2557,6 +2557,9 @@ add_executable(nr_dlsim ${T_SOURCE}) target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) +add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c ${T_SOURCE}) +target_link_libraries(nr_ulschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) + foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 3bbc1ccb71..596ff978f1 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -691,7 +691,7 @@ function main() { echo_info "Compiling unitary tests simulators" # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" - simlist="dlsim ulsim polartest ldpctest nr_pbchsim nr_dlschsim nr_dlsim" + simlist="dlsim ulsim polartest ldpctest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim" for f in $simlist ; do compilations \ phy_simulators $f \ diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c new file mode 100644 index 0000000000..2b36a03e61 --- /dev/null +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -0,0 +1,672 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include +#include +#include +#include +#include +#include + +#include "common/config/config_userapi.h" +#include "common/utils/LOG/log.h" +#include "common/ran_context.h" + +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" +#include "PHY/types.h" +#include "PHY/defs_nr_common.h" +#include "PHY/defs_nr_UE.h" +#include "PHY/defs_gNB.h" +#include "PHY/INIT/phy_init.h" +#include "PHY/NR_REFSIG/refsig_defs_ue.h" +#include "PHY/NR_REFSIG/nr_mod_table.h" +#include "PHY/MODULATION/modulation_eNB.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_dlsch.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" + +#include "SCHED_NR/sched_nr.h" + +//#include "PHY/MODULATION/modulation_common.h" +//#include "common/config/config_load_configmodule.h" +//#include "UTIL/LISTS/list.h" +//#include "common/ran_context.h" + +//#define DEBUG_DLSCHSIM + +PHY_VARS_gNB *gNB; +PHY_VARS_NR_UE *UE; +RAN_CONTEXT_t RC; + +double cpuf; + +// dummy functions +int nfapi_mode = 0; +int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { + return (0); +} +int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { + return (0); +} + +int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { + return (0); +} + +int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { + return (0); +} + +int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) { + return (0); +} + +uint32_t from_nrarfcn(int nr_bandP, uint32_t dl_earfcn) { + return (0); +} +int32_t get_uldl_offset(int eutra_bandP) { + return (0); +} + +NR_IF_Module_t * +NR_IF_Module_init(int Mod_id) { + return (NULL); +} + +void exit_function(const char *file, const char *function, const int line, + const char *s) { + const char *msg = s == NULL ? "no comment" : s; + printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); + exit(-1); +} + +// needed for some functions +PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; +uint16_t n_rnti = 0x1234; + +char quantize(double D, double x, unsigned char B) { + double qxd; + short maxlev; + qxd = floor(x / D); + maxlev = 1 << (B - 1); //(char)(pow(2,B-1)); + + //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev); + + if (qxd <= -maxlev) + qxd = -maxlev; + else if (qxd >= maxlev) + qxd = maxlev - 1; + + return ((char) qxd); +} + +int main(int argc, char **argv) { + char c; + int i; //,j,l,aa; + double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; + double snr_step = 0.1; + uint8_t snr1set = 0; + int **txdata; + double **s_re, **s_im, **r_re, **r_im; + // int sync_pos, sync_pos_slot; + // FILE *rx_frame_file; + FILE *output_fd = NULL; + uint8_t write_output_file = 0; + // int subframe_offset; + // char fname[40], vname[40]; + int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; + uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; + uint16_t Nid_cell = 0; + channel_desc_t *gNB2UE; + uint8_t extended_prefix_flag = 0; + int8_t interf1 = -21, interf2 = -21; + FILE *input_fd = NULL, *pbch_file_fd = NULL; + //char input_val_str[50],input_val_str2[50]; + //uint16_t NB_RB=25; + SCM_t channel_model = AWGN; //Rayleigh1_anticorr; + uint16_t N_RB_DL = 106, mu = 1; + unsigned char frame_type = 0; + unsigned char pbch_phase = 0; + int frame = 0, subframe = 0; + int frame_length_complex_samples; + //int frame_length_complex_samples_no_prefix; + NR_DL_FRAME_PARMS *frame_parms; + //nfapi_nr_config_request_t *gNB_config; + uint8_t Kmimo = 0; + uint32_t Nsoft = 0; + double sigma; + unsigned char qbits = 8; + int ret; + //int run_initial_sync=0; + int loglvl = OAILOG_WARNING; + float target_error_rate = 0.01; + + uint16_t nb_symb_sch = 12; + uint16_t nb_rb = 50; + uint8_t Imcs = 9; + + cpuf = get_cpu_freq_GHz(); + + if (load_configmodule(argc, argv) == 0) { + exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); + } + + //logInit(); + randominit(0); + + while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { + switch (c) { + case 'f': + write_output_file = 1; + output_fd = fopen(optarg, "w"); + + if (output_fd == NULL) { + printf("Error opening %s\n", optarg); + exit(-1); + } + + break; + + case 'd': + frame_type = 1; + break; + + case 'g': + switch ((char) *optarg) { + case 'A': + channel_model = SCM_A; + break; + + case 'B': + channel_model = SCM_B; + break; + + case 'C': + channel_model = SCM_C; + break; + + case 'D': + channel_model = SCM_D; + break; + + case 'E': + channel_model = EPA; + break; + + case 'F': + channel_model = EVA; + break; + + case 'G': + channel_model = ETU; + break; + + default: + msg("Unsupported channel model!\n"); + exit(-1); + } + + break; + + case 'i': + interf1 = atoi(optarg); + break; + + case 'j': + interf2 = atoi(optarg); + break; + + case 'n': + n_trials = atoi(optarg); + break; + + case 's': + snr0 = atof(optarg); + msg("Setting SNR0 to %f\n", snr0); + break; + + case 'S': + snr1 = atof(optarg); + snr1set = 1; + msg("Setting SNR1 to %f\n", snr1); + break; + + case 'p': + extended_prefix_flag = 1; + break; + + /* + case 'r': + ricean_factor = pow(10,-.1*atof(optarg)); + if (ricean_factor>1) { + printf("Ricean factor must be between 0 and 1\n"); + exit(-1); + } + break; + */ + + case 'y': + n_tx = atoi(optarg); + + if ((n_tx == 0) || (n_tx > 2)) { + msg("Unsupported number of tx antennas %d\n", n_tx); + exit(-1); + } + + break; + + case 'z': + n_rx = atoi(optarg); + + if ((n_rx == 0) || (n_rx > 2)) { + msg("Unsupported number of rx antennas %d\n", n_rx); + exit(-1); + } + + break; + + case 'N': + Nid_cell = atoi(optarg); + break; + + case 'R': + N_RB_DL = atoi(optarg); + break; + + case 'F': + input_fd = fopen(optarg, "r"); + + if (input_fd == NULL) { + printf("Problem with filename %s\n", optarg); + exit(-1); + } + + break; + + case 'P': + pbch_phase = atoi(optarg); + + if (pbch_phase > 3) + printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase); + + break; + + case 'm': + Imcs = atoi(optarg); + break; + + case 'l': + nb_symb_sch = atoi(optarg); + break; + + case 'r': + nb_rb = atoi(optarg); + break; + + case 'x': + transmission_mode = atoi(optarg); + break; + + default: + case 'h': + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); + printf("-h This message\n"); + printf("-p Use extended prefix mode\n"); + printf("-d Use TDD\n"); + printf("-n Number of frames to simulate\n"); + printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); + printf("-S Ending SNR, runs from SNR0 to SNR1\n"); + printf("-t Delay spread for multipath channel\n"); + printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); + printf("-x Transmission mode (1,2,6 for the moment)\n"); + printf("-y Number of TX antennas used in eNB\n"); + printf("-z Number of RX antennas used in UE\n"); + printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-N Nid_cell\n"); + printf("-R N_RB_DL\n"); + printf("-O oversampling factor (1,2,4,8,16)\n"); + printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); + // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + printf("-f Output filename (.txt format) for Pe/SNR results\n"); + printf("-F Input filename (.txt format) for RX conformance testing\n"); + exit(-1); + break; + } + } + + logInit(); + set_glog(loglvl); + T_stdout = 1; + + if (snr1set == 0) + snr1 = snr0 + 10; + + gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, + 61.44e6, //N_RB2sampling_rate(N_RB_DL), + 40e6, //N_RB2channel_bandwidth(N_RB_DL), + 0, 0, 0); + + if (gNB2UE == NULL) { + msg("Problem generating channel model. Exiting.\n"); + exit(-1); + } + + RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **)); + RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); + RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); + gNB = RC.gNB[0][0]; + //gNB_config = &gNB->gNB_config; + frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) + frame_parms->nb_antennas_tx = n_tx; + frame_parms->nb_antennas_rx = n_rx; + frame_parms->N_RB_DL = N_RB_DL; + frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; + crcTableInit(); + nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); + phy_init_nr_gNB(gNB, 0, 0); + //init_eNB_afterRU(); + frame_length_complex_samples = frame_parms->samples_per_subframe; + //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; + s_re = malloc(2 * sizeof(double *)); + s_im = malloc(2 * sizeof(double *)); + r_re = malloc(2 * sizeof(double *)); + r_im = malloc(2 * sizeof(double *)); + txdata = malloc(2 * sizeof(int *)); + + for (i = 0; i < 2; i++) { + s_re[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(s_re[i], frame_length_complex_samples * sizeof(double)); + s_im[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(s_im[i], frame_length_complex_samples * sizeof(double)); + r_re[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(r_re[i], frame_length_complex_samples * sizeof(double)); + r_im[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(r_im[i], frame_length_complex_samples * sizeof(double)); + txdata[i] = malloc(frame_length_complex_samples * sizeof(int)); + bzero(r_re[i], frame_length_complex_samples * sizeof(int)); + } + + if (pbch_file_fd != NULL) { + load_pbch_desc(pbch_file_fd); + } + + /* for (int k=0; k<2; k++) { + // Create transport channel structures for 2 transport blocks (MIMO) + for (i=0; i<2; i++) { + gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); + + if (!gNB->dlsch[k][i]) { + printf("Can't get eNB dlsch structures\n"); + exit(-1); + } + gNB->dlsch[k][i]->Nsoft = 10; + gNB->dlsch[k][i]->rnti = n_rnti+k; + } + }*/ + //configure UE + UE = malloc(sizeof(PHY_VARS_NR_UE)); + memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); + + //phy_init_nr_top(frame_parms); + if (init_nr_ue_signal(UE, 1, 0) != 0) { + printf("Error at UE NR initialisation\n"); + exit(-1); + } + + //nr_init_frame_parms_ue(&UE->frame_parms); + //init_nr_ue_transport(UE, 0); + for (int sf = 0; sf < 2; sf++) { + for (i = 0; i < 2; i++) { + UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL, + 0); + + if (!UE->dlsch[sf][0][i]) { + printf("Can't get ue dlsch structures\n"); + exit(-1); + } + + UE->dlsch[sf][0][i]->rnti = n_rnti; + } + } + + UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); + UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); + unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; + NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; + nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; + //time_stats_t *rm_stats, *te_stats, *i_stats; + uint8_t is_crnti = 0, llr8_flag = 0; + unsigned int TBS = 8424; + unsigned int available_bits; + uint8_t nb_re_dmrs = 6; + uint16_t length_dmrs = 1; + unsigned char mod_order; + uint8_t Nl = 1; + uint8_t rvidx = 0; + dlsch->rnti = 1; + /*dlsch->harq_processes[0]->mcs = Imcs; + dlsch->harq_processes[0]->rvidx = rvidx;*/ + //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], + // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); + mod_order = nr_get_Qm(Imcs, 1); + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, Nl); + printf("available bits %d TBS %d mod_order %d\n", available_bits, TBS, mod_order); + //dlsch->harq_ids[subframe]= 0; + rel15->n_prb = nb_rb; + rel15->nb_symbols = nb_symb_sch; + rel15->modulation_order = mod_order; + rel15->nb_layers = Nl; + rel15->nb_re_dmrs = nb_re_dmrs; + rel15->transport_block_size = TBS; + double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); + short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); + short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); + double errors_bit_uncoded = 0; + unsigned char *estimated_output; + unsigned char *estimated_output_bit; + unsigned char *test_input_bit; + unsigned int errors_bit = 0; + test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; + NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; + harq_process->mcs = Imcs; + harq_process->Nl = Nl; + harq_process->nb_rb = nb_rb; + harq_process->Qm = mod_order; + harq_process->rvidx = rvidx; + printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); + unsigned char *test_input; + test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); + + for (i = 0; i < TBS / 8; i++) + test_input[i] = (unsigned char) rand(); + + estimated_output = harq_process->b; + +#ifdef DEBUG_DLSCHSIM + for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); +#endif + + /*for (int i=0; i0x%08x\n",crc24c(test_input, 32)); + // generate signal + if (input_fd == NULL) { + nr_dlsch_encoding(test_input, subframe, dlsch, frame_parms); + } + + for (SNR = snr0; SNR < snr1; SNR += snr_step) { + n_errors = 0; + n_false_positive = 0; + + for (trial = 0; trial < n_trials; trial++) { + errors_bit_uncoded = 0; + for (i = 0; i < available_bits; i++) { +#ifdef DEBUG_CODER + if ((i&0xf)==0) + printf("\ne %d..%d: ",i,i+15); +#endif + + //if (i<16) + // printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); + if (dlsch->harq_processes[0]->f[i] == 0) + modulated_input[i] = 1.0; ///sqrt(2); //QPSK + else + modulated_input[i] = -1.0; ///sqrt(2); + + //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); + //SNR =10; + SNR_lin = pow(10, SNR / 10.0); + sigma = 1.0 / sqrt(2 * SNR_lin); + channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, + modulated_input[i] + sigma * gaussdouble(0.0, 1.0), + qbits); + //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); + //printf("llr[%d]=%d\n",i,channel_output_fixed[i]); + //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); + + //channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits); + + //if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]); + + //Uncoded BER + if (channel_output_fixed[i] < 0) + channel_output_uncoded[i] = 1; //QPSK demod + else + channel_output_uncoded[i] = 0; + + if (channel_output_uncoded[i] != dlsch->harq_processes[harq_pid]->f[i]) + errors_bit_uncoded = errors_bit_uncoded + 1; + } + + //if (errors_bit_uncoded>10) + //printf("errors bits uncoded %f\n", errors_bit_uncoded); +#ifdef DEBUG_CODER + printf("\n"); + exit(-1); +#endif + ret = nr_dlsch_decoding(UE, channel_output_fixed, &UE->frame_parms, + dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, + subframe, harq_pid, is_crnti, llr8_flag); + + if (ret > dlsch0_ue->max_ldpc_iterations) + n_errors++; + + //count errors + errors_bit = 0; + + for (i = 0; i < TBS; i++) { + estimated_output_bit[i] = (dlsch0_ue->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments + + if (estimated_output_bit[i] != test_input_bit[i]) { + errors_bit++; + //printf("estimated bits error occurs @%d ",i); + } + } + + if (errors_bit > 0) { + n_false_positive++; + if (n_trials == 1) + printf("errors_bit %d (trial %d)\n", errors_bit, trial); + } + } + + printf("SNR %f, BLER %f (false positive %f)\n", SNR, + (float) n_errors / (float) n_trials, + (float) n_false_positive / (float) n_trials); + + if ((float) n_errors / (float) n_trials < target_error_rate) { + printf("PDSCH test OK\n"); + break; + } + } + + /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/ + + //TODO: loop over slots + /*for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { + if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { + PHY_ofdm_mod(gNB->common_vars.txdataF[aa], + txdata[aa], + frame_parms->ofdm_symbol_size, + 12, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); + } else { + nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], + txdata[aa], + 14, + frame_parms); + } + } + + LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1); + + + for (i=0; inb_antennas_tx; aa++) { + r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); + r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); + } + }*/ + + for (i = 0; i < 2; i++) { + printf("gNB %d\n", i); + free_gNB_dlsch(gNB->dlsch[0][i]); + printf("UE %d\n", i); + free_nr_ue_dlsch(UE->dlsch[0][0][i]); + } + + for (i = 0; i < 2; i++) { + free(s_re[i]); + free(s_im[i]); + free(r_re[i]); + free(r_im[i]); + free(txdata[i]); + } + + free(s_re); + free(s_im); + free(r_re); + free(r_im); + free(txdata); + + if (output_fd) + fclose(output_fd); + + if (input_fd) + fclose(input_fd); + + return (n_errors); +} + From ad402982fe6a0deccaa0a90d30943c6e259c611e Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 7 Feb 2019 13:11:10 +0100 Subject: [PATCH 20/54] [ulschsim] Add support fo perfect channel (no noise) Also print the uncoded error bits --- openair1/SIMULATION/NR_PHY/ulschsim.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 2b36a03e61..72d4050f89 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -483,7 +483,7 @@ int main(int argc, char **argv) { double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); - double errors_bit_uncoded = 0; + unsigned int errors_bit_uncoded = 0; unsigned char *estimated_output; unsigned char *estimated_output_bit; unsigned char *test_input_bit; @@ -543,9 +543,13 @@ int main(int argc, char **argv) { //SNR =10; SNR_lin = pow(10, SNR / 10.0); sigma = 1.0 / sqrt(2 * SNR_lin); +#if 1 channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, modulated_input[i] + sigma * gaussdouble(0.0, 1.0), qbits); +#else + channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits); +#endif //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); //printf("llr[%d]=%d\n",i,channel_output_fixed[i]); //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); @@ -565,7 +569,7 @@ int main(int argc, char **argv) { } //if (errors_bit_uncoded>10) - //printf("errors bits uncoded %f\n", errors_bit_uncoded); + printf("errors bits uncoded %u\n", errors_bit_uncoded); #ifdef DEBUG_CODER printf("\n"); exit(-1); From 009b195d57fe3b8337fe9da6e5010daa55264dc2 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 13 Feb 2019 12:46:44 +0100 Subject: [PATCH 21/54] Initializing and freeing NR_UE_ULSCH_t. Creating nr_ulsch_coding.c --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/INIT/nr_init_ue.c | 12 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 4 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 4 +- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 41 ++-- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 204 ++++++++++++++++++ openair1/PHY/defs_nr_UE.h | 4 +- openair1/SCHED_NR_UE/harq_nr.c | 12 +- openair1/SCHED_NR_UE/harq_nr.h | 8 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 12 +- .../NR_UE_PHY/unit_tests/src/harq_test.c | 6 +- 11 files changed, 272 insertions(+), 36 deletions(-) create mode 100644 openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 949731a021..674d441dd9 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1304,6 +1304,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_initial_sync.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_pbch.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c + ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_tbs_tools.c diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index a150717e42..7a4cd9f446 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -361,8 +361,13 @@ void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, uint16_t max_harq_tx ) { + int num_of_threads,num_of_code_words; + PHY_VARS_NR_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; - phy_vars_ue->ulsch[eNB_id]->Mlimit = max_harq_tx; + + for (num_of_threads=0;num_of_threadsulsch[eNB_id][num_of_threads][num_of_code_words]->Mlimit = max_harq_tx; } extern uint16_t beta_cqi[16]; @@ -923,11 +928,12 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { AssertFatal((ue->dlsch[k][i][j] = new_nr_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[k][i][j]); + + AssertFatal((ue->ulsch[k][i][j] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NUMBER_OF_HARQ_PID_MAX, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n"); + LOG_D(PHY,"ulsch[%d][%d][%d] => %p\n",k,i,j,ue->ulsch[k][i][j]); } } - //AssertFatal((ue->ulsch[i] = new_ue_ulsch(ue->frame_parms.N_RB_UL, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n"); - ue->dlsch_SI[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); ue->dlsch_ra[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 7415b36281..7191e5f48b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -69,7 +69,7 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) #endif if (dlsch->harq_processes[i]->b) { - free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES); + free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES); //this should be MAX_NR_DLSCH_PAYLOAD_BYTES dlsch->harq_processes[i]->b = NULL; #ifdef DEBUG_DLSCH_FREE printf("Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b); @@ -196,7 +196,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, for (r=0; rharq_processes[i]->c[r] = (uint8_t*)malloc16(8448); - dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); + dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output if (dlsch->harq_processes[i]->c[r]) { bzero(dlsch->harq_processes[i]->c[r],8448); } else { 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 3c272b9c17..2b8e0258e6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -61,10 +61,10 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch); NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); -void free_ue_ulsch(NR_UE_ULSCH_t *ulsch); +void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch); -NR_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag); +NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag); void fill_UE_dlsch_MCH(PHY_VARS_NR_UE *ue,int mcs,int ndi,int rvidx,int eNB_id); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 0760c44b53..1f99da06c0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -110,20 +110,24 @@ typedef struct { uint32_t B; /// Length of ACK information (bits) uint8_t O_ACK; - /// Pointer to the payload - uint8_t *b; - /// Pointers to transport block segments - uint8_t *c[MAX_NUM_ULSCH_SEGMENTS]; /// Index of current HARQ round for this ULSCH uint8_t round; /// MCS format of this ULSCH uint8_t mcs; /// Redundancy-version of the current sub-frame uint8_t rvidx; - /// LDPC-code outputs - uint8_t d[MAX_NUM_ULSCH_SEGMENTS][3*8448]; - /// Interleaver outputs - uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*8448]; + /// pointer to pdu from MAC interface (TS 36.212 V15.4.0, Sec 5.1 p. 8) + uint8_t *a; + /// Pointer to the payload + CRC + uint8_t *b; + /// Pointers to transport block segments + uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC-code outputs (TS 36.212 V15.4.0, Sec 5.3.2 p. 17) + uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; // 66*Z_c is the maximum LDPC block length. We use 68 for internal manipulation of the buffer + /// Rate matching (Bit selection) outputs (TS 36.212 V15.4.0, Sec 5.4.2.1 p. 28) + uint8_t *e[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// Rate matching (Interleaving) outputs (TS 36.212 V15.4.0, Sec 5.4.2.2 p. 30) + uint8_t *f[MAX_NUM_NR_ULSCH_SEGMENTS]; /// Number of code segments uint32_t C; /// Number of bits in code segments @@ -168,6 +172,7 @@ typedef struct { // UL number of harq processes uint8_t number_harq_processes_for_pusch; #endif + /* /// Pointer to CQI data (+1 for 8 bits crc) uint8_t o[1+MAX_CQI_BYTES]; /// Length of CQI data (bits) @@ -180,22 +185,25 @@ typedef struct { uint8_t O_RI; /// Pointer to ACK uint8_t o_ACK[4]; + */ /// Minimum number of CQI bits for PUSCH (36-212 r8.6, Sec 5.2.4.1 p. 37) uint8_t O_CQI_MIN; /// ACK/NAK Bundling flag uint8_t bundling; - /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t e[MAX_NUM_CHANNEL_BITS]; + /// Concatenated "g"-sequences (for definition see 36-212 V15.4.0 2018-12, p.31) + uint8_t g[MAX_NUM_NR_CHANNEL_BITS]; /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t h[MAX_NUM_CHANNEL_BITS]; + uint8_t h[MAX_NUM_NR_CHANNEL_BITS]; /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - uint8_t b_tilde[MAX_NUM_CHANNEL_BITS]; + uint8_t b_tilde[MAX_NUM_NR_CHANNEL_BITS]; /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - int32_t d[MAX_NUM_RE]; + int32_t d[MAX_NUM_NR_RE]; /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15) - int32_t z[MAX_NUM_RE]; + int32_t z[MAX_NUM_NR_RE]; + /* /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) uint8_t q[MAX_CQI_PAYLOAD]; + /// coded and interleaved CQI bits uint8_t o_w[(MAX_CQI_BITS+8)*3]; /// coded CQI bits @@ -204,6 +212,7 @@ typedef struct { uint8_t q_ACK[MAX_ACK_PAYLOAD]; /// coded RI bits uint8_t q_RI[MAX_RI_PAYLOAD]; + */ /// beta_offset_cqi times 8 uint16_t beta_offset_cqi_times8; /// beta_offset_ri times 8 @@ -229,9 +238,9 @@ typedef struct { /// num active cba group uint8_t num_active_cba_groups; /// num dci found for cba - uint8_t num_cba_dci[10]; + //uint8_t num_cba_dci[10]; /// allocated CBA RNTI - uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; + //uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; /// UL max-harq-retransmission uint8_t Mlimit; } NR_UE_ULSCH_t; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c new file mode 100644 index 0000000000..8ad2a8ecb4 --- /dev/null +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -0,0 +1,204 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +* \brief Top-level routines for coding the ULSCH transport channel as described in 38.212 V15.4 2018-12 +* \author Khalid Ahmed +* \date 2019 +* \version 0.1 +* \company Fraunhofer IIS +* \email: khalid.ahmed@iis.fraunhofer.de +* \note +* \warning +*/ + +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/CODING/lte_interleaver_inline.h" +#include "PHY/CODING/nrLDPC_encoder/defs.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" +#include "common/utils/LOG/vcd_signal_dumper.h" + + + + + +void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) +{ + int i; + int r; + + if (ulsch) { +#ifdef DEBUG_ULSCH_FREE + printf("Freeing ulsch %p\n",ulsch); +#endif + + for (i=0; iharq_processes[i]) { + if (ulsch->harq_processes[i]->b) { + free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES); + ulsch->harq_processes[i]->b = NULL; + } + for (r=0; rharq_processes[i]->c[r]) { + free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); + ulsch->harq_processes[i]->c[r] = NULL; + } + + if (ulsch->harq_processes[i]->d[r]) { + free16(ulsch->harq_processes[i]->d[r],68*384); + ulsch->harq_processes[i]->d[r] = NULL; + } + + if (ulsch->harq_processes[i]->e[r]) { + free16(ulsch->harq_processes[i]->e[r],68*384); + ulsch->harq_processes[i]->e[r] = NULL; + } + + if (ulsch->harq_processes[i]->f[r]) { + free16(ulsch->harq_processes[i]->f[r],68*384); + ulsch->harq_processes[i]->f[r] = NULL; + } + + } + + free16(ulsch->harq_processes[i],sizeof(NR_UL_UE_HARQ_t)); + ulsch->harq_processes[i] = NULL; + } + } + free16(ulsch,sizeof(NR_UE_ULSCH_t)); + ulsch = NULL; + } + +} + +NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag) +{ + + NR_UE_ULSCH_t *ulsch; + unsigned char exit_flag = 0,i,j,r; + unsigned char bw_scaling =1; + + switch (N_RB_UL) { + + case 106: + bw_scaling =2; + break; + + default: + bw_scaling =1; + break; + } + + ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t)); + + if (ulsch) { + memset(ulsch,0,sizeof(NR_UE_ULSCH_t)); + + ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES; + ulsch->Mlimit = 4; // maximum harq retransmissions + + for (i=0; iharq_processes[i] = (NR_UL_UE_HARQ_t *)malloc16(sizeof(NR_UL_UE_HARQ_t)); + + // printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]); + if (ulsch->harq_processes[i]) { + memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t)); + ulsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + ulsch->harq_processes[i]->a = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + + if (ulsch->harq_processes[i]->a) { + bzero(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + } else { + printf("Can't allocate PDU\n"); + exit_flag=1; + } + + if (ulsch->harq_processes[i]->b) + memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + else { + LOG_E(PHY,"Can't get b\n"); + exit_flag=1; + } + + if (abstraction_flag==0) { + for (r=0; rharq_processes[i]->c[r] = (uint8_t*)malloc16(8448); + ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output + ulsch->harq_processes[i]->e[r] = (uint8_t*)malloc16(68*384); + ulsch->harq_processes[i]->f[r] = (uint8_t*)malloc16(68*384); + if (ulsch->harq_processes[i]->c[r]) { + bzero(ulsch->harq_processes[i]->c[r],8448); + } else { + printf("Can't get c\n"); + exit_flag=2; + } + if (ulsch->harq_processes[i]->d[r]) { + bzero(ulsch->harq_processes[i]->d[r],(68*384)); + } else { + printf("Can't get d\n"); + exit_flag=2; + } + if (ulsch->harq_processes[i]->e[r]) { + bzero(ulsch->harq_processes[i]->e[r],(68*384)); + } else { + printf("Can't get e\n"); + exit_flag=2; + } + if (ulsch->harq_processes[i]->f[r]) { + bzero(ulsch->harq_processes[i]->f[r],(68*384)); + } else { + printf("Can't get f\n"); + exit_flag=2; + } + } + } + + ulsch->harq_processes[i]->subframe_scheduling_flag = 0; + ulsch->harq_processes[i]->first_tx = 1; + } else { + LOG_E(PHY,"Can't get harq_p %d\n",i); + exit_flag=3; + } + } + + if ((abstraction_flag == 0) && (exit_flag==0)) { + for (i=0; i<8; i++) + for (j=0; j<96; j++) + for (r=0; rharq_processes[i]->d[r][j] = NR_NULL; + + return(ulsch); + } else if (abstraction_flag==1) + return(ulsch); + } + + LOG_E(PHY,"new_ue_ulsch exit flag, size of %d , %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t)); + free_nr_ue_ulsch(ulsch); + return(NULL); + + +} \ No newline at end of file diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a3c404ba61..10bfa46338 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1044,8 +1044,8 @@ typedef struct { NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX]; - NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][2]; // two RxTx Threads - NR_UE_ULSCH_t *ulsch[NUMBER_OF_CONNECTED_eNB_MAX]; + NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][NR_MAX_NB_CODEWORDS]; // two RxTx Threads + NR_UE_ULSCH_t *ulsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][NR_MAX_NB_CODEWORDS]; // two code words NR_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_eNB_MAX]; diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 23d828ec93..31dcfcacbe 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -150,7 +150,7 @@ void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_i * *********************************************************************/ -void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_harq_processes_pusch) +void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, int code_word_idx, uint8_t number_harq_processes_pusch) { NR_UE_ULSCH_t *ulsch; @@ -160,7 +160,7 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_h memset(ulsch,0,sizeof(NR_UE_ULSCH_t)); - ue->ulsch[gNB_id] = ulsch; + ue->ulsch[thread_id][gNB_id][code_word_idx] = ulsch; } else { LOG_E(PHY, "Fatal memory allocation problem at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__); @@ -185,7 +185,7 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_h } for (int slot_tx = 0; slot_tx < NR_MAX_SLOTS_PER_FRAME; slot_tx++) { - ue->ulsch[gNB_id]->harq_process_id[slot_tx] = NR_MAX_HARQ_PROCESSES; + ue->ulsch[thread_id][gNB_id][code_word_idx]->harq_process_id[slot_tx] = NR_MAX_HARQ_PROCESSES; } } @@ -202,9 +202,9 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_h * *********************************************************************/ -void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id) +void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, int code_word_idx) { - NR_UE_ULSCH_t *ulsch = ue->ulsch[gNB_id]; + NR_UE_ULSCH_t *ulsch = ue->ulsch[thread_id][gNB_id][code_word_idx]; for (int process_id = 0; process_id < ulsch->number_harq_processes_for_pusch; process_id++) { @@ -215,7 +215,7 @@ void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id) free16(ulsch, sizeof(NR_UE_ULSCH_t)); - ue->ulsch[gNB_id] = NULL; + ue->ulsch[thread_id][gNB_id][code_word_idx] = NULL; } /******************************************************************* diff --git a/openair1/SCHED_NR_UE/harq_nr.h b/openair1/SCHED_NR_UE/harq_nr.h index 2d3e87ddab..ee6e8625b0 100644 --- a/openair1/SCHED_NR_UE/harq_nr.h +++ b/openair1/SCHED_NR_UE/harq_nr.h @@ -83,17 +83,21 @@ void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_i /** \brief This function configures uplink HARQ context @param PHY_VARS_NR_UE ue context @param gNB_id gNodeB identifier + @param thread_id RXTX thread index + @param code_word_idx code word index @param number_harq_processes_pusch maximum number of uplink HARQ processes @returns none */ -void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_harq_processes_pusch); +void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, int code_word_idx, uint8_t number_harq_processes_pusch); /** \brief This function releases uplink HARQ context @param PHY_VARS_NR_UE ue context @param gNB_id gNodeB identifier + @param thread_id RXTX thread index + @param code_word_idx code word index @returns none */ -void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id); +void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int thread_id, int code_word_idx); /** \brief This function stores slot for transmission in HARQ context @param ulsch uplink context diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 72d4050f89..951d969c51 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) { //char input_val_str[50],input_val_str2[50]; //uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr; - uint16_t N_RB_DL = 106, mu = 1; + uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame = 0, subframe = 0; @@ -291,6 +291,7 @@ int main(int argc, char **argv) { case 'R': N_RB_DL = atoi(optarg); + N_RB_UL = N_RB_DL; break; case 'F': @@ -381,6 +382,7 @@ int main(int argc, char **argv) { frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; frame_parms->N_RB_DL = N_RB_DL; + frame_parms->N_RB_UL = N_RB_UL; frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; crcTableInit(); nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); @@ -446,6 +448,13 @@ int main(int argc, char **argv) { exit(-1); } + UE->ulsch[sf][0][i] = new_nr_ue_ulsch(N_RB_UL, 8, 0); + + if (!UE->ulsch[sf][0][i]) { + printf("Can't get ue ulsch structures\n"); + exit(-1); + } + UE->dlsch[sf][0][i]->rnti = n_rnti; } } @@ -649,6 +658,7 @@ int main(int argc, char **argv) { free_gNB_dlsch(gNB->dlsch[0][i]); printf("UE %d\n", i); free_nr_ue_dlsch(UE->dlsch[0][0][i]); + free_nr_ue_ulsch(UE->ulsch[0][0][i]); } for (i = 0; i < 2; i++) { diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c index ab99841668..05170e0bc9 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c @@ -54,6 +54,8 @@ int test_harq_uplink(PHY_VARS_NR_UE *phy_vars_ue) { int gNB_id = 0; + int thread_number = 0; + int code_word_idx = 0; int harq_pid = 0; int ndi = 1; uint8_t rnti_type = _C_RNTI_; @@ -61,7 +63,7 @@ int test_harq_uplink(PHY_VARS_NR_UE *phy_vars_ue) printf("\nHARQ Uplink \n"); - config_uplink_harq_process(phy_vars_ue , gNB_id, NR_DEFAULT_DLSCH_HARQ_PROCESSES); + config_uplink_harq_process(phy_vars_ue , gNB_id, thread_number, code_word_idx, NR_DEFAULT_DLSCH_HARQ_PROCESSES); NR_UE_ULSCH_t *ulsch_harq = phy_vars_ue->ulsch[gNB_id]; @@ -91,7 +93,7 @@ int test_harq_uplink(PHY_VARS_NR_UE *phy_vars_ue) } } - release_uplink_harq_process(phy_vars_ue , gNB_id); + release_uplink_harq_process(phy_vars_ue , gNB_id, thread_number, code_word_idx); return 0; } From 3d3f49c5c0931c446ce7dfb17597f3ac4cc4c2e5 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Mon, 18 Feb 2019 15:15:44 +0100 Subject: [PATCH 22/54] nr_ulsch_encoding is implemented and tested --- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 13 +- .../NR_TRANSPORT/nr_transport_common_proto.h | 2 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 3 + .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 14 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 313 ++++++++++++++++-- openair1/SIMULATION/NR_PHY/ulschsim.c | 65 +++- 6 files changed, 358 insertions(+), 52 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 7191e5f48b..eb1bdb0508 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -272,7 +272,7 @@ int nr_dlsch_encoding(unsigned char *a, unsigned int G; unsigned int crc=1; - + int i; uint8_t harq_pid = dlsch->harq_ids[slot]; nfapi_nr_dl_config_dlsch_pdu_rel15_t rel15 = dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; uint16_t nb_rb = rel15.n_prb; @@ -302,7 +302,9 @@ int nr_dlsch_encoding(unsigned char *a, A = rel15.transport_block_size; G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15.nb_layers); + LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order); + Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, rel15.nb_layers); @@ -328,8 +330,13 @@ int nr_dlsch_encoding(unsigned char *a, dlsch->harq_processes[harq_pid]->B = A+24; // dlsch->harq_processes[harq_pid]->b = a; + memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); + //write_output("enc_b.m","enc_in0",&dlsch->harq_processes[harq_pid]->b[0],(A/8)+4,1,4); + //for(i=0;i<10;i++) + //printf("dlsch->harq_processes[harq_pid]->b %d\n", dlsch->harq_processes[harq_pid]->b[i]); + nr_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, @@ -351,6 +358,7 @@ int nr_dlsch_encoding(unsigned char *a, Kr = dlsch->harq_processes[harq_pid]->K; Kr_bytes = Kr>>3; + //write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); //printf("segment Z %d k %d Kr %d BG %d\n", *pz,dlsch->harq_processes[harq_pid]->K,Kr,BG); //start_meas(te_stats); @@ -388,6 +396,7 @@ int nr_dlsch_encoding(unsigned char *a, //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); + //write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); #ifdef DEBUG_DLSCH_CODING write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4); @@ -429,6 +438,7 @@ int nr_dlsch_encoding(unsigned char *a, rel15.redundancy_version, E); + #ifdef DEBUG_DLSCH_CODING for (int i =0; i<16; i++) printf("output ratematching e[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset); @@ -442,6 +452,7 @@ int nr_dlsch_encoding(unsigned char *a, dlsch->harq_processes[harq_pid]->f+r_offset); //stop_meas(i_stats); + #ifdef DEBUG_DLSCH_CODING for (int i =0; i<16; i++) printf("output interleaving f[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->f[i+r_offset], r_offset); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index b075da4e97..14ba3de923 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -38,7 +38,7 @@ #define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS #define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056) -#define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056) +#define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_ULSCH_SEGMENTS*1056) #define MAX_NUM_NR_CHANNEL_BITS (14*273*12*6) // 14 symbols, 273 RB #define MAX_NUM_NR_RE (14*273*12) 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 2b8e0258e6..d3e7dd0621 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1006,6 +1006,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint8_t is_crnti, uint8_t llr8_flag); +int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, + NR_DL_FRAME_PARMS* frame_parms); + uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, int eNB_id, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 1f99da06c0..885039c592 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -102,6 +102,8 @@ typedef struct { uint16_t first_rb; /// Current Number of RBs uint16_t nb_rb; + /// number of layers + uint8_t Nl; /// Last TPC command uint8_t TPC; /// Transport block size @@ -117,17 +119,17 @@ typedef struct { /// Redundancy-version of the current sub-frame uint8_t rvidx; /// pointer to pdu from MAC interface (TS 36.212 V15.4.0, Sec 5.1 p. 8) - uint8_t *a; + unsigned char *a; /// Pointer to the payload + CRC uint8_t *b; /// Pointers to transport block segments uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC-code outputs + uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; /// LDPC-code outputs (TS 36.212 V15.4.0, Sec 5.3.2 p. 17) - uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; // 66*Z_c is the maximum LDPC block length. We use 68 for internal manipulation of the buffer - /// Rate matching (Bit selection) outputs (TS 36.212 V15.4.0, Sec 5.4.2.1 p. 28) - uint8_t *e[MAX_NUM_NR_ULSCH_SEGMENTS]; + uint8_t e[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32))); /// Rate matching (Interleaving) outputs (TS 36.212 V15.4.0, Sec 5.4.2.2 p. 30) - uint8_t *f[MAX_NUM_NR_ULSCH_SEGMENTS]; + uint8_t f[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32))); /// Number of code segments uint32_t C; /// Number of bits in code segments @@ -162,6 +164,8 @@ typedef struct { typedef struct { /// Current Number of Symbols uint8_t Nsymb_pusch; + /// number of DMRS resource elements + uint8_t nb_re_dmrs; /// SRS active flag uint8_t srs_active; //#if defined(UPGRADE_RAT_NR) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 8ad2a8ecb4..965627e4a8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -56,6 +56,11 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) for (i=0; iharq_processes[i]) { + + if (ulsch->harq_processes[i]->a) { + free16(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES); + ulsch->harq_processes[i]->a = NULL; + } if (ulsch->harq_processes[i]->b) { free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES); ulsch->harq_processes[i]->b = NULL; @@ -71,16 +76,6 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) ulsch->harq_processes[i]->d[r] = NULL; } - if (ulsch->harq_processes[i]->e[r]) { - free16(ulsch->harq_processes[i]->e[r],68*384); - ulsch->harq_processes[i]->e[r] = NULL; - } - - if (ulsch->harq_processes[i]->f[r]) { - free16(ulsch->harq_processes[i]->f[r],68*384); - ulsch->harq_processes[i]->f[r] = NULL; - } - } free16(ulsch->harq_processes[i],sizeof(NR_UL_UE_HARQ_t)); @@ -119,6 +114,9 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES; ulsch->Mlimit = 4; // maximum harq retransmissions + //for (i=0; i<10; i++) + //ulsch->harq_ids[i] = 0; + for (i=0; iharq_processes[i] = (NR_UL_UE_HARQ_t *)malloc16(sizeof(NR_UL_UE_HARQ_t)); @@ -126,8 +124,8 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u // printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]); if (ulsch->harq_processes[i]) { memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t)); - ulsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); - ulsch->harq_processes[i]->a = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + ulsch->harq_processes[i]->a = (unsigned char*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); if (ulsch->harq_processes[i]->a) { bzero(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); @@ -137,7 +135,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u } if (ulsch->harq_processes[i]->b) - memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + bzero(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); else { LOG_E(PHY,"Can't get b\n"); exit_flag=1; @@ -148,8 +146,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u // account for filler in first segment and CRCs for multiple segment case ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448); ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output - ulsch->harq_processes[i]->e[r] = (uint8_t*)malloc16(68*384); - ulsch->harq_processes[i]->f[r] = (uint8_t*)malloc16(68*384); + if (ulsch->harq_processes[i]->c[r]) { bzero(ulsch->harq_processes[i]->c[r],8448); } else { @@ -162,18 +159,6 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u printf("Can't get d\n"); exit_flag=2; } - if (ulsch->harq_processes[i]->e[r]) { - bzero(ulsch->harq_processes[i]->e[r],(68*384)); - } else { - printf("Can't get e\n"); - exit_flag=2; - } - if (ulsch->harq_processes[i]->f[r]) { - bzero(ulsch->harq_processes[i]->f[r],(68*384)); - } else { - printf("Can't get f\n"); - exit_flag=2; - } } } @@ -185,15 +170,13 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u } } - if ((abstraction_flag == 0) && (exit_flag==0)) { - for (i=0; i<8; i++) - for (j=0; j<96; j++) - for (r=0; rharq_processes[i]->d[r][j] = NR_NULL; + if (exit_flag==0) { + for (i=0; iharq_processes[i]->round=0; + } return(ulsch); - } else if (abstraction_flag==1) - return(ulsch); + } } LOG_E(PHY,"new_ue_ulsch exit flag, size of %d , %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t)); @@ -201,4 +184,264 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u return(NULL); -} \ No newline at end of file +} + + + +int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, + NR_DL_FRAME_PARMS* frame_parms) +{ + +/////////////////////////parameters and variables declaration///////////////////////// +/////////// + + unsigned int G,crc; + uint8_t harq_pid; + NR_UL_UE_HARQ_t *harq_process; + uint16_t nb_rb ; + uint8_t nb_symb_sch ; + uint32_t A, Z; + uint32_t *pz; + uint8_t mod_order; + uint16_t Kr,r,r_offset,Kr_bytes; + uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; + uint8_t kb,BG; + uint32_t E; + uint8_t Ilbrm; + uint32_t Tbslbrm; + uint8_t nb_re_dmrs; + uint16_t length_dmrs; + int i; + +/////////// +/////////////////////////////////////////////////////////////////////////////////////// + + +/////////////////////////parameters and variables initialization///////////////////////// +/////////// + + crc = 1; + harq_pid = 0; + harq_process = ulsch->harq_processes[harq_pid]; + nb_rb = harq_process->nb_rb; + nb_symb_sch = harq_process->nb_symbols; + A = harq_process->TBS; + pz = &Z; + mod_order = nr_get_Qm(harq_process->mcs,1); + Kr=0; + r_offset=0; + BG = 1; + Ilbrm = 0; + Tbslbrm = 950984; //max tbs + nb_re_dmrs = ulsch->nb_re_dmrs; + length_dmrs = 1; + +/////////// +///////////////////////////////////////////////////////////////////////////////////////// + + /* + uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char + for(j=0;jNl); + LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order); + printf("ulsch coding A %d G %d mod_order %d\n", A,G, mod_order); + + Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); + + // if (harq_process->Ndi == 1) { // this is a new packet + if (harq_process->round == 0) { // this is a new packet +#ifdef DEBUG_DLSCH_CODING + printf("encoding thinks this is a new packet \n"); +#endif + +///////////////////////// a---->| add CRC |---->b ///////////////////////// +/////////// + /* + int i; + printf("dlsch (tx): \n"); + for (i=0;i<(A>>3);i++) + printf("%02x.",a[i]); + printf("\n"); + */ + // Add 24-bit crc (polynomial A) to payload + crc = crc24a(harq_process->a,A)>>8; + harq_process->a[A>>3] = ((uint8_t*)&crc)[2]; + harq_process->a[1+(A>>3)] = ((uint8_t*)&crc)[1]; + harq_process->a[2+(A>>3)] = ((uint8_t*)&crc)[0]; + //printf("CRC %x (A %d)\n",crc,A); + //printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]); + + harq_process->B = A+24; + + memcpy(harq_process->b,harq_process->a,(A/8)+4); + + //write_output("ulsch_b.m","enc_in0",&harq_process->b[0],(A/8)+4,1,4); + //for(i=0;i<10;i++) + //printf("harq_process->b %d\n", harq_process->b[i]); + + + +/////////// +/////////////////////////////////////////////////////////////////////////// + +///////////////////////// b---->| block segmentation |---->c ///////////////////////// +/////////// + + nr_segmentation(harq_process->b, + harq_process->c, + harq_process->B, + &harq_process->C, + &harq_process->K, + pz, + &harq_process->F); + + kb = harq_process->K/(*pz); + if ( kb==22){ + BG = 1; + } + else{ + BG = 2; + } + + Kr = harq_process->K; + Kr_bytes = Kr>>3; + + write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); + +/////////// +///////////////////////////////////////////////////////////////////////////////////// + + +///////////////////////// c---->| LDCP coding |---->d ///////////////////////// +/////////// + + //printf("segment Z %d kb %d k %d Kr %d BG %d\n", *pz,kb,harq_process->K,Kr,BG); + + //start_meas(te_stats); + for (r=0; rC; r++) { + d_tmp[r] = &harq_process->d[r][0]; + //channel_input[r] = &harq_process->d[r][0]; +#ifdef DEBUG_DLSCH_CODING + printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F); + printf("start ldpc encoder segment %d/%d\n",r,harq_process->C); + printf("input %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); + for (int cnt =0 ; cnt < 22*(*pz)/8; cnt ++){ + printf("%d ", harq_process->c[r][cnt]); + } + printf("\n"); + +#endif + //ldpc_encoder_orig((unsigned char*)harq_process->c[r],harq_process->d[r],Kr,BG,0); + //ldpc_encoder_optim((unsigned char*)harq_process->c[r],(unsigned char*)&harq_process->d[r][0],Kr,BG,NULL,NULL,NULL,NULL); + } + + //for (int i=0;i<68*384;i++) + // printf("channel_input[%d]=%d\n",i,channel_input[i]); + + + + /*printf("output %d %d %d %d %d \n", harq_process->d[0][0], harq_process->d[0][1], harq_process->d[r][2],harq_process->d[0][3], harq_process->d[0][4]); + for (int cnt =0 ; cnt < 66*(*pz); cnt ++){ + printf("%d \n", harq_process->d[0][cnt]); + } + printf("\n");*/ + + //ldpc_encoder_optim_8seg(harq_process->c,d_tmp,Kr,BG,harq_process->C,NULL,NULL,NULL,NULL); + ldpc_encoder_optim_8seg(harq_process->c,harq_process->d,Kr,BG,harq_process->C,NULL,NULL,NULL,NULL); + + //stop_meas(te_stats); + //printf("end ldpc encoder -- output\n"); + //write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); +#ifdef DEBUG_DLSCH_CODING + write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); + write_output("ulsch_enc_output0.m","enc0",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,4); +#endif + +/////////// +/////////////////////////////////////////////////////////////////////////////// + + } + + for (r=0; rC; r++) { // looping over C segments +#ifdef DEBUG_DLSCH_CODING + printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", + r, + G, + Kr*3, + mod_order,nb_rb); +#endif + + //start_meas(rm_stats); +#ifdef DEBUG_DLSCH_CODING + printf("rvidx in encoding = %d\n", harq_process->rvidx); +#endif + +///////////////////////// d---->| Rate matching bit selection |---->e ///////////////////////// +/////////// + + E = nr_get_E(G, harq_process->C, mod_order, harq_process->Nl, r); + + nr_rate_matching_ldpc(Ilbrm, + Tbslbrm, + BG, + *pz, + harq_process->d[r], + harq_process->e+r_offset, + harq_process->C, + harq_process->rvidx, + E); + + + +#ifdef DEBUG_DLSCH_CODING + for (int i =0; i<16; i++) + printf("output ratematching e[%d]= %d r_offset %d\n", i,harq_process->e[i+r_offset], r_offset); +#endif + +/////////// +/////////////////////////////////////////////////////////////////////////////////////////////// + + +///////////////////////// e---->| Rate matching bit interleaving |---->f ///////////////////////// +/////////// + + //stop_meas(rm_stats); + + //start_meas(i_stats); + nr_interleaving_ldpc(E, + mod_order, + harq_process->e+r_offset, + harq_process->f+r_offset); + //stop_meas(i_stats); + + +#ifdef DEBUG_DLSCH_CODING + for (int i =0; i<16; i++) + printf("output interleaving f[%d]= %d r_offset %d\n", i,harq_process->f[i+r_offset], r_offset); + + if (r==harq_process->C-1) + write_output("enc_output.m","enc",harq_process->f,G,1,4); +#endif + + r_offset += E; + +/////////// +/////////////////////////////////////////////////////////////////////////////////////////////// + + } + + memcpy(ulsch->g,harq_process->f,G>>3); // g is the concatenated code block + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); + + return(0); +} diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 951d969c51..80121b3d7f 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -122,7 +122,7 @@ char quantize(double D, double x, unsigned char B) { int main(int argc, char **argv) { char c; - int i; //,j,l,aa; + int i,sf; //,j,l,aa; double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; double snr_step = 0.1; uint8_t snr1set = 0; @@ -438,7 +438,7 @@ int main(int argc, char **argv) { //nr_init_frame_parms_ue(&UE->frame_parms); //init_nr_ue_transport(UE, 0); - for (int sf = 0; sf < 2; sf++) { + for (sf = 0; sf < 2; sf++) { for (i = 0; i < 2; i++) { UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL, 0); @@ -464,6 +464,9 @@ int main(int argc, char **argv) { unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; + + NR_UE_ULSCH_t *ulsch = UE->ulsch[0][0][0]; + //time_stats_t *rm_stats, *te_stats, *i_stats; uint8_t is_crnti = 0, llr8_flag = 0; unsigned int TBS = 8424; @@ -474,6 +477,7 @@ int main(int argc, char **argv) { uint8_t Nl = 1; uint8_t rvidx = 0; dlsch->rnti = 1; + ulsch->nb_re_dmrs = nb_re_dmrs; //[adk] A HOT FIX until cearting nfapi_nr_ul_config_ulsch_pdu_rel15_t /*dlsch->harq_processes[0]->mcs = Imcs; dlsch->harq_processes[0]->rvidx = rvidx;*/ //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], @@ -497,9 +501,13 @@ int main(int argc, char **argv) { unsigned char *estimated_output_bit; unsigned char *test_input_bit; unsigned int errors_bit = 0; + test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; harq_process->mcs = Imcs; @@ -516,6 +524,26 @@ int main(int argc, char **argv) { estimated_output = harq_process->b; + + /////////////////////////[adk] preparing UL harq_process parameters///////////////////////// + /////////// + NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch->harq_processes[harq_pid]; + + if (harq_process_ul_ue){ + + harq_process_ul_ue->mcs = Imcs; + harq_process_ul_ue->Nl = Nl; + harq_process_ul_ue->nb_rb = nb_rb; + harq_process_ul_ue->nb_symbols = nb_symb_sch; + harq_process_ul_ue->rvidx = rvidx; + harq_process_ul_ue->TBS = TBS; + harq_process_ul_ue->a = &test_input[0]; + + } + /////////// + //////////////////////////////////////////////////////////////////////////////////////////// + + #ifdef DEBUG_DLSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); #endif @@ -527,6 +555,7 @@ int main(int argc, char **argv) { // generate signal if (input_fd == NULL) { nr_dlsch_encoding(test_input, subframe, dlsch, frame_parms); + nr_ulsch_encoding(ulsch, frame_parms); } for (SNR = snr0; SNR < snr1; SNR += snr_step) { @@ -540,10 +569,14 @@ int main(int argc, char **argv) { if ((i&0xf)==0) printf("\ne %d..%d: ",i,i+15); #endif + /* + if (i<16){ + printf("dlsch_encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); + printf("ulsch_encoder output f[%d] = %d\n",i,ulsch->harq_processes[0]->f[i]); - //if (i<16) - // printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); - if (dlsch->harq_processes[0]->f[i] == 0) + } + */ + if (ulsch->harq_processes[0]->f[i] == 0) modulated_input[i] = 1.0; ///sqrt(2); //QPSK else modulated_input[i] = -1.0; ///sqrt(2); @@ -594,7 +627,7 @@ int main(int argc, char **argv) { errors_bit = 0; for (i = 0; i < TBS; i++) { - estimated_output_bit[i] = (dlsch0_ue->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); + estimated_output_bit[i] = (ulsch->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments if (estimated_output_bit[i] != test_input_bit[i]) { @@ -653,12 +686,24 @@ int main(int argc, char **argv) { } }*/ + for (i = 0; i < 2; i++) { + printf("gNB %d\n", i); - free_gNB_dlsch(gNB->dlsch[0][i]); - printf("UE %d\n", i); - free_nr_ue_dlsch(UE->dlsch[0][0][i]); - free_nr_ue_ulsch(UE->ulsch[0][0][i]); + + if (gNB->dlsch[0][i]) + free_gNB_dlsch(gNB->dlsch[0][i]); + + for (sf = 0; sf < 2; sf++) { + + printf("UE %d\n", i); + + if (UE->dlsch[sf][0][i]) + free_nr_ue_dlsch(UE->dlsch[sf][0][i]); + + if (UE->ulsch[sf][0][i]) + free_nr_ue_ulsch(UE->ulsch[sf][0][i]); + } } for (i = 0; i < 2; i++) { From ea2bc826f1b2650f547fd00eb81d006482452cf4 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 20 Feb 2019 17:20:39 +0100 Subject: [PATCH 23/54] minor clean ups --- cmake_targets/CMakeLists.txt | 5 ++++- openair1/PHY/CODING/crc_byte.c | 6 +++++- openair1/PHY/INIT/nr_init_ue.c | 5 ++--- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 8 +------- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 7 ------- openair1/PHY/defs_nr_common.h | 4 ++-- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 674d441dd9..6ed11eebfa 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2558,7 +2558,10 @@ add_executable(nr_dlsim ${T_SOURCE}) target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) -add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c ${T_SOURCE}) +add_executable(nr_ulschsim + ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c + ${OPENAIR_DIR}/common/utils/backtrace.c + ${T_SOURCE}) target_link_libraries(nr_ulschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index d728d6b9ad..5e0ebeb991 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -32,6 +32,7 @@ #include "coding_defs.h" +#include "assertions.h" /*ref 36-212 v8.6.0 , pp 8-9 */ /* the highest degree is set by default */ @@ -275,7 +276,7 @@ int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type) break; default: - crc_len=3; + AssertFatal(1,"Invalid crc_type \n"); } for (int i=0; i>24; break; + + default: + AssertFatal(1,"Invalid crc_type \n"); } if (crc == oldcrc) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 7a4cd9f446..986d423034 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -925,9 +925,8 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { for (i=0; idlsch[k][i][j] = new_nr_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); - - LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[k][i][j]); + AssertFatal((ue->dlsch[k][i][j] = new_nr_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); + LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[k][i][j]); AssertFatal((ue->ulsch[k][i][j] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NUMBER_OF_HARQ_PID_MAX, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n"); LOG_D(PHY,"ulsch[%d][%d][%d] => %p\n",k,i,j,ue->ulsch[k][i][j]); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index eb1bdb0508..4e8c2d2ff5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -272,7 +272,6 @@ int nr_dlsch_encoding(unsigned char *a, unsigned int G; unsigned int crc=1; - int i; uint8_t harq_pid = dlsch->harq_ids[slot]; nfapi_nr_dl_config_dlsch_pdu_rel15_t rel15 = dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; uint16_t nb_rb = rel15.n_prb; @@ -333,10 +332,6 @@ int nr_dlsch_encoding(unsigned char *a, memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); - //write_output("enc_b.m","enc_in0",&dlsch->harq_processes[harq_pid]->b[0],(A/8)+4,1,4); - //for(i=0;i<10;i++) - //printf("dlsch->harq_processes[harq_pid]->b %d\n", dlsch->harq_processes[harq_pid]->b[i]); - nr_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, @@ -358,7 +353,6 @@ int nr_dlsch_encoding(unsigned char *a, Kr = dlsch->harq_processes[harq_pid]->K; Kr_bytes = Kr>>3; - //write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); //printf("segment Z %d k %d Kr %d BG %d\n", *pz,dlsch->harq_processes[harq_pid]->K,Kr,BG); //start_meas(te_stats); @@ -466,5 +460,5 @@ int nr_dlsch_encoding(unsigned char *a, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); - return(0); + return 0; } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 965627e4a8..6b17eff585 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -284,12 +284,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, memcpy(harq_process->b,harq_process->a,(A/8)+4); - //write_output("ulsch_b.m","enc_in0",&harq_process->b[0],(A/8)+4,1,4); - //for(i=0;i<10;i++) - //printf("harq_process->b %d\n", harq_process->b[i]); - - - /////////// /////////////////////////////////////////////////////////////////////////// @@ -315,7 +309,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, Kr = harq_process->K; Kr_bytes = Kr>>3; - write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); /////////// ///////////////////////////////////////////////////////////////////////////////////// diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 58a8833b18..21c1af5774 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -87,10 +87,10 @@ #define NR_MAX_CSET_DURATION 3 #define NR_MAX_NB_RBG 18 -#define NR_MAX_NB_LAYERS 8 +#define NR_MAX_NB_LAYERS 8 // SU-MIMO (3GPP TS 38.211 V15.4.0 section 7.3.1.3) #define NR_MAX_NB_CODEWORDS 2 #define NR_MAX_NB_HARQ_PROCESSES 16 -#define NR_MAX_PDSCH_ENCODED_LENGTH 950984 +#define NR_MAX_PDSCH_ENCODED_LENGTH NR_MAX_NB_RB*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8*NR_MAX_NB_LAYERS // 8 is the maximum modulation order (it was 950984 before !!) #define NR_MAX_PDSCH_TBS 3824 typedef enum { From a7fc22c807f16c42866a12d1cd47aa40b23ba406 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Tue, 26 Feb 2019 12:53:00 +0100 Subject: [PATCH 24/54] Adding harq_pid as an input to nr_ulsch_encoding --- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 18 +++++++++++++++++- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 5 ++--- openair1/SIMULATION/NR_PHY/ulschsim.c | 10 +++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) 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 d3e7dd0621..3db43237a0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1007,7 +1007,23 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint8_t llr8_flag); int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, - NR_DL_FRAME_PARMS* frame_parms); + NR_DL_FRAME_PARMS* frame_parms, + uint8_t harq_pid); + +/*! \brief Perform PUSCH scrambling. TS 38.211 V15.4.0 subclause 6.3.1.1 + @param[in] in Pointer to input bits + @param[in] size of input bits + @param[in] Nid cell id + @param[in] n_RNTI CRNTI + @param[out] out the scrambled bits +*/ + +void nr_pusch_codeword_scrambling(uint8_t *in, + uint16_t size, + uint32_t Nid, + uint32_t n_RNTI, + uint32_t* out); + uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 6b17eff585..4e46903ebf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -189,14 +189,14 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, - NR_DL_FRAME_PARMS* frame_parms) + NR_DL_FRAME_PARMS* frame_parms, + uint8_t harq_pid) { /////////////////////////parameters and variables declaration///////////////////////// /////////// unsigned int G,crc; - uint8_t harq_pid; NR_UL_UE_HARQ_t *harq_process; uint16_t nb_rb ; uint8_t nb_symb_sch ; @@ -221,7 +221,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, /////////// crc = 1; - harq_pid = 0; harq_process = ulsch->harq_processes[harq_pid]; nb_rb = harq_process->nb_rb; nb_symb_sch = harq_process->nb_symbols; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 80121b3d7f..de3bd2fe62 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -52,7 +52,7 @@ //#include "UTIL/LISTS/list.h" //#include "common/ran_context.h" -//#define DEBUG_DLSCHSIM +//#define DEBUG_ULSCHSIM PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; @@ -544,7 +544,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////////////////////// -#ifdef DEBUG_DLSCHSIM +#ifdef DEBUG_ULSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); #endif @@ -553,9 +553,13 @@ int main(int argc, char **argv) { //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); // generate signal + + /////////////////////////[adk] ULSCH coding///////////////////////// + /////////// + if (input_fd == NULL) { nr_dlsch_encoding(test_input, subframe, dlsch, frame_parms); - nr_ulsch_encoding(ulsch, frame_parms); + nr_ulsch_encoding(ulsch, frame_parms, harq_pid); } for (SNR = snr0; SNR < snr1; SNR += snr_step) { From 9947a6bccd3508ac75c50e360bcdf09a2590c7ff Mon Sep 17 00:00:00 2001 From: Ahmed Date: Fri, 1 Mar 2019 16:58:47 +0100 Subject: [PATCH 25/54] ULSCH decoding functionality at gNB side Added the following structs and enums in "defs_gNB.h" - NR_UL_gNB_HARQ_t - NR_gNB_ULSCH_t - NR_SCH_status_t added the following structs in "nfapi_nr_interface.h" - nfapi_nr_ul_config_ulsch_pdu - nfapi_nr_ul_config_ulsch_pdu_rel15_t - nfapi_nr_ul_srs_config_t - nr_pusch_freq_hopping_t added nr_ulsch.h for the ulsch decoding function declarations - free_gNB_ulsch - new_gNB_ulsch - nr_ulsch_decoding added nr_ulsch_decoding.c for the implementation of the ulsch decoding functions - free_gNB_ulsch - new_gNB_ulsch - nr_ulsch_decoding --- cmake_targets/CMakeLists.txt | 1 + .../nfapi/public_inc/nfapi_nr_interface.h | 41 ++ openair1/PHY/NR_TRANSPORT/nr_ulsch.h | 49 ++ openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 583 ++++++++++++++++++ openair1/PHY/defs_gNB.h | 195 +++++- 5 files changed, 860 insertions(+), 9 deletions(-) create mode 100644 openair1/PHY/NR_TRANSPORT/nr_ulsch.h create mode 100644 openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6ed11eebfa..79f057c29e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1275,6 +1275,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dlsch.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dlsch_tools.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dlsch_coding.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_decoding.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_tbs_tools.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sch_dmrs.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 94b7121998..b953a715ef 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -673,4 +673,45 @@ typedef struct { nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_nr_dl_config_request_t; + +typedef enum {nr_pusch_freq_hopping_disabled = 0 , + nr_pusch_freq_hopping_enabled = 1 + } nr_pusch_freq_hopping_t; + +typedef struct{ + uint8_t aperiodicSRS_ResourceTrigger; +} nfapi_nr_ul_srs_config_t; + +typedef struct { + uint8_t bandwidth_part_ind; + uint16_t number_rbs; + uint16_t start_rb; + uint8_t frame_offset; + uint16_t number_symbols; + uint16_t start_symbol; + nr_pusch_freq_hopping_t pusch_freq_hopping; + uint8_t mcs; + uint8_t Qm; + uint8_t ndi; + uint8_t rv; + uint8_t harq_process_nbr; + int8_t accumulated_delta_PUSCH; + int8_t absolute_delta_PUSCH; + uint8_t n_layers; + uint8_t tpmi; + uint8_t n_dmrs_cdm_groups; + uint8_t dmrs_ports[4]; + uint8_t n_front_load_symb; + nfapi_nr_ul_srs_config_t srs_config; + uint8_t csi_reportTriggerSize; + uint8_t maxCodeBlockGroupsPerTransportBlock; + uint8_t ptrs_dmrs_association_port; + uint8_t beta_offset_ind; +} nfapi_nr_ul_config_ulsch_pdu_rel15_t; + +typedef struct { + uint16_t rnti; + nfapi_nr_ul_config_ulsch_pdu_rel15_t ulsch_pdu_rel15; +} nfapi_nr_ul_config_ulsch_pdu; + #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h new file mode 100644 index 0000000000..77cc101679 --- /dev/null +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -0,0 +1,49 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_TRANSPORT/nr_ulsch.h +* \brief functions used for PUSCH/ULSCH physical and transport channels for gNB +* \author Ahmed Hussein +* \date 2019 +* \version 0.1 +* \company Fraunhofer IIS +* \email: ahmed.hussein@iis.fraunhofer.de +* \note +* \warning +*/ + +#include "PHY/defs_gNB.h" + +void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); + +NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); + +uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, + uint8_t UE_id, + short *ulsch_llr, + NR_DL_FRAME_PARMS *frame_parms, + uint32_t frame, + uint16_t nb_symb_sch, + uint8_t nr_tti_rx, + uint8_t harq_pid, + uint8_t is_crnti, + uint8_t llr8_flag); + diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c new file mode 100644 index 0000000000..1d72507de9 --- /dev/null +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -0,0 +1,583 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_TRANSPORT/nr_ulsch_decoding.c +* \brief Top-level routines for decoding LDPC (ULSCH) transport channels from 38.212, V15.4.0 2018-12 +* \author Ahmed Hussein +* \date 2019 +* \version 0.1 +* \company Fraunhofer IIS +* \email: ahmed.hussein@iis.fraunhofer.de +* \note +* \warning +*/ + + +// [from gNB coding] +#include "PHY/defs_gNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/lte_interleaver_inline.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" +#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" +#include "PHY/NR_TRANSPORT/nr_ulsch.h" +#include "PHY/NR_TRANSPORT/nr_dlsch.h" +#include "SCHED_NR/sched_nr.h" +#include "defs.h" +#include "common/utils/LOG/vcd_signal_dumper.h" +#include "common/utils/LOG/log.h" +#include +//#define DEBUG_ULSCH_DECODING + +#define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384 + +static uint64_t nb_total_decod =0; +static uint64_t nb_error_decod =0; + +//extern double cpuf; + +void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) +{ + + int i,r; + + if (ulsch) { + for (i=0; iharq_processes[i]) { + if (ulsch->harq_processes[i]->b) { + free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES); + ulsch->harq_processes[i]->b = NULL; + } + for (r=0; rharq_processes[i]->c[r],(8448)*sizeof(uint8_t)); + ulsch->harq_processes[i]->c[r] = NULL; + } + for (r=0; rharq_processes[i]->d[r]) { + free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t)); + ulsch->harq_processes[i]->d[r] = NULL; + } + } + for (r=0; r<(MAX_NUM_NR_ULSCH_SEGMENTS); r++) { + if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]){ + nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]); + ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; + } + } + free16(ulsch->harq_processes[i],sizeof(NR_UL_gNB_HARQ_t)); + ulsch->harq_processes[i] = NULL; + } + } + free16(ulsch,sizeof(NR_gNB_ULSCH_t)); + ulsch = NULL; + } +} + + +NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag) +{ + + NR_gNB_ULSCH_t *ulsch; + uint8_t exit_flag = 0,i,r; + unsigned char bw_scaling =1; + + switch (N_RB_UL) { + case 106: + bw_scaling =2; + break; + + default: + bw_scaling =1; + break; + } + + ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t)); + + if (ulsch) { + + memset(ulsch,0,sizeof(NR_gNB_ULSCH_t)); + + ulsch->max_ldpc_iterations = max_ldpc_iterations; + ulsch->Mlimit = 4; + + for (i=0; iharq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16(sizeof(NR_UL_gNB_HARQ_t)); + + if (ulsch->harq_processes[i]) { + + memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t)); + + ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + + if (ulsch->harq_processes[i]->b) + memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); + else + exit_flag=3; + + if (abstraction_flag == 0) { + for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); + + ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448*sizeof(uint8_t)); + + if (ulsch->harq_processes[i]->c[r]) + memset(ulsch->harq_processes[i]->c[r],0,8448*sizeof(uint8_t)); + else + exit_flag=2; + + ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16((68*384)*sizeof(int16_t)); + + if (ulsch->harq_processes[i]->d[r]) + memset(ulsch->harq_processes[i]->d[r],0,(68*384)*sizeof(int16_t)); + else + exit_flag=2; + } + } + } else { + exit_flag=1; + } + } + + if (exit_flag==0) + return(ulsch); + } + + printf("new_gNB_ulsch with size %zu: exit_flag = %u\n",sizeof(NR_UL_gNB_HARQ_t), exit_flag); + free_gNB_ulsch(ulsch); + + return(NULL); +} + + +uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, + uint8_t UE_id, + short *ulsch_llr, + NR_DL_FRAME_PARMS *frame_parms, + uint32_t frame, + uint16_t nb_symb_sch, + uint8_t nr_tti_rx, + uint8_t harq_pid, + uint8_t is_crnti, + uint8_t llr8_flag) +{ + + uint32_t A,E; + uint32_t G; + uint32_t ret,offset; + int32_t no_iteration_ldpc; + uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; + uint8_t crc_type; + int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + + + NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id][0]; + NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; + nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &harq_process->ulsch_pdu.ulsch_pdu_rel15; + + t_nrLDPC_dec_params decParams; + t_nrLDPC_dec_params* p_decParams = &decParams; + t_nrLDPC_time_stats procTime; + t_nrLDPC_time_stats* p_procTime = &procTime ; + t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; + + int16_t z [68*384]; + int8_t l [68*384]; + int16_t inv_d [68*384]; + uint8_t kb, kc; + uint8_t Ilbrm = 0; + uint32_t Tbslbrm = 950984; + uint16_t nb_rb = 30; //to update + uint8_t nb_re_dmrs = 6; + uint16_t length_dmrs = 1; + + uint32_t i,j; + + __m128i *pv = (__m128i*)&z; + __m128i *pl = (__m128i*)&l; + + + if (!ulsch_llr) { + printf("ulsch_decoding.c: NULL ulsch_llr pointer\n"); + return(ulsch->max_ldpc_iterations); + } + + if (!harq_process) { + printf("ulsch_decoding.c: NULL harq_process pointer\n"); + return(ulsch->max_ldpc_iterations); + } + + if (!frame_parms) { + printf("ulsch_decoding.c: NULL frame_parms pointer\n"); + return(ulsch->max_ldpc_iterations); + } + + nb_rb = nfapi_ulsch_pdu_rel15->number_rbs; + + // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; + + harq_process->TBS = nr_compute_tbs(nfapi_ulsch_pdu_rel15->mcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, nfapi_ulsch_pdu_rel15->n_layers); + + A = harq_process->TBS; + ret = ulsch->max_ldpc_iterations; + + harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, nfapi_ulsch_pdu_rel15->Qm,nfapi_ulsch_pdu_rel15->n_layers); + G = harq_process->G; + + LOG_I(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, nfapi_ulsch_pdu_rel15->mcs, nfapi_ulsch_pdu_rel15->n_layers, nb_symb_sch,nb_rb); + + if (harq_process->round == 0) { + // This is a new packet, so compute quantities regarding segmentation + harq_process->B = A+24; + + // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F) + nr_segmentation(NULL, + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, // [hna] Z is Zc + &harq_process->F); + + p_decParams->Z = harq_process->Z; + +#ifdef DEBUG_ULSCH_DECODING + printf("ulsch decoding nr segmentation Z %d\n", p_decParams->Z); + if (!frame%100) + printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); +#endif + } + + kb = harq_process->K/harq_process->Z; + + if ( kb==22) { + p_decParams->BG = 1; + p_decParams->R = 13; + kc = 68; + } else { + p_decParams->BG = 2; + p_decParams->R = 13; + kc = 52; + } + + p_decParams->numMaxIter = ulsch->max_ldpc_iterations; + Kr = p_decParams->Z*kb; + p_decParams->outMode= 0; + + err_flag = 0; + r_offset = 0; + + unsigned char bw_scaling =1; + + switch (frame_parms->N_RB_UL) { + + case 106: + bw_scaling =2; + break; + + default: + bw_scaling =1; + break; + } + + if (harq_process->C > MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling) { + LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling); + return((1+ulsch->max_ldpc_iterations)); + } +#ifdef DEBUG_ULSCH_DECODING + printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); +#endif + + opp_enabled=1; + + Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" + Kr_bytes = Kr>>3; + + K_bytes_F = Kr_bytes-(harq_process->F>>3); + + Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, nfapi_ulsch_pdu_rel15->n_layers); + + for (r=0; rC; r++) { + + E = nr_get_E(G, harq_process->C, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers, r); + +#if gNB_TIMING_TRACE + start_meas(ulsch_deinterleaving_stats); +#endif + + //////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////// nr_deinterleaving_ldpc /////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// + + //////////////////////////// ulsch_llr =====> harq_process->e ////////////////////////////// + + nr_deinterleaving_ldpc(E, + nfapi_ulsch_pdu_rel15->Qm, + harq_process->e[r], + ulsch_llr+r_offset); + + //for (int i =0; i<16; i++) + // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); + +#if gNB_TIMING_TRACE + stop_meas(ulsch_deinterleaving_stats); +#endif + +#if gNB_TIMING_TRACE + start_meas(ulsch_rate_unmatching_stats); +#endif + +#ifdef DEBUG_ULSCH_DECODING + LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", + harq_pid,r, G, + Kr*3, + harq_process->TBS, + nfapi_ulsch_pdu_rel15->Qm, + nfapi_ulsch_pdu_rel15->number_rbs, + nfapi_ulsch_pdu_rel15->n_layers, + nfapi_ulsch_pdu_rel15->rv, + harq_process->round); +#endif + ////////////////////////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////// nr_rate_matching_ldpc_rx //////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// + + ///////////////////////// harq_process->e =====> harq_process->d ///////////////////////// + + if (nr_rate_matching_ldpc_rx(Ilbrm, + Tbslbrm, + p_decParams->BG, + p_decParams->Z, + harq_process->d[r], + harq_process->e[r], + harq_process->C, + nfapi_ulsch_pdu_rel15->rv, + (harq_process->round==0)?1:0, + E)==-1) { +#if gNB_TIMING_TRACE + stop_meas(ulsch_rate_unmatching_stats); +#endif + LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n"); + return(ulsch->max_ldpc_iterations); + } else { +#if gNB_TIMING_TRACE + stop_meas(ulsch_rate_unmatching_stats); +#endif + } + + r_offset += E; + +#ifdef DEBUG_ULSCH_DECODING + if (r==0) { + write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0); + write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0); + } + + printf("decoder input(segment %d) :",r); + int i; + for (i=0;i<(3*8*Kr_bytes)+12;i++) + printf("%d : %d\n",i,harq_process->d[r][i]); + printf("\n"); +#endif + + + // printf("Clearing c, %p\n",harq_process->c[r]); + memset(harq_process->c[r],0,Kr_bytes); + + // printf("done\n"); + if (harq_process->C == 1) + crc_type = CRC24_A; + else + crc_type = CRC24_B; + + if (err_flag == 0) { + +#if gNB_TIMING_TRACE + start_meas(ulsch_turbo_decoding_stats); +#endif + + for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++) { + inv_d[cnt] = (1)*harq_process->d[r][cnt]; + } + + memset(pv,0,2*harq_process->Z*sizeof(int16_t)); + memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); + + for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++) { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } + + for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } + + for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) { + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + } + + ////////////////////////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////// nrLDPC_decoder ///////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////// pl =====> llrProcBuf ////////////////////////////////// + + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, + p_nrLDPC_procBuf[r], + p_procTime); + + if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { + printf("CRC OK\n"); + ret = 2; + } else { + printf("CRC NOK\n"); + ret = 1+ulsch->max_ldpc_iterations; + } + + nb_total_decod++; + if (no_iteration_ldpc > ulsch->max_ldpc_iterations){ + nb_error_decod++; + } + + ret=no_iteration_ldpc; + + for (int m=0; m < Kr>>3; m ++) { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } + +#ifdef DEBUG_ULSCH_DECODING + //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); + for (int k=0;k>3;k++) + printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); + printf("no_iterations_ldpc %d (ret %d)\n",no_iteration_ldpc,ret); + //write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4); +#endif + +#if gNB_TIMING_TRACE + stop_meas(ulsch_turbo_decoding_stats); +#endif + } + + if ((err_flag == 0) && (ret>=(1+ulsch->max_ldpc_iterations))) { + // a Code segment is in error so break; + LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); + err_flag = 1; + } + ////////////////////////////////////////////////////////////////////////////////////////// + } + + int32_t frame_rx_prev = frame; + int32_t tti_rx_prev = nr_tti_rx - 1; + if (tti_rx_prev < 0) { + frame_rx_prev--; + tti_rx_prev += 10*frame_parms->ttis_per_subframe; + } + frame_rx_prev = frame_rx_prev%1024; + + if (err_flag == 1) { + +#if gNB_DEBUG_TRACE + LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", + phy_vars_gNB->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round); +#endif + + // harq_process->harq_ack.ack = 0; + // harq_process->harq_ack.harq_id = harq_pid; + // harq_process->harq_ack.send_harq_status = 1; + // harq_process->errors[harq_process->round]++; + harq_process->round++; + + if (harq_process->round >= ulsch->Mlimit) { + harq_process->status = SCH_IDLE; + harq_process->round = 0; + harq_process->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + } + + if(is_crnti) { + LOG_D(PHY,"[gNB %d] ULSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", + phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,ulsch->Mlimit,harq_process->TBS); + } + + harq_process->handled = 1; + return((1+ulsch->max_ldpc_iterations)); + + } else { + +#if gNB_DEBUG_TRACE + LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", + phy_vars_gNB->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); +#endif + + harq_process->status = SCH_IDLE; + harq_process->round = 0; + // harq_process->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + // harq_process->harq_ack.ack = 1; + // harq_process->harq_ack.harq_id = harq_pid; + // harq_process->harq_ack.send_harq_status = 1; + + if(is_crnti) + { + LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS); + } + } + + // Reassembly of Transport block here + offset = 0; + Kr = harq_process->K; + Kr_bytes = Kr>>3; + + for (r=0; rC; r++) { + + memcpy(harq_process->b+offset, + harq_process->c[r], + Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); + + offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); + +#ifdef DEBUG_ULSCH_DECODING + printf("Segment %d : Kr= %d bytes\n",r,Kr_bytes); + printf("copied %d bytes to b sequence (harq_pid %d)\n", + (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)),harq_pid); + printf("b[0] = %x,c[%d] = %x\n", + harq_process->b[offset], + harq_process->F>>3, + harq_process->c[r]); +#endif + + } + + ulsch->last_iteration_cnt = ret; + + return(ret); +} \ No newline at end of file diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 10b99eb113..24be9688dc 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -38,6 +38,10 @@ #include "CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" #define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB @@ -72,6 +76,7 @@ typedef struct { uint64_t dci_pdu[2]; } NR_gNB_DCI_ALLOC_t; + typedef struct { uint8_t num_dci; uint8_t num_pdsch_rnti; @@ -79,6 +84,14 @@ typedef struct { } NR_gNB_PDCCH; +typedef enum { + NR_SCH_IDLE, + NR_ACTIVE, + NR_CBA_ACTIVE, + NR_DISABLED +} NR_SCH_status_t; + + typedef struct { /// Nfapi DLSCH PDU nfapi_nr_dl_config_dlsch_pdu dlsch_pdu; @@ -114,7 +127,6 @@ typedef struct { typedef struct { - /// Pointers to 16 HARQ processes for the DLSCH NR_DL_gNB_HARQ_t *harq_processes[NR_MAX_NB_HARQ_PROCESSES]; /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding) @@ -160,6 +172,170 @@ typedef struct { } NR_gNB_DLSCH_t; +typedef struct { + /// Nfapi ULSCH PDU + nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; + /// Frame where current HARQ round was sent + uint32_t frame; + /// Subframe where current HARQ round was sent + uint32_t subframe; + /// Index of current HARQ round for this DLSCH + uint8_t round; + /// Last TPC command + uint8_t TPC; + /// MIMO mode for this DLSCH + MIMO_mode_t mimo_mode; + /// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK) + uint8_t dci_alloc; + /// Flag indicating that this ULSCH has been allocated by a RAR (otherwise it is a retransmission based on PHICH NAK or DCI) + uint8_t rar_alloc; + /// Status Flag indicating for this ULSCH (idle,active,disabled) + NR_SCH_status_t status; + /// Subframe scheduling indicator (i.e. Transmission opportunity indicator) + uint8_t subframe_scheduling_flag; + /// Subframe cba scheduling indicator (i.e. CBA Transmission opportunity indicator) + uint8_t subframe_cba_scheduling_flag; + /// PHICH active flag + uint8_t phich_active; + /// PHICH ACK + uint8_t phich_ACK; + /// First Allocated RB - previous scheduling. This is needed for PHICH generation which is done after a new scheduling + uint16_t previous_first_rb; + /// Flag to indicate that the UL configuration has been handled. Used to remove a stale ULSCH when frame wraps around + uint8_t handled; + /// Flag to indicate that this ULSCH is for calibration information sent from UE (i.e. no MAC SDU to pass up) + // int calibration_flag; + /// delta_TF for power control + int32_t delta_TF; + + + /////////////////////// ulsch decoding /////////////////////// + /// Transport block size (This is A from 38.212 V15.4.0 section 5.1) + uint32_t TBS; + /// Pointer to the payload (38.212 V15.4.0 section 5.1) + uint8_t *b; + /// The payload + CRC (24 bits) in bits (38.212 V15.4.0 section 5.1) + uint32_t B; + /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) + uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// Number of bits in each code block (38.212 V15.4.0 section 5.2.2) + uint32_t K; + /// Number of "Filler" bits added in the code block segmentation (38.212 V15.4.0 section 5.2.2) + uint32_t F; + /// Number of code blocks after code block segmentation (38.212 V15.4.0 section 5.2.2) + uint32_t C; + /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) + int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC processing buffer + t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC lifting size (38.212 V15.4.0 table 5.3.2-1) + uint32_t Z; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; + /// Number of bits in each code block after rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + uint32_t E; + /// Number of soft channel bits after code block concatenation (38.212 V15.4.0 section 5.5) + uint32_t G; + ////////////////////////////////////////////////////////////// + + + /////////////////////////// DMRS ///////////////////////////// + /// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) + uint8_t n_DMRS; + /// n_DMRS 2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1) + uint8_t n_DMRS2; + /// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) - previous scheduling + /// This is needed for PHICH generation which + /// is done after a new scheduling + uint8_t previous_n_DMRS; + ////////////////////////////////////////////////////////////// + + + ///////////////////// UCI multiplexing /////////////////////// + /// CQI CRC status + uint8_t cqi_crc_status; + /// Pointer to CQI data + uint8_t o[MAX_CQI_BYTES]; + /// Format of CQI data + UCI_format_t uci_format; + /// Length of CQI data under RI=1 assumption(bits) + uint8_t Or1; + /// Length of CQI data under RI=2 assumption(bits) + uint8_t Or2; + /// Rank information + uint8_t o_RI[2]; + /// Length of rank information (bits) + uint8_t O_RI; + /// Pointer to ACK + uint8_t o_ACK[4]; + /// Length of ACK information (bits) + uint8_t O_ACK; + /// The value of DAI in DCI format 0 + uint8_t V_UL_DAI; + /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) + int8_t q[MAX_CQI_PAYLOAD]; + /// number of coded CQI bits after interleaving + uint8_t o_RCC; + /// coded and interleaved CQI bits + int8_t o_w[(MAX_CQI_BITS+8)*3]; + /// coded CQI bits + int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; + /// coded ACK bits + int16_t q_ACK[MAX_ACK_PAYLOAD]; + /// coded RI bits + int16_t q_RI[MAX_RI_PAYLOAD]; + /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled + uint8_t h[MAX_NUM_CHANNEL_BITS]; + /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; + ////////////////////////////////////////////////////////////// +} NR_UL_gNB_HARQ_t; + + +typedef struct { + /// Pointers to 16 HARQ processes for the ULSCH + NR_UL_gNB_HARQ_t *harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES]; + /// Current HARQ process id + int harq_process_id[NR_MAX_SLOTS_PER_FRAME]; + /// HARQ process mask, indicates which processes are currently active + uint16_t harq_mask; + /// ACK/NAK Bundling flag + uint8_t bundling; + /// beta_offset_cqi times 8 + uint16_t beta_offset_cqi_times8; + /// beta_offset_ri times 8 + uint16_t beta_offset_ri_times8; + /// beta_offset_harqack times 8 + uint16_t beta_offset_harqack_times8; + /// Flag to indicate that gNB awaits UE Msg3 + uint8_t Msg3_active; + /// Flag to indicate that gNB should decode UE Msg3 + uint8_t Msg3_flag; + /// Subframe for Msg3 + uint8_t Msg3_subframe; + /// Frame for Msg3 + uint32_t Msg3_frame; + /// Allocated RNTI for this ULSCH + uint16_t rnti; + /// RNTI type + uint8_t rnti_type; + /// cyclic shift for DM RS + uint8_t cyclicShift; + /// for cooperative communication + uint8_t cooperation_flag; + /// Maximum number of HARQ rounds + uint8_t Mlimit; + /// Maximum number of LDPC iterations + uint8_t max_ldpc_iterations; + /// number of iterations used in last LDPC decoding + uint8_t last_iteration_cnt; + /// num active cba group + uint8_t num_active_cba_groups; + /// num active cba group + uint16_t cba_rnti[NUM_MAX_CBA_GROUP]; +} NR_gNB_ULSCH_t; + + typedef struct { /// \brief Pointers (dynamic) to the received data in the time domain. /// - first index: rx antenna [0..nb_antennas_rx[ @@ -394,17 +570,18 @@ typedef struct PHY_VARS_gNB_s { LTE_eNB_PHICH phich_vars[2]; NR_gNB_COMMON common_vars; - LTE_eNB_UCI uci_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_SRS srs_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_PUSCH *pusch_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_PRACH prach_vars; - NR_gNB_DLSCH_t *dlsch[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams - LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA + LTE_eNB_UCI uci_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_SRS srs_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_PUSCH *pusch_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_PRACH prach_vars; + NR_gNB_DLSCH_t *dlsch[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams + NR_gNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1][2]; // [Nusers times + number of RA][2 codewords], index 0 in [NUMBER_OF_UE_MAX+1] is for RA + // LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA NR_gNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p; NR_gNB_DLSCH_t *dlsch_MCH; NR_gNB_DLSCH_t *dlsch_PCH; - LTE_eNB_UE_stats UE_stats[NUMBER_OF_UE_MAX]; - LTE_eNB_UE_stats *UE_stats_ptr[NUMBER_OF_UE_MAX]; + LTE_eNB_UE_stats UE_stats[NUMBER_OF_UE_MAX]; + LTE_eNB_UE_stats *UE_stats_ptr[NUMBER_OF_UE_MAX]; uint8_t pbch_configured; uint8_t pbch_pdu[4]; //PBCH_PDU_SIZE From e5fd0fcd00328c50b10fbf118500f039857f9c7c Mon Sep 17 00:00:00 2001 From: Ahmed Date: Fri, 1 Mar 2019 17:42:06 +0100 Subject: [PATCH 26/54] added the ulsch decoding functions to ulschsim.c now ulschsim.c is uplink only with no downlink decoding functions or variables --- openair1/PHY/INIT/nr_init.c | 69 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 1207 +++++++++++++------------ 2 files changed, 646 insertions(+), 630 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 46e3010972..1a2382b526 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -33,6 +33,7 @@ #include "assertions.h" #include +#include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/LTE_REFSIG/lte_refsig.h" #include "SCHED_NR/fapi_nr_l1.h" @@ -77,12 +78,14 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char abstraction_flag) { // shortcuts NR_DL_FRAME_PARMS *const fp = &gNB->frame_parms; - nfapi_nr_config_request_t *cfg = &gNB->gNB_config; + nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_gNB_COMMON *const common_vars = &gNB->common_vars; - LTE_eNB_PUSCH **const pusch_vars = gNB->pusch_vars; - LTE_eNB_SRS *const srs_vars = gNB->srs_vars; - LTE_eNB_PRACH *const prach_vars = &gNB->prach_vars; + LTE_eNB_PUSCH **const pusch_vars = gNB->pusch_vars; + LTE_eNB_SRS *const srs_vars = gNB->srs_vars; + LTE_eNB_PRACH *const prach_vars = &gNB->prach_vars; + int i, UE_id; + LOG_I(PHY,"[gNB %d] %s() About to wait for gNB to be configured\n", gNB->Mod_id, __FUNCTION__); gNB->total_dlsch_bitrate = 0; gNB->total_transmitted_bits = 0; @@ -110,7 +113,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, init_dfts(); // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); - // Polar encoder init for PBCH //PDCCH DMRS init gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **)); uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; @@ -148,6 +150,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, } nr_init_pdsch_dmrs(gNB, cfg->sch_config.physical_cell_id.value); + /// Transport init necessary for NR synchro init_nr_transport(gNB); @@ -167,14 +170,15 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, gNB->first_run_I0_measurements = 1; ///This flag used to be static. With multiple gNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here. common_vars->rxdata = (int32_t **)NULL; - common_vars->txdataF = (int32_t **)malloc16(15*sizeof(int32_t *)); - common_vars->rxdataF = (int32_t **)malloc16(64*sizeof(int32_t *)); + common_vars->txdataF = (int32_t **)malloc16(15*sizeof(int32_t*)); + common_vars->rxdataF = (int32_t **)malloc16(64*sizeof(int32_t*)); - for (i=0; i<15; i++) { - common_vars->txdataF[i] = (int32_t *)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t) ); - LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n", - i,common_vars->txdataF[i], - fp->samples_per_frame_wCP*sizeof(int32_t)); + for (i=0;i<15;i++){ + common_vars->txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t) ); // [hna] samples_per_frame without CP + + LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n", + i,common_vars->txdataF[i], + fp->samples_per_frame_wCP*sizeof(int32_t)); } // Channel estimates for SRS @@ -417,6 +421,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { gNB_config->rf_config.ul_carrier_bandwidth.value, gNB_config->sch_config.physical_cell_id.value, fp->dl_CarrierFreq ); + nr_init_frame_parms(gNB_config, fp); if (RC.gNB[Mod_id][CC_id]->configured == 1) { @@ -436,6 +441,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { LOG_I(PHY, "Initialise nr transport\n"); for (i=0; idlsch[i][j]->rnti=0; - LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,gNB->dlsch[i][j], gNB->dlsch[i][j]->rnti); + gNB->dlsch[i][j]->rnti=0; + LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,gNB->dlsch[i][j], gNB->dlsch[i][j]->rnti); }*/ + + ///////////////////////// Initializing gNB ULSCH ///////////////////////// + LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); + + // ULSCH for RA + if(i==0) { + gNB->ulsch[i][j] = new_gNB_ulsch(5, fp->N_RB_UL, 0); + + if (!gNB->ulsch[i][j]) { + LOG_E(PHY,"Can't get gNB ulsch structures\n"); + exit(-1); + } + } + + // ULSCH for data + gNB->ulsch[i+1][j] = new_gNB_ulsch(5, fp->N_RB_UL, 0); + + if (!gNB->ulsch[i+1][j]) { + LOG_E(PHY,"Can't get gNB ulsch structures\n"); + exit(-1); + } + ////////////////////////////////////////////////////////////////////////// } - //LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); - //gNB->ulsch[1+i] = new_gNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); - /*if (!gNB->ulsch[1+i]) { - LOG_E(PHY,"Can't get gNB ulsch structures\n"); - exit(-1); - }*/ // this is the transmission mode for the signalling channels // this will be overwritten with the real transmission mode by the RRC once the UE is connected //gNB->transmission_mode[i] = fp->nb_antenna_ports_gNB==1 ? 1 : 2; } - // ULSCH for RA - //gNB->ulsch[0] = new_gNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0); - /*if (!gNB->ulsch[0]) { - LOG_E(PHY,"Can't get gNB ulsch structures\n"); - exit(-1); - }*/ gNB->dlsch_SI = new_gNB_dlsch(1,8,NSOFT, 0, fp, cfg); LOG_D(PHY,"gNB %d.%d : SI %p\n",gNB->Mod_id,gNB->CC_id,gNB->dlsch_SI); gNB->dlsch_ra = new_gNB_dlsch(1,8,NSOFT, 0, fp, cfg); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index de3bd2fe62..9b0c3562af 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -1,23 +1,23 @@ /* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ +* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The OpenAirInterface Software Alliance licenses this file to You under +* the OAI Public License, Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.openairinterface.org/?page_id=698 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*------------------------------------------------------------------------------- +* For more information about the OpenAirInterface (OAI) Software Alliance: +* contact@openairinterface.org +*/ #include #include @@ -32,6 +32,7 @@ #include "SIMULATION/TOOLS/sim.h" #include "SIMULATION/RF/rf.h" + #include "PHY/types.h" #include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" @@ -43,6 +44,7 @@ #include "PHY/MODULATION/modulation_UE.h" #include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" +#include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED_NR/sched_nr.h" @@ -63,41 +65,40 @@ double cpuf; // dummy functions int nfapi_mode = 0; int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { - return (0); + return (0); } int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { - return (0); + return (0); } int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { - return (0); + return (0); } int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { - return (0); + return (0); } int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) { - return (0); + return (0); } uint32_t from_nrarfcn(int nr_bandP, uint32_t dl_earfcn) { - return (0); + return (0); } int32_t get_uldl_offset(int eutra_bandP) { - return (0); + return (0); } NR_IF_Module_t * NR_IF_Module_init(int Mod_id) { - return (NULL); + return (NULL); } -void exit_function(const char *file, const char *function, const int line, - const char *s) { - const char *msg = s == NULL ? "no comment" : s; - printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); - exit(-1); +void exit_function(const char *file, const char *function, const int line, const char *s) { + const char *msg = s == NULL ? "no comment" : s; + printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); + exit(-1); } // needed for some functions @@ -105,631 +106,631 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; uint16_t n_rnti = 0x1234; char quantize(double D, double x, unsigned char B) { - double qxd; - short maxlev; - qxd = floor(x / D); - maxlev = 1 << (B - 1); //(char)(pow(2,B-1)); + double qxd; + short maxlev; + qxd = floor(x / D); + maxlev = 1 << (B - 1); //(char)(pow(2,B-1)); - //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev); + //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev); - if (qxd <= -maxlev) - qxd = -maxlev; - else if (qxd >= maxlev) - qxd = maxlev - 1; + if (qxd <= -maxlev) + qxd = -maxlev; + else if (qxd >= maxlev) + qxd = maxlev - 1; - return ((char) qxd); + return ((char) qxd); } int main(int argc, char **argv) { - char c; - int i,sf; //,j,l,aa; - double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; - double snr_step = 0.1; - uint8_t snr1set = 0; - int **txdata; - double **s_re, **s_im, **r_re, **r_im; - // int sync_pos, sync_pos_slot; - // FILE *rx_frame_file; - FILE *output_fd = NULL; - uint8_t write_output_file = 0; - // int subframe_offset; - // char fname[40], vname[40]; - int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; - uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; - uint16_t Nid_cell = 0; - channel_desc_t *gNB2UE; - uint8_t extended_prefix_flag = 0; - int8_t interf1 = -21, interf2 = -21; - FILE *input_fd = NULL, *pbch_file_fd = NULL; - //char input_val_str[50],input_val_str2[50]; - //uint16_t NB_RB=25; - SCM_t channel_model = AWGN; //Rayleigh1_anticorr; - uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; - unsigned char frame_type = 0; - unsigned char pbch_phase = 0; - int frame = 0, subframe = 0; - int frame_length_complex_samples; - //int frame_length_complex_samples_no_prefix; - NR_DL_FRAME_PARMS *frame_parms; - //nfapi_nr_config_request_t *gNB_config; - uint8_t Kmimo = 0; - uint32_t Nsoft = 0; - double sigma; - unsigned char qbits = 8; - int ret; - //int run_initial_sync=0; - int loglvl = OAILOG_WARNING; - float target_error_rate = 0.01; - - uint16_t nb_symb_sch = 12; - uint16_t nb_rb = 50; - uint8_t Imcs = 9; - - cpuf = get_cpu_freq_GHz(); - - if (load_configmodule(argc, argv) == 0) { - exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); - } - - //logInit(); - randominit(0); - - while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { - switch (c) { - case 'f': - write_output_file = 1; - output_fd = fopen(optarg, "w"); - - if (output_fd == NULL) { - printf("Error opening %s\n", optarg); - exit(-1); - } - - break; - - case 'd': - frame_type = 1; - break; - - case 'g': - switch ((char) *optarg) { - case 'A': - channel_model = SCM_A; - break; - - case 'B': - channel_model = SCM_B; - break; - - case 'C': - channel_model = SCM_C; - break; - - case 'D': - channel_model = SCM_D; - break; - - case 'E': - channel_model = EPA; - break; - - case 'F': - channel_model = EVA; - break; - - case 'G': - channel_model = ETU; - break; - - default: - msg("Unsupported channel model!\n"); - exit(-1); - } - - break; - - case 'i': - interf1 = atoi(optarg); - break; - - case 'j': - interf2 = atoi(optarg); - break; - - case 'n': - n_trials = atoi(optarg); - break; - - case 's': - snr0 = atof(optarg); - msg("Setting SNR0 to %f\n", snr0); - break; - - case 'S': - snr1 = atof(optarg); - snr1set = 1; - msg("Setting SNR1 to %f\n", snr1); - break; - - case 'p': - extended_prefix_flag = 1; - break; - - /* - case 'r': - ricean_factor = pow(10,-.1*atof(optarg)); - if (ricean_factor>1) { - printf("Ricean factor must be between 0 and 1\n"); - exit(-1); - } - break; - */ - - case 'y': - n_tx = atoi(optarg); - - if ((n_tx == 0) || (n_tx > 2)) { - msg("Unsupported number of tx antennas %d\n", n_tx); - exit(-1); - } - - break; - - case 'z': - n_rx = atoi(optarg); - - if ((n_rx == 0) || (n_rx > 2)) { - msg("Unsupported number of rx antennas %d\n", n_rx); - exit(-1); - } - - break; - - case 'N': - Nid_cell = atoi(optarg); - break; - - case 'R': - N_RB_DL = atoi(optarg); - N_RB_UL = N_RB_DL; - break; - - case 'F': - input_fd = fopen(optarg, "r"); - - if (input_fd == NULL) { - printf("Problem with filename %s\n", optarg); - exit(-1); - } - - break; - - case 'P': - pbch_phase = atoi(optarg); - - if (pbch_phase > 3) - printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase); - - break; - - case 'm': - Imcs = atoi(optarg); - break; - - case 'l': - nb_symb_sch = atoi(optarg); - break; - - case 'r': - nb_rb = atoi(optarg); - break; - - case 'x': - transmission_mode = atoi(optarg); - break; - - default: - case 'h': - printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); - printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); - printf("-n Number of frames to simulate\n"); - printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); - printf("-S Ending SNR, runs from SNR0 to SNR1\n"); - printf("-t Delay spread for multipath channel\n"); - printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); - printf("-x Transmission mode (1,2,6 for the moment)\n"); - printf("-y Number of TX antennas used in eNB\n"); - printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); - printf("-N Nid_cell\n"); - printf("-R N_RB_DL\n"); - printf("-O oversampling factor (1,2,4,8,16)\n"); - printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); - printf("-F Input filename (.txt format) for RX conformance testing\n"); - exit(-1); - break; - } - } - - logInit(); - set_glog(loglvl); - T_stdout = 1; - - if (snr1set == 0) - snr1 = snr0 + 10; - - gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, - 61.44e6, //N_RB2sampling_rate(N_RB_DL), - 40e6, //N_RB2channel_bandwidth(N_RB_DL), - 0, 0, 0); - - if (gNB2UE == NULL) { - msg("Problem generating channel model. Exiting.\n"); - exit(-1); - } - - RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **)); - RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); - RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); - gNB = RC.gNB[0][0]; - //gNB_config = &gNB->gNB_config; - frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) - frame_parms->nb_antennas_tx = n_tx; - frame_parms->nb_antennas_rx = n_rx; - frame_parms->N_RB_DL = N_RB_DL; - frame_parms->N_RB_UL = N_RB_UL; - frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; - crcTableInit(); - nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); - phy_init_nr_gNB(gNB, 0, 0); - //init_eNB_afterRU(); - frame_length_complex_samples = frame_parms->samples_per_subframe; - //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; - s_re = malloc(2 * sizeof(double *)); - s_im = malloc(2 * sizeof(double *)); - r_re = malloc(2 * sizeof(double *)); - r_im = malloc(2 * sizeof(double *)); - txdata = malloc(2 * sizeof(int *)); - - for (i = 0; i < 2; i++) { - s_re[i] = malloc(frame_length_complex_samples * sizeof(double)); - bzero(s_re[i], frame_length_complex_samples * sizeof(double)); - s_im[i] = malloc(frame_length_complex_samples * sizeof(double)); - bzero(s_im[i], frame_length_complex_samples * sizeof(double)); - r_re[i] = malloc(frame_length_complex_samples * sizeof(double)); - bzero(r_re[i], frame_length_complex_samples * sizeof(double)); - r_im[i] = malloc(frame_length_complex_samples * sizeof(double)); - bzero(r_im[i], frame_length_complex_samples * sizeof(double)); - txdata[i] = malloc(frame_length_complex_samples * sizeof(int)); - bzero(r_re[i], frame_length_complex_samples * sizeof(int)); - } - - if (pbch_file_fd != NULL) { - load_pbch_desc(pbch_file_fd); - } - - /* for (int k=0; k<2; k++) { - // Create transport channel structures for 2 transport blocks (MIMO) - for (i=0; i<2; i++) { - gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); - - if (!gNB->dlsch[k][i]) { - printf("Can't get eNB dlsch structures\n"); - exit(-1); - } - gNB->dlsch[k][i]->Nsoft = 10; - gNB->dlsch[k][i]->rnti = n_rnti+k; - } - }*/ - //configure UE - UE = malloc(sizeof(PHY_VARS_NR_UE)); - memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); - - //phy_init_nr_top(frame_parms); - if (init_nr_ue_signal(UE, 1, 0) != 0) { - printf("Error at UE NR initialisation\n"); - exit(-1); - } - - //nr_init_frame_parms_ue(&UE->frame_parms); - //init_nr_ue_transport(UE, 0); - for (sf = 0; sf < 2; sf++) { - for (i = 0; i < 2; i++) { - UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL, - 0); - - if (!UE->dlsch[sf][0][i]) { - printf("Can't get ue dlsch structures\n"); - exit(-1); - } - - UE->ulsch[sf][0][i] = new_nr_ue_ulsch(N_RB_UL, 8, 0); - - if (!UE->ulsch[sf][0][i]) { - printf("Can't get ue ulsch structures\n"); - exit(-1); - } - - UE->dlsch[sf][0][i]->rnti = n_rnti; - } - } - - UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); - UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); - unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; - NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; - nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; - - NR_UE_ULSCH_t *ulsch = UE->ulsch[0][0][0]; - - //time_stats_t *rm_stats, *te_stats, *i_stats; - uint8_t is_crnti = 0, llr8_flag = 0; - unsigned int TBS = 8424; - unsigned int available_bits; - uint8_t nb_re_dmrs = 6; - uint16_t length_dmrs = 1; - unsigned char mod_order; - uint8_t Nl = 1; - uint8_t rvidx = 0; - dlsch->rnti = 1; - ulsch->nb_re_dmrs = nb_re_dmrs; //[adk] A HOT FIX until cearting nfapi_nr_ul_config_ulsch_pdu_rel15_t - /*dlsch->harq_processes[0]->mcs = Imcs; - dlsch->harq_processes[0]->rvidx = rvidx;*/ - //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], - // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); - mod_order = nr_get_Qm(Imcs, 1); - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); - TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, Nl); - printf("available bits %d TBS %d mod_order %d\n", available_bits, TBS, mod_order); - //dlsch->harq_ids[subframe]= 0; - rel15->n_prb = nb_rb; - rel15->nb_symbols = nb_symb_sch; - rel15->modulation_order = mod_order; - rel15->nb_layers = Nl; - rel15->nb_re_dmrs = nb_re_dmrs; - rel15->transport_block_size = TBS; - double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); - short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); - short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); - unsigned int errors_bit_uncoded = 0; - unsigned char *estimated_output; - unsigned char *estimated_output_bit; - unsigned char *test_input_bit; - unsigned int errors_bit = 0; - - test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - - estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - - estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - - NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; - NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; - harq_process->mcs = Imcs; - harq_process->Nl = Nl; - harq_process->nb_rb = nb_rb; - harq_process->Qm = mod_order; - harq_process->rvidx = rvidx; - printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); - unsigned char *test_input; - test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); - - for (i = 0; i < TBS / 8; i++) - test_input[i] = (unsigned char) rand(); - - estimated_output = harq_process->b; - - - /////////////////////////[adk] preparing UL harq_process parameters///////////////////////// - /////////// - NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch->harq_processes[harq_pid]; - - if (harq_process_ul_ue){ - - harq_process_ul_ue->mcs = Imcs; - harq_process_ul_ue->Nl = Nl; - harq_process_ul_ue->nb_rb = nb_rb; - harq_process_ul_ue->nb_symbols = nb_symb_sch; - harq_process_ul_ue->rvidx = rvidx; - harq_process_ul_ue->TBS = TBS; - harq_process_ul_ue->a = &test_input[0]; - - } - /////////// - //////////////////////////////////////////////////////////////////////////////////////////// + char c; + int i,sf; //,j,l,aa; + double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; + double snr_step = 0.1; + uint8_t snr1set = 0; + int **txdata; + double **s_re, **s_im, **r_re, **r_im; + // int sync_pos, sync_pos_slot; + // FILE *rx_frame_file; + FILE *output_fd = NULL; + uint8_t write_output_file = 0; + // int subframe_offset; + // char fname[40], vname[40]; + int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; + uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; + uint16_t Nid_cell = 0; + channel_desc_t *gNB2UE; + uint8_t extended_prefix_flag = 0; + int8_t interf1 = -21, interf2 = -21; + FILE *input_fd = NULL, *pbch_file_fd = NULL; + //char input_val_str[50],input_val_str2[50]; + //uint16_t NB_RB=25; + SCM_t channel_model = AWGN; //Rayleigh1_anticorr; + uint8_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; + unsigned char frame_type = 0; + unsigned char pbch_phase = 0; + int frame = 0, subframe = 0; + int frame_length_complex_samples; + //int frame_length_complex_samples_no_prefix; + NR_DL_FRAME_PARMS *frame_parms; + //nfapi_nr_config_request_t *gNB_config; + // uint8_t Kmimo = 0; + uint32_t Nsoft = 0; + double sigma; + unsigned char qbits = 8; + int ret; + //int run_initial_sync=0; + int loglvl = OAILOG_WARNING; + float target_error_rate = 0.01; + + uint16_t nb_symb_sch = 12; + uint16_t nb_rb = 50; + uint8_t Imcs = 9; + + cpuf = get_cpu_freq_GHz(); + + if (load_configmodule(argc, argv) == 0) { + exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); + } + + //logInit(); + randominit(0); + + while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { + switch (c) { + case 'f': + write_output_file = 1; + output_fd = fopen(optarg, "w"); + + if (output_fd == NULL) { + printf("Error opening %s\n", optarg); + exit(-1); + } + + break; + + case 'd': + frame_type = 1; + break; + + case 'g': + switch ((char) *optarg) { + case 'A': + channel_model = SCM_A; + break; + + case 'B': + channel_model = SCM_B; + break; + + case 'C': + channel_model = SCM_C; + break; + + case 'D': + channel_model = SCM_D; + break; + + case 'E': + channel_model = EPA; + break; + + case 'F': + channel_model = EVA; + break; + + case 'G': + channel_model = ETU; + break; + + default: + msg("Unsupported channel model!\n"); + exit(-1); + } + + break; + + case 'i': + interf1 = atoi(optarg); + break; + + case 'j': + interf2 = atoi(optarg); + break; + + case 'n': + n_trials = atoi(optarg); + break; + + case 's': + snr0 = atof(optarg); + msg("Setting SNR0 to %f\n", snr0); + break; + + case 'S': + snr1 = atof(optarg); + snr1set = 1; + msg("Setting SNR1 to %f\n", snr1); + break; + + case 'p': + extended_prefix_flag = 1; + break; + + /* + case 'r': + ricean_factor = pow(10,-.1*atof(optarg)); + if (ricean_factor>1) { + printf("Ricean factor must be between 0 and 1\n"); + exit(-1); + } + break; + */ + + case 'y': + n_tx = atoi(optarg); + + if ((n_tx == 0) || (n_tx > 2)) { + msg("Unsupported number of tx antennas %d\n", n_tx); + exit(-1); + } + + break; + + case 'z': + n_rx = atoi(optarg); + + if ((n_rx == 0) || (n_rx > 2)) { + msg("Unsupported number of rx antennas %d\n", n_rx); + exit(-1); + } + + break; + + case 'N': + Nid_cell = atoi(optarg); + break; + + case 'R': + N_RB_DL = atoi(optarg); + N_RB_UL = N_RB_DL; + break; + + case 'F': + input_fd = fopen(optarg, "r"); + + if (input_fd == NULL) { + printf("Problem with filename %s\n", optarg); + exit(-1); + } + + break; + + case 'P': + pbch_phase = atoi(optarg); + + if (pbch_phase > 3) + printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase); + + break; + + case 'm': + Imcs = atoi(optarg); + break; + + case 'l': + nb_symb_sch = atoi(optarg); + break; + + case 'r': + nb_rb = atoi(optarg); + break; + + case 'x': + transmission_mode = atoi(optarg); + break; + + default: + case 'h': + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); + printf("-h This message\n"); + printf("-p Use extended prefix mode\n"); + printf("-d Use TDD\n"); + printf("-n Number of frames to simulate\n"); + printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); + printf("-S Ending SNR, runs from SNR0 to SNR1\n"); + printf("-t Delay spread for multipath channel\n"); + printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); + printf("-x Transmission mode (1,2,6 for the moment)\n"); + printf("-y Number of TX antennas used in eNB\n"); + printf("-z Number of RX antennas used in UE\n"); + printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-N Nid_cell\n"); + printf("-R N_RB_DL\n"); + printf("-O oversampling factor (1,2,4,8,16)\n"); + printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); + // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + printf("-f Output filename (.txt format) for Pe/SNR results\n"); + printf("-F Input filename (.txt format) for RX conformance testing\n"); + exit(-1); + break; + } + } + + logInit(); + set_glog(loglvl); + T_stdout = 1; + + if (snr1set == 0) + snr1 = snr0 + 10; + + gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, 61.44e6, //N_RB2sampling_rate(N_RB_DL), + 40e6, //N_RB2channel_bandwidth(N_RB_DL), + 0, 0, 0); + + if (gNB2UE == NULL) { + msg("Problem generating channel model. Exiting.\n"); + exit(-1); + } + + RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **)); + RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); + RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); + gNB = RC.gNB[0][0]; + //gNB_config = &gNB->gNB_config; + + frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) + frame_parms->nb_antennas_tx = n_tx; + frame_parms->nb_antennas_rx = n_rx; + frame_parms->N_RB_DL = N_RB_DL; + frame_parms->N_RB_UL = N_RB_UL; + frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; + + crcTableInit(); + + nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); + + phy_init_nr_gNB(gNB, 0, 0); + //init_eNB_afterRU(); + + frame_length_complex_samples = frame_parms->samples_per_subframe; + //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; + s_re = malloc(2 * sizeof(double *)); + s_im = malloc(2 * sizeof(double *)); + r_re = malloc(2 * sizeof(double *)); + r_im = malloc(2 * sizeof(double *)); + txdata = malloc(2 * sizeof(int * )); + + for (i = 0; i < 2; i++) { + s_re[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(s_re[i], frame_length_complex_samples * sizeof(double)); + s_im[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(s_im[i], frame_length_complex_samples * sizeof(double)); + r_re[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(r_re[i], frame_length_complex_samples * sizeof(double)); + r_im[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(r_im[i], frame_length_complex_samples * sizeof(double)); + txdata[i] = malloc(frame_length_complex_samples * sizeof(int)); + bzero(r_re[i], frame_length_complex_samples * sizeof(int)); // [hna] r_re should be txdata + } + + if (pbch_file_fd != NULL) { + load_pbch_desc(pbch_file_fd); + } + + /* for (int k=0; k<2; k++) { + // Create transport channel structures for 2 transport blocks (MIMO) + for (i=0; i<2; i++) { + gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); + + if (!gNB->dlsch[k][i]) { + printf("Can't get eNB dlsch structures\n"); + exit(-1); + } + gNB->dlsch[k][i]->Nsoft = 10; + gNB->dlsch[k][i]->rnti = n_rnti+k; + } + }*/ + //configure UE + UE = malloc(sizeof(PHY_VARS_NR_UE)); + memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); + + //phy_init_nr_top(frame_parms); + if (init_nr_ue_signal(UE, 1, 0) != 0) { + printf("Error at UE NR initialisation\n"); + exit(-1); + } + + //nr_init_frame_parms_ue(&UE->frame_parms); + //init_nr_ue_transport(UE, 0); + for (sf = 0; sf < 2; sf++) { + for (i = 0; i < 2; i++) { + + UE->ulsch[sf][0][i] = new_nr_ue_ulsch(N_RB_UL, 8, 0); + + if (!UE->ulsch[sf][0][i]) { + printf("Can't get ue ulsch structures\n"); + exit(-1); + } + + } + } + + UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); + UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); + + unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; + //time_stats_t *rm_stats, *te_stats, *i_stats; + uint8_t is_crnti = 0, llr8_flag = 0; + unsigned int TBS = 8424; + unsigned int available_bits; + uint8_t nb_re_dmrs = 6; + uint16_t length_dmrs = 1; + unsigned char mod_order; + uint8_t Nl = 1; + uint8_t rvidx = 0; + uint8_t UE_id = 1; + + NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0]; + nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15; + + NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0][0]; + + ulsch_ue->nb_re_dmrs = nb_re_dmrs; //[adk] A HOT FIX until cearting nfapi_nr_ul_config_ulsch_pdu_rel15_t + + mod_order = nr_get_Qm(Imcs, 1); + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, Nl); + printf("available bits %d TBS %d mod_order %d\n", available_bits, TBS, mod_order); + + /////////// setting rel15_ul parameters /////////// + rel15_ul->number_rbs = nb_rb; + rel15_ul->number_symbols = nb_symb_sch; + rel15_ul->Qm = mod_order; + rel15_ul->mcs = Imcs; + rel15_ul->rv = rvidx; + rel15_ul->n_layers = Nl; + /////////////////////////////////////////////////// + + double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc + short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); + short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); + unsigned int errors_bit_uncoded = 0; + // unsigned char *estimated_output; + unsigned char *estimated_output_bit; + unsigned char *test_input_bit; + unsigned int errors_bit = 0; + + test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + // estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + + unsigned char *test_input; + test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); + + for (i = 0; i < TBS / 8; i++) + test_input[i] = (unsigned char) rand(); + + // estimated_output = ulsch_gNB->harq_processes[harq_pid]->b; + + /////////////////////////[adk] preparing UL harq_process parameters///////////////////////// + /////////// + NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; + + if (harq_process_ul_ue) { + + harq_process_ul_ue->mcs = Imcs; + harq_process_ul_ue->Nl = Nl; + harq_process_ul_ue->nb_rb = nb_rb; + harq_process_ul_ue->nb_symbols = nb_symb_sch; + harq_process_ul_ue->rvidx = rvidx; + harq_process_ul_ue->TBS = TBS; + harq_process_ul_ue->a = &test_input[0]; + + } + /////////// + //////////////////////////////////////////////////////////////////////////////////////////// #ifdef DEBUG_ULSCHSIM - for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); + for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); #endif - /*for (int i=0; i0x%08x\n",crc24c(test_input, 32)); - // generate signal + //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); + // generate signal - /////////////////////////[adk] ULSCH coding///////////////////////// - /////////// + /////////////////////////[adk] ULSCH coding///////////////////////// + /////////// - if (input_fd == NULL) { - nr_dlsch_encoding(test_input, subframe, dlsch, frame_parms); - nr_ulsch_encoding(ulsch, frame_parms, harq_pid); - } + if (input_fd == NULL) { + nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid); + } - for (SNR = snr0; SNR < snr1; SNR += snr_step) { - n_errors = 0; - n_false_positive = 0; + /////////// + //////////////////////////////////////////////////////////////////// + + + for (SNR = snr0; SNR < snr1; SNR += snr_step) { + n_errors = 0; + n_false_positive = 0; + + for (trial = 0; trial < n_trials; trial++) { + + errors_bit_uncoded = 0; + + for (i = 0; i < available_bits; i++) { - for (trial = 0; trial < n_trials; trial++) { - errors_bit_uncoded = 0; - for (i = 0; i < available_bits; i++) { #ifdef DEBUG_CODER - if ((i&0xf)==0) - printf("\ne %d..%d: ",i,i+15); + if ((i&0xf)==0) + printf("\ne %d..%d: ",i,i+15); #endif - /* - if (i<16){ - printf("dlsch_encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); - printf("ulsch_encoder output f[%d] = %d\n",i,ulsch->harq_processes[0]->f[i]); + /* + if (i<16){ + printf("dlsch_encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); + printf("ulsch_encoder output f[%d] = %d\n",i,ulsch_ue->harq_processes[0]->f[i]); + } + */ - } - */ - if (ulsch->harq_processes[0]->f[i] == 0) - modulated_input[i] = 1.0; ///sqrt(2); //QPSK - else - modulated_input[i] = -1.0; ///sqrt(2); + if (ulsch_ue->harq_processes[0]->f[i] == 0) + modulated_input[i] = 1.0; ///sqrt(2); //QPSK + else + modulated_input[i] = -1.0; ///sqrt(2); + + //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); + //SNR =10; - //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); - //SNR =10; - SNR_lin = pow(10, SNR / 10.0); - sigma = 1.0 / sqrt(2 * SNR_lin); + SNR_lin = pow(10, SNR / 10.0); + sigma = 1.0 / sqrt(2 * SNR_lin); #if 1 - channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, - modulated_input[i] + sigma * gaussdouble(0.0, 1.0), - qbits); + channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, + modulated_input[i] + sigma * gaussdouble(0.0, 1.0), + qbits); #else - channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits); + channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits); #endif - //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); - //printf("llr[%d]=%d\n",i,channel_output_fixed[i]); - //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); + //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); + //printf("llr[%d]=%d\n",i,channel_output_fixed[i]); + //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); - //channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits); + //channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits); - //if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]); + //if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]); - //Uncoded BER - if (channel_output_fixed[i] < 0) - channel_output_uncoded[i] = 1; //QPSK demod - else - channel_output_uncoded[i] = 0; + //Uncoded BER + if (channel_output_fixed[i] < 0) + channel_output_uncoded[i] = 1; //QPSK demod + else + channel_output_uncoded[i] = 0; - if (channel_output_uncoded[i] != dlsch->harq_processes[harq_pid]->f[i]) - errors_bit_uncoded = errors_bit_uncoded + 1; - } + if (channel_output_uncoded[i] != ulsch_ue->harq_processes[harq_pid]->f[i]) + errors_bit_uncoded = errors_bit_uncoded + 1; + } + + //if (errors_bit_uncoded>10) + printf("errors bits uncoded %u\n", errors_bit_uncoded); - //if (errors_bit_uncoded>10) - printf("errors bits uncoded %u\n", errors_bit_uncoded); #ifdef DEBUG_CODER - printf("\n"); - exit(-1); + printf("\n"); + exit(-1); #endif - ret = nr_dlsch_decoding(UE, channel_output_fixed, &UE->frame_parms, - dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, - subframe, harq_pid, is_crnti, llr8_flag); - if (ret > dlsch0_ue->max_ldpc_iterations) - n_errors++; + ret = nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, + frame, nb_symb_sch, subframe, harq_pid, is_crnti, llr8_flag); - //count errors - errors_bit = 0; + if (ret > ulsch_gNB->max_ldpc_iterations) + n_errors++; - for (i = 0; i < TBS; i++) { - estimated_output_bit[i] = (ulsch->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); - test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments + //count errors + errors_bit = 0; - if (estimated_output_bit[i] != test_input_bit[i]) { - errors_bit++; - //printf("estimated bits error occurs @%d ",i); - } - } + for (i = 0; i < TBS; i++) { + estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments - if (errors_bit > 0) { - n_false_positive++; - if (n_trials == 1) - printf("errors_bit %d (trial %d)\n", errors_bit, trial); - } - } + if (estimated_output_bit[i] != test_input_bit[i]) { + errors_bit++; + //printf("estimated bits error occurs @%d ",i); + } + } - printf("SNR %f, BLER %f (false positive %f)\n", SNR, - (float) n_errors / (float) n_trials, - (float) n_false_positive / (float) n_trials); + if (errors_bit > 0) { + n_false_positive++; + if (n_trials == 1) + printf("errors_bit %d (trial %d)\n", errors_bit, trial); + } + } + + printf("*****************************************\n"); + printf("SNR %f, BLER %f (false positive %f)\n", SNR, + (float) n_errors / (float) n_trials, + (float) n_false_positive / (float) n_trials); + printf("*****************************************\n"); - if ((float) n_errors / (float) n_trials < target_error_rate) { - printf("PDSCH test OK\n"); - break; - } - } + if ((float) n_errors / (float) n_trials < target_error_rate) + break; + } - /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); - if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/ + /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/ - //TODO: loop over slots - /*for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { - if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { - PHY_ofdm_mod(gNB->common_vars.txdataF[aa], - txdata[aa], - frame_parms->ofdm_symbol_size, - 12, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); - } else { - nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], - txdata[aa], - 14, - frame_parms); - } - } + //TODO: loop over slots + /*for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { + if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { + PHY_ofdm_mod(gNB->common_vars.txdataF[aa], + txdata[aa], + frame_parms->ofdm_symbol_size, + 12, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); + } else { + nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], + txdata[aa], + 14, + frame_parms); + } + } - LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1); - if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1); + LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1); - for (i=0; inb_antennas_tx; aa++) { - r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); - r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); - } - }*/ + for (i=0; inb_antennas_tx; aa++) { + r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); + r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); + } + }*/ + for (i = 0; i < 2; i++) { - for (i = 0; i < 2; i++) { + printf("----------------------\n"); + printf("freeing codeword %d\n", i); + printf("----------------------\n"); - printf("gNB %d\n", i); + printf("gNB ulsch[0][%d]\n", i); // [hna] ulsch[0] is for RA - if (gNB->dlsch[0][i]) - free_gNB_dlsch(gNB->dlsch[0][i]); + free_gNB_ulsch(gNB->ulsch[0][i]); - for (sf = 0; sf < 2; sf++) { + printf("gNB ulsch[%d][%d]\n",UE_id, i); - printf("UE %d\n", i); + free_gNB_ulsch(gNB->ulsch[UE_id][i]); - if (UE->dlsch[sf][0][i]) - free_nr_ue_dlsch(UE->dlsch[sf][0][i]); + for (sf = 0; sf < 2; sf++) { - if (UE->ulsch[sf][0][i]) - free_nr_ue_ulsch(UE->ulsch[sf][0][i]); - } - } + printf("UE ulsch[%d][0][%d]\n", sf, i); - for (i = 0; i < 2; i++) { - free(s_re[i]); - free(s_im[i]); - free(r_re[i]); - free(r_im[i]); - free(txdata[i]); - } + if (UE->ulsch[sf][0][i]) + free_nr_ue_ulsch(UE->ulsch[sf][0][i]); + } - free(s_re); - free(s_im); - free(r_re); - free(r_im); - free(txdata); + printf("\n"); + } - if (output_fd) - fclose(output_fd); + for (i = 0; i < 2; i++) { + free(s_re[i]); + free(s_im[i]); + free(r_re[i]); + free(r_im[i]); + free(txdata[i]); + } - if (input_fd) - fclose(input_fd); + free(s_re); + free(s_im); + free(r_re); + free(r_im); + free(txdata); - return (n_errors); + if (output_fd) + fclose(output_fd); + + if (input_fd) + fclose(input_fd); + + return (n_errors); } From bc53a0a77144772de29c7244b0eee5d7801d53f5 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Fri, 1 Mar 2019 17:48:51 +0100 Subject: [PATCH 27/54] indentation + some comments --- openair1/PHY/CODING/coding_defs.h | 2 +- openair1/PHY/CODING/nr_segmentation.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 5 +- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 1146 ++++++++--------- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 4 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 4 +- 6 files changed, 579 insertions(+), 584 deletions(-) diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 0f316e7869..0c1dbfae35 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -453,7 +453,7 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int B, unsigned int *C, unsigned int *K, - unsigned int *Zout, + unsigned int *Zout, unsigned int *F); uint32_t nr_compute_tbs(uint8_t mcs, diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c index 8d0cc9e7d3..421f440ec2 100644 --- a/openair1/PHY/CODING/nr_segmentation.c +++ b/openair1/PHY/CODING/nr_segmentation.c @@ -34,7 +34,7 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int B, unsigned int *C, unsigned int *K, - unsigned int *Zout, + unsigned int *Zout, // [hna] Zout is Zc unsigned int *F) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 4e8c2d2ff5..50e836fe58 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -195,6 +195,9 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, if (abstraction_flag==0) { for (r=0; rharq_processes[i]->c[r] = (uint8_t*)malloc16(8448); dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output if (dlsch->harq_processes[i]->c[r]) { @@ -337,7 +340,7 @@ int nr_dlsch_encoding(unsigned char *a, dlsch->harq_processes[harq_pid]->B, &dlsch->harq_processes[harq_pid]->C, &dlsch->harq_processes[harq_pid]->K, - pz, + pz, // [hna] pz is Zc &dlsch->harq_processes[harq_pid]->F); F = dlsch->harq_processes[harq_pid]->F; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index def3a71754..7cc6dde893 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -76,11 +76,11 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch) } for (r=0; r<(MAX_NUM_NR_DLSCH_SEGMENTS); r++) { - if (dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]){ - nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]); - dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; - } - } + if (dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]){ + nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]); + dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; + } + } free16(dlsch->harq_processes[i],sizeof(NR_DL_UE_HARQ_t)); dlsch->harq_processes[i] = NULL; @@ -143,7 +143,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint if (abstraction_flag == 0) { for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); + dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(1056); if (dlsch->harq_processes[i]->c[r]) @@ -192,7 +192,7 @@ void nr_dlsch_unscrambling(int16_t* llr, reset = 0; } if (((s>>(i&0x1f))&1)==1) - llr[i] = -llr[i]; + llr[i] = -llr[i]; } } @@ -203,7 +203,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, NR_UE_DLSCH_t *dlsch, NR_DL_UE_HARQ_t *harq_process, uint32_t frame, - uint16_t nb_symb_sch, + uint16_t nb_symb_sch, uint8_t nr_tti_rx, uint8_t harq_pid, uint8_t is_crnti, @@ -247,7 +247,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, //NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[0]; - if (!dlsch_llr) { + if (!dlsch_llr) { printf("dlsch_decoding.c: NULL dlsch_llr pointer\n"); return(dlsch->max_ldpc_iterations); } @@ -305,57 +305,59 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // This is a new packet, so compute quantities regarding segmentation harq_process->B = A+24; nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, - &harq_process->F); - p_decParams->Z = harq_process->Z; + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, // [hna] Z is Zc + &harq_process->F); + + p_decParams->Z = harq_process->Z; #ifdef DEBUG_DLSCH_DECODING printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z); - if (!frame%100) - printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); + if (!frame%100) + printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); #endif } - Coderate = (float) A /(float) G; - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ - p_decParams->BG = 2; - if (Coderate < 0.3333){ - p_decParams->R = 15; - kc = 52; - } - else if (Coderate <0.6667){ - p_decParams->R = 13; - kc = 32; - } - else { - p_decParams->R = 23; - kc = 17; - } - } - else{ - p_decParams->BG = 1; - if (Coderate < 0.6667){ - p_decParams->R = 13; - kc = 68; - } - else if (Coderate <0.8889){ - p_decParams->R = 23; - kc = 35; - } - else { - p_decParams->R = 89; - kc = 27; - } - } - //printf("coderate %f kc %d \n", Coderate, kc); + Coderate = (float) A /(float) G; + if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) + { + p_decParams->BG = 2; + if (Coderate < 0.3333){ + p_decParams->R = 15; + kc = 52; + } + else if (Coderate <0.6667){ + p_decParams->R = 13; + kc = 32; + } + else { + p_decParams->R = 23; + kc = 17; + } + } + else{ + p_decParams->BG = 1; + if (Coderate < 0.6667){ + p_decParams->R = 13; + kc = 68; + } + else if (Coderate <0.8889){ + p_decParams->R = 23; + kc = 35; + } + else { + p_decParams->R = 89; + kc = 27; + } + } - p_decParams->numMaxIter = dlsch->max_ldpc_iterations; - p_decParams->outMode= 0; + //printf("coderate %f kc %d \n", Coderate, kc); + p_decParams->numMaxIter = dlsch->max_ldpc_iterations; + p_decParams->outMode= 0; err_flag = 0; r_offset = 0; @@ -363,27 +365,27 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, unsigned char bw_scaling =1; switch (frame_parms->N_RB_DL) { + case 106: + bw_scaling =2; + break; - case 106: - bw_scaling =2; - break; - - default: - bw_scaling =1; - break; + default: + bw_scaling =1; + break; } if (harq_process->C > MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling) { LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling); return((1+dlsch->max_ldpc_iterations)); } + #ifdef DEBUG_DLSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif opp_enabled=1; - Kr = harq_process->K; + Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" Kr_bytes = Kr>>3; K_bytes_F = Kr_bytes-(harq_process->F>>3); @@ -400,11 +402,11 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, #endif nr_deinterleaving_ldpc(E, harq_process->Qm, - harq_process->w[r], + harq_process->w[r], // [hna] w is e dlsch_llr+r_offset); //for (int i =0; i<16; i++) - // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); + // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); #if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); @@ -441,31 +443,30 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, #endif LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n"); return(dlsch->max_ldpc_iterations); - } else - { + } else { #if UE_TIMING_TRACE stop_meas(dlsch_rate_unmatching_stats); #endif } //for (int i =0; i<16; i++) - // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); + // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); r_offset += E; #ifdef DEBUG_DLSCH_DECODING if (r==0) { - write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0); + write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); + write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0); } printf("decoder input(segment %d) :",r); - int i; for (i=0;i<(3*8*Kr_bytes)+12;i++) + int i; + for (i=0;i<(3*8*Kr_bytes)+12;i++) printf("%d : %d\n",i,harq_process->d[r][i]); - printf("\n"); + printf("\n"); #endif - // printf("Clearing c, %p\n",harq_process->c[r]); memset(harq_process->c[r],0,Kr_bytes); @@ -482,74 +483,70 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, if (err_flag == 0) { #if UE_TIMING_TRACE - start_meas(dlsch_turbo_decoding_stats); + start_meas(dlsch_turbo_decoding_stats); #endif //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A); //printf("harq process dr iteration %d\n", p_decParams->numMaxIter); + memset(pv,0,2*harq_process->Z*sizeof(int16_t)); + //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); + memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); - memset(pv,0,2*harq_process->Z*sizeof(int16_t)); - //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); - memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); + for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) + { + pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); + } - for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); - } + for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) + { + pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); + } - for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); - } - - for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) - { - - pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); - - } + for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) + { + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + } - no_iteration_ldpc = nrLDPC_decoder(p_decParams, - (int8_t*)&pl[0], - llrProcBuf, + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, p_nrLDPC_procBuf[r], p_procTime); - // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int - if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { - printf("Segment %d CRC OK\n",r); - ret = 2; - } - else { - printf("CRC NOK\n"); - ret = 1+dlsch->max_ldpc_iterations; - } - + // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int + if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { + printf("Segment %d CRC OK\n",r); + ret = 2; + } + else { + printf("CRC NOK\n"); + ret = 1+dlsch->max_ldpc_iterations; + } - nb_total_decod++; - if (no_iteration_ldpc > dlsch->max_ldpc_iterations){ - nb_error_decod++; - } + nb_total_decod++; + if (no_iteration_ldpc > dlsch->max_ldpc_iterations){ + nb_error_decod++; + } - ret=no_iteration_ldpc; + ret=no_iteration_ldpc; - //if (!nb_total_decod%10000){ - //printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout); - //} - //else - //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); + //if (!nb_total_decod%10000){ + //printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout); + //} + //else + //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); - for (int m=0; m < Kr>>3; m ++) - { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } + for (int m=0; m < Kr>>3; m ++) + { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } #ifdef DEBUG_DLSCH_DECODING //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); for (int k=0;k>3;k++) - printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); + printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); printf("no_iterations_ldpc %d (ret %d)\n",no_iteration_ldpc,ret); //write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4); #endif @@ -664,18 +661,18 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, #ifdef UE_DLSCH_PARALLELISATION uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, - int eNB_id, - short *dlsch_llr, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_DLSCH_t *dlsch, - NR_DL_UE_HARQ_t *harq_process, - uint32_t frame, - uint16_t nb_symb_sch, - uint8_t nr_tti_rx, - uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag) + UE_nr_rxtx_proc_t *proc, + int eNB_id, + short *dlsch_llr, + NR_DL_FRAME_PARMS *frame_parms, + NR_UE_DLSCH_t *dlsch, + NR_DL_UE_HARQ_t *harq_process, + uint32_t frame, + uint16_t nb_symb_sch, + uint8_t nr_tti_rx, + uint8_t harq_pid, + uint8_t is_crnti, + uint8_t llr8_flag) { #if UE_TIMING_TRACE @@ -786,27 +783,28 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, // This is a new packet, so compute quantities regarding segmentation harq_process->B = A+24; nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, - &harq_process->F); - p_decParams->Z = harq_process->Z; + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, + &harq_process->F); + + p_decParams->Z = harq_process->Z; } - kb = harq_process->K/harq_process->Z; - if ( kb==22){ - p_decParams->BG = 1; - p_decParams->R = 13; - kc = 68; - } - else{ - p_decParams->BG = 2; - p_decParams->R = 13; - kc = 52; - } + kb = harq_process->K/harq_process->Z; + if ( kb==22){ + p_decParams->BG = 1; + p_decParams->R = 13; + kc = 68; + } + else{ + p_decParams->BG = 2; + p_decParams->R = 13; + kc = 52; + } p_decParams->numMaxIter = 2; Kr = p_decParams->Z*kb; @@ -842,135 +840,133 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, #endif opp_enabled=1; -if (harq_process->C>1) { // wakeup worker if more than 1 segment - if (pthread_mutex_lock(&proc->mutex_dlsch_td) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE dlsch td\n",phy_vars_ue->Mod_id ); - exit_fun("nothing to add"); - } + if (harq_process->C>1) { // wakeup worker if more than 1 segment + if (pthread_mutex_lock(&proc->mutex_dlsch_td) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE dlsch td\n",phy_vars_ue->Mod_id ); + exit_fun("nothing to add"); + } - /*Qm= harq_process->Qm; - Nl=harq_process->Nl; - r_thread = harq_process->C/2-1; - C= harq_process->C; + /*Qm= harq_process->Qm; + Nl=harq_process->Nl; + r_thread = harq_process->C/2-1; + C= harq_process->C; - Gp = G/Nl/Qm; - GpmodC = Gp%C; + Gp = G/Nl/Qm; + GpmodC = Gp%C; - if (r_thread < (C-(GpmodC))) - Er = Nl*Qm * (Gp/C); - else - Er = Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); - printf("mthread Er %d\n", Er); + if (r_thread < (C-(GpmodC))) + Er = Nl*Qm * (Gp/C); + else + Er = Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); + printf("mthread Er %d\n", Er); - printf("mthread instance_cnt_dlsch_td %d\n", proc->instance_cnt_dlsch_td);*/ + printf("mthread instance_cnt_dlsch_td %d\n", proc->instance_cnt_dlsch_td);*/ - proc->instance_cnt_dlsch_td++; - proc->eNB_id = eNB_id; - proc->harq_pid = harq_pid; - proc->llr8_flag = llr8_flag; - //proc->r[0] = 1; + proc->instance_cnt_dlsch_td++; + proc->eNB_id = eNB_id; + proc->harq_pid = harq_pid; + proc->llr8_flag = llr8_flag; + //proc->r[0] = 1; - if (proc->instance_cnt_dlsch_td == 0) - { - LOG_D(PHY,"unblock dlsch td processing thread blocked on instance_cnt_dlsch_td : %d \n", proc->instance_cnt_dlsch_td ); - if (pthread_cond_signal(&proc->cond_dlsch_td) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE dlsch td\n", phy_vars_ue->Mod_id); - exit_fun("nothing to add"); - } - if (pthread_mutex_unlock(&proc->mutex_dlsch_td) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE dlsch td \n",phy_vars_ue->Mod_id ); - exit_fun("nothing to add"); - } + if (proc->instance_cnt_dlsch_td == 0) + { + LOG_D(PHY,"unblock dlsch td processing thread blocked on instance_cnt_dlsch_td : %d \n", proc->instance_cnt_dlsch_td ); + if (pthread_cond_signal(&proc->cond_dlsch_td) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE dlsch td\n", phy_vars_ue->Mod_id); + exit_fun("nothing to add"); + } + if (pthread_mutex_unlock(&proc->mutex_dlsch_td) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE dlsch td \n",phy_vars_ue->Mod_id ); + exit_fun("nothing to add"); + } + } else + { + LOG_E( PHY, "[SCHED][UE %d] UE dlsch td thread busy (IC %d)!!\n", phy_vars_ue->Mod_id, proc->instance_cnt_dlsch_td); + if (proc->instance_cnt_dlsch_td > 4) + exit_fun("instance_cnt_dlsch_td > 4"); + } + //AssertFatal(pthread_cond_signal(&proc->cond_slot1_dl_processing) ==0 ,""); + AssertFatal(pthread_mutex_unlock(&proc->mutex_dlsch_td) ==0,""); - } else - { - LOG_E( PHY, "[SCHED][UE %d] UE dlsch td thread busy (IC %d)!!\n", phy_vars_ue->Mod_id, proc->instance_cnt_dlsch_td); - if (proc->instance_cnt_dlsch_td > 4) - exit_fun("instance_cnt_dlsch_td > 4"); - } - //AssertFatal(pthread_cond_signal(&proc->cond_slot1_dl_processing) ==0 ,""); - AssertFatal(pthread_mutex_unlock(&proc->mutex_dlsch_td) ==0,""); + if (harq_process->C>2) { + if (pthread_mutex_lock(&proc->mutex_dlsch_td1) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE dlsch td\n",phy_vars_ue->Mod_id ); + exit_fun("nothing to add"); + } - if (harq_process->C>2) { - if (pthread_mutex_lock(&proc->mutex_dlsch_td1) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE dlsch td\n",phy_vars_ue->Mod_id ); - exit_fun("nothing to add"); - } + proc->instance_cnt_dlsch_td1++; + proc->eNB_id = eNB_id; + proc->harq_pid = harq_pid; + proc->llr8_flag = llr8_flag; + // proc->Er = Er; - proc->instance_cnt_dlsch_td1++; - proc->eNB_id = eNB_id; - proc->harq_pid = harq_pid; - proc->llr8_flag = llr8_flag; - // proc->Er = Er; + if (proc->instance_cnt_dlsch_td1 == 0) + { + LOG_D(PHY,"unblock slot1 dl processing thread blocked on instance_cnt_dlsch_td : %d \n", proc->instance_cnt_dlsch_td1 ); + if (pthread_cond_signal(&proc->cond_dlsch_td1) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE dlsch td\n", phy_vars_ue->Mod_id); + exit_fun("nothing to add"); + } + if (pthread_mutex_unlock(&proc->mutex_dlsch_td1) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE dlsch td \n",phy_vars_ue->Mod_id ); + exit_fun("nothing to add"); + } + } else + { + LOG_E( PHY, "[SCHED][UE %d] UE dlsch td thread 1 busy (IC %d)!!\n", phy_vars_ue->Mod_id, proc->instance_cnt_dlsch_td1); + if (proc->instance_cnt_dlsch_td1 > 4) + exit_fun("instance_cnt_dlsch_td1 > 4"); + } - if (proc->instance_cnt_dlsch_td1 == 0) - { - LOG_D(PHY,"unblock slot1 dl processing thread blocked on instance_cnt_dlsch_td : %d \n", proc->instance_cnt_dlsch_td1 ); - if (pthread_cond_signal(&proc->cond_dlsch_td1) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE dlsch td\n", phy_vars_ue->Mod_id); - exit_fun("nothing to add"); - } - if (pthread_mutex_unlock(&proc->mutex_dlsch_td1) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE dlsch td \n",phy_vars_ue->Mod_id ); - exit_fun("nothing to add"); - } + AssertFatal(pthread_mutex_unlock(&proc->mutex_dlsch_td1) ==0,""); - } else - { - LOG_E( PHY, "[SCHED][UE %d] UE dlsch td thread 1 busy (IC %d)!!\n", phy_vars_ue->Mod_id, proc->instance_cnt_dlsch_td1); - if (proc->instance_cnt_dlsch_td1 > 4) - exit_fun("instance_cnt_dlsch_td1 > 4"); - } + } + /* + if (pthread_mutex_timedlock(&proc->mutex_td,&wait) != 0) { + printf("[eNB] ERROR pthread_mutex_lock for TD thread (IC %d)\n", proc->instance_cnt_td); + exit_fun( "error locking mutex_fep" ); + return -1; + } - AssertFatal(pthread_mutex_unlock(&proc->mutex_dlsch_td1) ==0,""); + if (proc->instance_cnt_td==0) { + printf("[UE] TD thread busy\n"); + exit_fun("TD thread busy"); + pthread_mutex_unlock( &proc->mutex_td ); + return -1; + } - } - /* - if (pthread_mutex_timedlock(&proc->mutex_td,&wait) != 0) { - printf("[eNB] ERROR pthread_mutex_lock for TD thread (IC %d)\n", proc->instance_cnt_td); - exit_fun( "error locking mutex_fep" ); - return -1; - } + ++proc->instance_cnt_td; - if (proc->instance_cnt_td==0) { - printf("[UE] TD thread busy\n"); - exit_fun("TD thread busy"); - pthread_mutex_unlock( &proc->mutex_td ); - return -1; - } + proc->tdp.UE = phy_vars_ue; + proc->tdp.eNB_id = eNB_id; + proc->tdp.harq_pid = harq_pid; + proc->tdp.llr8_flag = llr8_flag; - ++proc->instance_cnt_td; - - proc->tdp.UE = phy_vars_ue; - proc->tdp.eNB_id = eNB_id; - proc->tdp.harq_pid = harq_pid; - proc->tdp.llr8_flag = llr8_flag; - - printf("----- 2thread llr flag %d tdp flag %d\n",llr8_flag, proc->tdp.llr8_flag); + printf("----- 2thread llr flag %d tdp flag %d\n",llr8_flag, proc->tdp.llr8_flag); - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_td) != 0) { - printf("[UE] ERROR pthread_cond_signal for td thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (1+dlsch->last_iteration_cnt); - } + // wakeup worker to do second half segments + if (pthread_cond_signal(&proc->cond_td) != 0) { + printf("[UE] ERROR pthread_cond_signal for td thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return (1+dlsch->last_iteration_cnt); + } - pthread_mutex_unlock( &proc->mutex_td );*/ + pthread_mutex_unlock( &proc->mutex_td );*/ - Cby2 = 1; //harq_process->C/2; - //proc->decoder_main_available = 1; - } - else { - Cby2 = 1; - } + Cby2 = 1; //harq_process->C/2; + //proc->decoder_main_available = 1; + } + else { + Cby2 = 1; + } - //for (r=0; rK; Kr_bytes = Kr>>3; @@ -1041,27 +1037,27 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment } //for (int i =0; i<16; i++) - // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); + // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); //r_offset += E; //printf("main thread r_offset %d\n",r_offset); #ifdef DEBUG_DLSCH_DECODING for (int i =0; i<16; i++) - printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); + printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); #endif #ifdef DEBUG_DLSCH_DECODING if (r==0) { - write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - write_output("decoder_in.m","dec",&harq_process->d[0][96],(3*8*Kr_bytes)+12,1,0); + write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); + write_output("decoder_in.m","dec",&harq_process->d[0][96],(3*8*Kr_bytes)+12,1,0); } printf("decoder input(segment %d) :",r); for (int i=0;i<(3*8*Kr_bytes);i++) printf("%d : %d\n",i,harq_process->d[r][i]); - printf("\n"); + printf("\n"); #endif @@ -1082,98 +1078,94 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS, harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_ldpc_iterations); */ - if (llr8_flag) { - AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", - Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); - } + if (llr8_flag) { + AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", + Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); + } #if UE_TIMING_TRACE - start_meas(dlsch_turbo_decoding_stats); + start_meas(dlsch_turbo_decoding_stats); #endif LOG_D(PHY,"mthread AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); - - for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ - inv_d[cnt] = (1)*harq_process->d[r][cnt]; - } - memset(pv,0,2*p_decParams->Z*sizeof(int16_t)); - //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); - memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); + for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ + inv_d[cnt] = (1)*harq_process->d[r][cnt]; + } + + memset(pv,0,2*p_decParams->Z*sizeof(int16_t)); + //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); + memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); - for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); - } + for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++) + { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } - for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); - } + for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) + { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } - for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) - { + for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) + { + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + } - pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, + p_nrLDPC_procBuf, + p_procTime); - } + nb_total_decod++; + if (no_iteration_ldpc > 10){ + nb_error_decod++; + ret = 1+dlsch->max_ldpc_iterations; + } + else { + ret=2; + } - no_iteration_ldpc = nrLDPC_decoder(p_decParams, - (int8_t*)&pl[0], - llrProcBuf, - p_nrLDPC_procBuf, - p_procTime); + if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { + printf("CRC OK\n"); + ret = 2; + } + else { + printf("CRC NOK\n"); + ret = 1+dlsch->max_ldpc_iterations; + } - nb_total_decod++; - if (no_iteration_ldpc > 10){ - nb_error_decod++; - ret = 1+dlsch->max_ldpc_iterations; - } - else { - ret=2; - } - - if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { - printf("CRC OK\n"); - ret = 2; - } - else { - printf("CRC NOK\n"); - ret = 1+dlsch->max_ldpc_iterations; - } - - //if (!nb_total_decod%10000){ - printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout); - //} + //if (!nb_total_decod%10000){ + printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout); + //} - //else - //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); + //else + //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); - for (int m=0; m < Kr>>3; m ++) - { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } + for (int m=0; m < Kr>>3; m ++) + { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } - /*for (int u=0; u < Kr>>3; u ++) - { - ullrProcBuf[u]= (uint8_t) llrProcBuf[u]; - } + /*for (int u=0; u < Kr>>3; u ++) + { + ullrProcBuf[u]= (uint8_t) llrProcBuf[u]; + } - printf("output unsigned ullrProcBuf \n"); + printf("output unsigned ullrProcBuf \n"); - for (int j=0; j < Kr>>3; j ++) - { + for (int j=0; j < Kr>>3; j ++) + { + printf(" %d \n", ullrProcBuf[j]); + } + printf(" \n");*/ + //printf("output channel decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); - printf(" %d \n", ullrProcBuf[j]); - - } - printf(" \n");*/ - //printf("output channel decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); - - //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); + //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); #ifdef DEBUG_DLSCH_DECODING - for (int k=0;k<32;k++) - printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); + for (int k=0;k<32;k++) + printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); #endif #if UE_TIMING_TRACE @@ -1252,40 +1244,40 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment */ uint32_t wait = 0; if (harq_process->C==2){ - while((proc->decoder_thread_available == 0) ) + while((proc->decoder_thread_available == 0) ) { usleep(1); wait++; } } else if ((harq_process->C==3) ){ - while((proc->decoder_thread_available == 0) || (proc->decoder_thread_available1 == 0)) - { - usleep(1); - wait++; - } + while((proc->decoder_thread_available == 0) || (proc->decoder_thread_available1 == 0)) + { + usleep(1); + wait++; + } } proc->decoder_main_available = 0; for (r=0; rC; r++) { - Kr = harq_process->K; //to check if same K in all segments - Kr_bytes = Kr>>3; + Kr = harq_process->K; //to check if same K in all segments + Kr_bytes = Kr>>3; - memcpy(harq_process->b+offset, - harq_process->c[r], - Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); - offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); + memcpy(harq_process->b+offset, + harq_process->c[r], + Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); + offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); #ifdef DEBUG_DLSCH_DECODING - printf("Segment %d : Kr= %d bytes\n",r,Kr_bytes); - printf("copied %d bytes to b sequence (harq_pid %d)\n", - (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)),harq_pid); - printf("b[0] = %x,c[%d] = %x\n", - harq_process->b[offset], - harq_process->F>>3, - harq_process->c[r]); + printf("Segment %d : Kr= %d bytes\n",r,Kr_bytes); + printf("copied %d bytes to b sequence (harq_pid %d)\n", + (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)),harq_pid); + printf("b[0] = %x,c[%d] = %x\n", + harq_process->b[offset], + harq_process->F>>3, + harq_process->c[r]); #endif } @@ -1346,14 +1338,14 @@ void *nr_dlsch_decoding_2thread0(void *arg) char threadname[256]; sprintf(threadname,"UE_thread_dlsch_td_%d", proc->sub_frame_start); - cpu_set_t cpuset; + cpu_set_t cpuset; CPU_ZERO(&cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.dlsch_td_one != -1 ) - CPU_SET(threads.dlsch_td_one, &cpuset); + CPU_SET(threads.dlsch_td_one, &cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.dlsch_td_two != -1 ) - CPU_SET(threads.dlsch_td_two, &cpuset); + CPU_SET(threads.dlsch_td_two, &cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.dlsch_td_three != -1 ) - CPU_SET(threads.dlsch_td_three, &cpuset); + CPU_SET(threads.dlsch_td_three, &cpuset); @@ -1376,42 +1368,42 @@ void *nr_dlsch_decoding_2thread0(void *arg) init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, threadname); while (!oai_exit) { - //proc->decoder_thread_available = 1; - - if (pthread_mutex_lock(&proc->mutex_dlsch_td) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE dlsch td\n" ); - exit_fun("nothing to add"); - } - while (proc->instance_cnt_dlsch_td < 0) { - // most of the time, the thread is waiting here - pthread_cond_wait( &proc->cond_dlsch_td, &proc->mutex_dlsch_td ); - } - if (pthread_mutex_unlock(&proc->mutex_dlsch_td) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE dlsch_td \n" ); - exit_fun("nothing to add"); - } + //proc->decoder_thread_available = 1; + + if (pthread_mutex_lock(&proc->mutex_dlsch_td) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE dlsch td\n" ); + exit_fun("nothing to add"); + } + while (proc->instance_cnt_dlsch_td < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_dlsch_td, &proc->mutex_dlsch_td ); + } + if (pthread_mutex_unlock(&proc->mutex_dlsch_td) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE dlsch_td \n" ); + exit_fun("nothing to add"); + } - uint32_t wait = 0; - while(proc->decoder_main_available == 0) - { - usleep(1); - wait++; - } + uint32_t wait = 0; + while(proc->decoder_main_available == 0) + { + usleep(1); + wait++; + } - //proc->decoder_thread_available = 0; - //PHY_VARS_NR_UE *phy_vars_ue = tdp->UE; - int eNB_id = proc->eNB_id; - int harq_pid = proc->harq_pid; - llr8_flag1 = proc->llr8_flag; - //r_offset = proc->Er; - //UE_rxtx_proc_t *proc = tdp->proc; - int frame = proc->frame_rx; - int subframe = proc->nr_tti_rx; - NR_UE_DLSCH_t *dlsch = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]; - NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; - short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; - //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); - p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[1]; + //proc->decoder_thread_available = 0; + //PHY_VARS_NR_UE *phy_vars_ue = tdp->UE; + int eNB_id = proc->eNB_id; + int harq_pid = proc->harq_pid; + llr8_flag1 = proc->llr8_flag; + //r_offset = proc->Er; + //UE_rxtx_proc_t *proc = tdp->proc; + int frame = proc->frame_rx; + int subframe = proc->nr_tti_rx; + NR_UE_DLSCH_t *dlsch = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]; + NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; + short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; + //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); + p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[1]; /* if (nb_rb > frame_parms->N_RB_DL) { @@ -1444,27 +1436,27 @@ void *nr_dlsch_decoding_2thread0(void *arg) harq_process->B = A+24; nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, - &harq_process->F); - p_decParams->Z = harq_process->Z; + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, + &harq_process->F); + p_decParams->Z = harq_process->Z; } kb = harq_process->K/harq_process->Z; - if ( kb==22){ - p_decParams->BG = 1; - p_decParams->R = 13; - kc = 68; - } - else{ - p_decParams->BG = 2; - p_decParams->R = 13; - kc = 52; - } + if ( kb==22){ + p_decParams->BG = 1; + p_decParams->R = 13; + kc = 68; + } + else{ + p_decParams->BG = 2; + p_decParams->R = 13; + kc = 52; + } p_decParams->numMaxIter = 2; Kr = p_decParams->Z*kb; @@ -1510,14 +1502,14 @@ void *nr_dlsch_decoding_2thread0(void *arg) Cprime = C; //assume CBGTI not present if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1) - r_offset = Nl*Qm*(G/(Nl*Qm*Cprime)); + r_offset = Nl*Qm*(G/(Nl*Qm*Cprime)); else - r_offset = Nl*Qm*((G/(Nl*Qm*Cprime))+1); + r_offset = Nl*Qm*((G/(Nl*Qm*Cprime))+1); - // printf("thread0 r_offset %d\n",r_offset); - + // printf("thread0 r_offset %d\n",r_offset); + //for (r=(harq_process->C/2); rC; r++) { - r=1; //(harq_process->C/2); + r=1; //(harq_process->C/2); Kr = harq_process->K; @@ -1537,7 +1529,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) dlsch_llr+r_offset); //for (int i =0; i<16; i++) - // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); + // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); #if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); @@ -1582,7 +1574,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) } //for (int i =0; i<16; i++) - // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); + // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); //r_offset += E; @@ -1616,10 +1608,10 @@ void *nr_dlsch_decoding_2thread0(void *arg) Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS, harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_ldpc_iterations); */ - if (llr8_flag1) { - AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", - Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); - } + if (llr8_flag1) { + AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", + Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); + } #if UE_TIMING_TRACE start_meas(dlsch_turbo_decoding_stats); #endif @@ -1634,58 +1626,58 @@ void *nr_dlsch_decoding_2thread0(void *arg) memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); - } + { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } - for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); - } + for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) + { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } - for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) - { + for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) + { - pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); - } + } - no_iteration_ldpc = nrLDPC_decoder(p_decParams, - (int8_t*)&pl[0], - llrProcBuf, + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, p_nrLDPC_procBuf, - p_procTime); + p_procTime); - if (no_iteration_ldpc > 10) - printf("Error number of iteration LPDC %d\n", no_iteration_ldpc); - //else - //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); + if (no_iteration_ldpc > 10) + printf("Error number of iteration LPDC %d\n", no_iteration_ldpc); + //else + //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); - for (int m=0; m < Kr>>3; m ++) - { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } + for (int m=0; m < Kr>>3; m ++) + { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } - /*for (int u=0; u < Kr>>3; u ++) - { - ullrProcBuf[u]= (uint8_t) llrProcBuf[u]; - } + /*for (int u=0; u < Kr>>3; u ++) + { + ullrProcBuf[u]= (uint8_t) llrProcBuf[u]; + } - printf("output unsigned ullrProcBuf \n"); + printf("output unsigned ullrProcBuf \n"); - for (int j=0; j < Kr>>3; j ++) - { + for (int j=0; j < Kr>>3; j ++) + { - printf(" %d \n", ullrProcBuf[j]); + printf(" %d \n", ullrProcBuf[j]); - } - printf(" \n");*/ -#ifdef DEBUG_DLSCH_DECODING - for (int k=0;k<2;k++) - printf("segment 1 output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); + } + printf(" \n");*/ +#ifdef DEBUG_DLSCH_DECODING + for (int k=0;k<2;k++) + printf("segment 1 output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); #endif - + #if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); #endif @@ -1818,7 +1810,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) #define FIFO_PRIORITY 39 void *nr_dlsch_decoding_2thread1(void *arg) { - static __thread int UE_dlsch_td_retval1; + static __thread int UE_dlsch_td_retval1; struct nr_rxtx_thread_data *rtd = arg; UE_nr_rxtx_proc_t *proc = rtd->proc; PHY_VARS_NR_UE *phy_vars_ue = rtd->UE; @@ -1860,14 +1852,14 @@ void *nr_dlsch_decoding_2thread1(void *arg) char threadname[256]; sprintf(threadname,"UE_thread_dlsch_td1_%d", proc->sub_frame_start); - cpu_set_t cpuset; + cpu_set_t cpuset; CPU_ZERO(&cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.dlsch_td_one != -1 ) - CPU_SET(threads.dlsch_td_one, &cpuset); + CPU_SET(threads.dlsch_td_one, &cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.dlsch_td_two != -1 ) - CPU_SET(threads.dlsch_td_two, &cpuset); + CPU_SET(threads.dlsch_td_two, &cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.dlsch_td_three != -1 ) - CPU_SET(threads.dlsch_td_three, &cpuset); + CPU_SET(threads.dlsch_td_three, &cpuset); @@ -1881,51 +1873,51 @@ void *nr_dlsch_decoding_2thread1(void *arg) uint32_t ret,offset; uint32_t r,r_offset=0,Kr,Kr_bytes,err_flag=0,K_bytes_F; uint8_t crc_type; - uint8_t C,Cprime; + uint8_t C,Cprime; uint8_t Qm; - uint8_t Nl; + uint8_t Nl; //uint32_t Er; - init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, threadname); - printf("2thread1 oai_exit %d\n", oai_exit); - while (!oai_exit) { - if (pthread_mutex_lock(&proc->mutex_dlsch_td1) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE dlsch td\n" ); - exit_fun("nothing to add"); - } - while (proc->instance_cnt_dlsch_td1 < 0) { - // most of the time, the thread is waiting here - pthread_cond_wait( &proc->cond_dlsch_td1, &proc->mutex_dlsch_td1 ); - } - if (pthread_mutex_unlock(&proc->mutex_dlsch_td1) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE dlsch_td \n" ); - exit_fun("nothing to add"); - } + init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, threadname); + printf("2thread1 oai_exit %d\n", oai_exit); + while (!oai_exit) { + if (pthread_mutex_lock(&proc->mutex_dlsch_td1) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE dlsch td\n" ); + exit_fun("nothing to add"); + } + while (proc->instance_cnt_dlsch_td1 < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_dlsch_td1, &proc->mutex_dlsch_td1 ); + } + if (pthread_mutex_unlock(&proc->mutex_dlsch_td1) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE dlsch_td \n" ); + exit_fun("nothing to add"); + } - //printf("2thread1 main available %d\n", proc->decoder_main_available); + //printf("2thread1 main available %d\n", proc->decoder_main_available); - uint32_t wait = 0; - while(proc->decoder_main_available == 0) - { - usleep(1); - wait++; - } - - //proc->decoder_thread_available1 = 0; - //PHY_VARS_NR_UE *phy_vars_ue = tdp->UE; - int eNB_id = proc->eNB_id; - int harq_pid = proc->harq_pid; - llr8_flag1 = proc->llr8_flag; - //r_offset = proc->Er; - //UE_rxtx_proc_t *proc = tdp->proc; - int frame = proc->frame_rx; - int subframe = proc->nr_tti_rx; - NR_UE_DLSCH_t *dlsch = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]; - NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; - short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; - //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); - //printf("2thread1 nr_tti_tx %d subframe %d SF thread id %d r_offset %d\n", proc->nr_tti_rx, subframe, phy_vars_ue->current_thread_id[subframe], r_offset); - p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[2]; + uint32_t wait = 0; + while(proc->decoder_main_available == 0) + { + usleep(1); + wait++; + } + + //proc->decoder_thread_available1 = 0; + //PHY_VARS_NR_UE *phy_vars_ue = tdp->UE; + int eNB_id = proc->eNB_id; + int harq_pid = proc->harq_pid; + llr8_flag1 = proc->llr8_flag; + //r_offset = proc->Er; + //UE_rxtx_proc_t *proc = tdp->proc; + int frame = proc->frame_rx; + int subframe = proc->nr_tti_rx; + NR_UE_DLSCH_t *dlsch = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]; + NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; + short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; + //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); + //printf("2thread1 nr_tti_tx %d subframe %d SF thread id %d r_offset %d\n", proc->nr_tti_rx, subframe, phy_vars_ue->current_thread_id[subframe], r_offset); + p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[2]; /* if (nb_rb > frame_parms->N_RB_DL) { @@ -1960,27 +1952,27 @@ void *nr_dlsch_decoding_2thread1(void *arg) // This is a new packet, so compute quantities regarding segmentation harq_process->B = A+24; nr_segmentation(NULL, - NULL, - harq_process->B, - &harq_process->C, - &harq_process->K, - &harq_process->Z, - &harq_process->F); - p_decParams->Z = harq_process->Z; + NULL, + harq_process->B, + &harq_process->C, + &harq_process->K, + &harq_process->Z, + &harq_process->F); + p_decParams->Z = harq_process->Z; } kb = harq_process->K/harq_process->Z; - if ( kb==22){ - p_decParams->BG = 1; - p_decParams->R = 89; - kc = 68; - } - else{ - p_decParams->BG = 2; - p_decParams->R = 13; - kc = 52; - } + if ( kb==22){ + p_decParams->BG = 1; + p_decParams->R = 89; + kc = 68; + } + else{ + p_decParams->BG = 2; + p_decParams->R = 13; + kc = 52; + } p_decParams->numMaxIter = 2; Kr = p_decParams->Z*kb; @@ -2025,23 +2017,23 @@ void *nr_dlsch_decoding_2thread1(void *arg) Cprime = C; //assume CBGTI not present if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1) - r_offset = Nl*Qm*(G/(Nl*Qm*Cprime)); + r_offset = Nl*Qm*(G/(Nl*Qm*Cprime)); else - r_offset = Nl*Qm*((G/(Nl*Qm*Cprime))+1); + r_offset = Nl*Qm*((G/(Nl*Qm*Cprime))+1); - //printf("sub thread r_offset %d\n", r_offset); + //printf("sub thread r_offset %d\n", r_offset); //for (r=(harq_process->C/2); rC; r++) { - r=2; //(harq_process->C/2); - r_offset = r*r_offset; - //printf("thread1 r=%d r_offset %d \n",r, r_offset); + r=2; //(harq_process->C/2); + r_offset = r*r_offset; + //printf("thread1 r=%d r_offset %d \n",r, r_offset); - Kr = harq_process->K; - Kr_bytes = Kr>>3; - K_bytes_F = Kr_bytes-(harq_process->F>>3); + Kr = harq_process->K; + Kr_bytes = Kr>>3; + K_bytes_F = Kr_bytes-(harq_process->F>>3); - Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); + Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); @@ -2059,7 +2051,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) dlsch_llr+r_offset); //for (int i =0; i<16; i++) - // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); + // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); #if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); @@ -2082,15 +2074,15 @@ void *nr_dlsch_decoding_2thread1(void *arg) #endif if (nr_rate_matching_ldpc_rx(Ilbrm, - Tbslbrm, - p_decParams->BG, - p_decParams->Z, - harq_process->d[r], - harq_process->w[r], - harq_process->C, - harq_process->rvidx, - (harq_process->round==0)?1:0, - E)==-1) { + Tbslbrm, + p_decParams->BG, + p_decParams->Z, + harq_process->d[r], + harq_process->w[r], + harq_process->C, + harq_process->rvidx, + (harq_process->round==0)?1:0, + E)==-1) { #if UE_TIMING_TRACE stop_meas(dlsch_rate_unmatching_stats); #endif @@ -2104,7 +2096,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) } //for (int i =0; i<16; i++) - // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); + // printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); //r_offset += E; @@ -2136,71 +2128,71 @@ void *nr_dlsch_decoding_2thread1(void *arg) Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS, harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_ldpc_iterations); */ - if (llr8_flag1) { - AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", - Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); - } + if (llr8_flag1) { + AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n", + Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round); + } #if UE_TIMING_TRACE start_meas(dlsch_turbo_decoding_stats); #endif // LOG_D(PHY,"AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1); - memset(pv,0,2*p_decParams->Z*sizeof(int16_t)); + memset(pv,0,2*p_decParams->Z*sizeof(int16_t)); //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); - memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); + memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); - } + { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } - for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) - { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); - } + for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) + { + pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + } - for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) - { + for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) + { - pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); - } + } - no_iteration_ldpc = nrLDPC_decoder(p_decParams, - (int8_t*)&pl[0], - llrProcBuf, + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, p_nrLDPC_procBuf, - p_procTime); + p_procTime); - if (no_iteration_ldpc > 10) - printf("Error number of iteration LPDC %d\n", no_iteration_ldpc); - //else - // printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); + if (no_iteration_ldpc > 10) + printf("Error number of iteration LPDC %d\n", no_iteration_ldpc); + //else + // printf("OK number of iteration LPDC %d\n", no_iteration_ldpc); - for (int m=0; m < Kr>>3; m ++) - { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } + for (int m=0; m < Kr>>3; m ++) + { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } - /*for (int u=0; u < Kr>>3; u ++) - { - ullrProcBuf[u]= (uint8_t) llrProcBuf[u]; - } + /*for (int u=0; u < Kr>>3; u ++) + { + ullrProcBuf[u]= (uint8_t) llrProcBuf[u]; + } - printf("output unsigned ullrProcBuf \n"); + printf("output unsigned ullrProcBuf \n"); - for (int j=0; j < Kr>>3; j ++) - { + for (int j=0; j < Kr>>3; j ++) + { - printf(" %d \n", ullrProcBuf[j]); + printf(" %d \n", ullrProcBuf[j]); - } - printf(" \n");*/ + } + printf(" \n");*/ #endif - //printf("output channel decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); + //printf("output channel decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); - //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); + //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); #if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); @@ -2239,7 +2231,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) //printf("end 2thread1 proc->instance_cnt_dlsch_td1 %d\n", proc->instance_cnt_dlsch_td1); } - //printf("after 2thread1 after oai exit proc->instance_cnt_dlsch_td %d\n", proc->instance_cnt_dlsch_td1); + //printf("after 2thread1 after oai exit proc->instance_cnt_dlsch_td %d\n", proc->instance_cnt_dlsch_td1); // thread finished free(arg); return &UE_dlsch_td_retval1; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 4e46903ebf..b4b7463e18 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -42,8 +42,6 @@ - - void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) { int i; @@ -88,6 +86,8 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch) } + + NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag) { diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 2b36a03e61..29c4fed74d 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -404,7 +404,7 @@ int main(int argc, char **argv) { r_im[i] = malloc(frame_length_complex_samples * sizeof(double)); bzero(r_im[i], frame_length_complex_samples * sizeof(double)); txdata[i] = malloc(frame_length_complex_samples * sizeof(int)); - bzero(r_re[i], frame_length_complex_samples * sizeof(int)); + bzero(r_re[i], frame_length_complex_samples * sizeof(int)); // [hna] r_re should be txdata } if (pbch_file_fd != NULL) { @@ -480,7 +480,7 @@ int main(int argc, char **argv) { rel15->nb_layers = Nl; rel15->nb_re_dmrs = nb_re_dmrs; rel15->transport_block_size = TBS; - double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); + double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); double errors_bit_uncoded = 0; From d7abeed6abbc61b63ba45dbbe7f49f825a51a7c2 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 6 Mar 2019 16:48:37 +0100 Subject: [PATCH 28/54] Applying LDPC code rate fix at nr_ulsch_encoding --- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index b4b7463e18..70a34f2c66 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -200,18 +200,19 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, NR_UL_UE_HARQ_t *harq_process; uint16_t nb_rb ; uint8_t nb_symb_sch ; - uint32_t A, Z; + uint32_t A, Z, F; uint32_t *pz; uint8_t mod_order; uint16_t Kr,r,r_offset,Kr_bytes; uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; - uint8_t kb,BG; + uint8_t BG; uint32_t E; uint8_t Ilbrm; uint32_t Tbslbrm; uint8_t nb_re_dmrs; uint16_t length_dmrs; int i; + float Coderate; /////////// /////////////////////////////////////////////////////////////////////////////////////// @@ -230,10 +231,12 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, Kr=0; r_offset=0; BG = 1; + F=0; Ilbrm = 0; Tbslbrm = 950984; //max tbs nb_re_dmrs = ulsch->nb_re_dmrs; length_dmrs = 1; + Coderate = 0.0; /////////// ///////////////////////////////////////////////////////////////////////////////////////// @@ -251,7 +254,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,harq_process->Nl); - LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order); + LOG_D(PHY,"ulsch coding A %d G %d mod_order %d\n", A,G, mod_order); printf("ulsch coding A %d G %d mod_order %d\n", A,G, mod_order); Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, harq_process->Nl); @@ -266,7 +269,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, /////////// /* int i; - printf("dlsch (tx): \n"); + printf("ulsch (tx): \n"); for (i=0;i<(A>>3);i++) printf("%02x.",a[i]); printf("\n"); @@ -297,13 +300,15 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, pz, &harq_process->F); - kb = harq_process->K/(*pz); - if ( kb==22){ - BG = 1; - } - else{ - BG = 2; - } + F = harq_process->F; + Coderate = (float) A /(float) G; + + if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ + BG = 2; + } + else{ + BG = 1; + } Kr = harq_process->K; Kr_bytes = Kr>>3; @@ -316,7 +321,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ///////////////////////// c---->| LDCP coding |---->d ///////////////////////// /////////// - //printf("segment Z %d kb %d k %d Kr %d BG %d\n", *pz,kb,harq_process->K,Kr,BG); + //printf("segment Z %d k %d Kr %d BG %d\n", *pz,harq_process->K,Kr,BG); //start_meas(te_stats); for (r=0; rC; r++) { @@ -364,6 +369,15 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } for (r=0; rC; r++) { // looping over C segments + + if (harq_process->F>0) { + for (int k=(Kr-F-2*(*pz)); kd[r][k] = NR_NULL; + //if (k<(Kr-F+8)) + //printf("r %d filler bits [%d] = %d \n", r,k, harq_process->d[r][k]); + } + } + #ifdef DEBUG_DLSCH_CODING printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", r, From a1da7a2f9555965b7edf8bccd2422e4b1d73b384 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Wed, 6 Mar 2019 18:32:20 +0100 Subject: [PATCH 29/54] Applying LDPC code fix at "nr_ulsch_decoding.c" (works for mcs 4 to 28) --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 72 +++++++++++++------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 1d72507de9..ace93e4ee3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -187,7 +187,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t A,E; uint32_t G; uint32_t ret,offset; - int32_t no_iteration_ldpc; + int32_t no_iteration_ldpc, length_dec; uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; uint8_t crc_type; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); @@ -206,12 +206,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, int16_t z [68*384]; int8_t l [68*384]; int16_t inv_d [68*384]; - uint8_t kb, kc; + uint8_t kc; uint8_t Ilbrm = 0; uint32_t Tbslbrm = 950984; uint16_t nb_rb = 30; //to update uint8_t nb_re_dmrs = 6; uint16_t length_dmrs = 1; + double Coderate = 0.0; uint32_t i,j; @@ -249,6 +250,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, LOG_I(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, nfapi_ulsch_pdu_rel15->mcs, nfapi_ulsch_pdu_rel15->n_layers, nb_symb_sch,nb_rb); if (harq_process->round == 0) { + // This is a new packet, so compute quantities regarding segmentation harq_process->B = A+24; @@ -270,20 +272,43 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #endif } - kb = harq_process->K/harq_process->Z; + Coderate = (float) A /(float) G; - if ( kb==22) { - p_decParams->BG = 1; - p_decParams->R = 13; - kc = 68; - } else { + if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ p_decParams->BG = 2; - p_decParams->R = 13; - kc = 52; + if (Coderate < 0.3333) { + p_decParams->R = 15; + kc = 52; + } + else if (Coderate <0.6667) { + p_decParams->R = 13; + kc = 32; + } + else { + p_decParams->R = 23; + kc = 17; + } + } else { + p_decParams->BG = 1; + if (Coderate < 0.6667) { + p_decParams->R = 13; + kc = 68; + } + else if (Coderate <0.8889) { + p_decParams->R = 23; + kc = 35; + } + else { + p_decParams->R = 89; + kc = 27; + } } + //printf("coderate %f kc %d \n", Coderate, kc); + + + p_decParams->numMaxIter = ulsch->max_ldpc_iterations; - Kr = p_decParams->Z*kb; p_decParams->outMode= 0; err_flag = 0; @@ -410,10 +435,14 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, memset(harq_process->c[r],0,Kr_bytes); // printf("done\n"); - if (harq_process->C == 1) + if (harq_process->C == 1) { crc_type = CRC24_A; - else + length_dec = harq_process->B; + } + else { crc_type = CRC24_B; + length_dec = (harq_process->B+24*harq_process->C)/harq_process->C; + } if (err_flag == 0) { @@ -421,19 +450,18 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, start_meas(ulsch_turbo_decoding_stats); #endif - for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++) { - inv_d[cnt] = (1)*harq_process->d[r][cnt]; - } + //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A); + memset(pv,0,2*harq_process->Z*sizeof(int16_t)); memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); - for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++) { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) { + pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); } - for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) { - pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j])); + for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) { + pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); } for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) { @@ -455,8 +483,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, p_nrLDPC_procBuf[r], p_procTime); - if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { - printf("CRC OK\n"); + if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { + printf("Segment %d CRC OK\n",r); ret = 2; } else { printf("CRC NOK\n"); From af59ee996d742ce3bb50c982130374da210e6670 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 13 Feb 2019 12:45:01 +0100 Subject: [PATCH 30/54] Add build directories to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1ed392ef06..61d9558916 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ cmake_targets/log/ cmake_targets/ran_build/ +cmake_targets/*/build/ targets/bin/ From 980d20c8b8cbcd3560f2688cbfa7c828acb73dc3 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 7 Mar 2019 15:45:52 +0100 Subject: [PATCH 31/54] i_ssb detection message added in pbchsim --- openair1/SIMULATION/NR_PHY/pbchsim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index cc01357868..548a4f3dc3 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -412,7 +412,6 @@ int main(int argc, char **argv) // computation of integer and fractional FO to compare with estimation results int IFO; if(eps!=0.0){ - UE->UE_fo_compensation = 1; printf("Introducing a CFO of %lf relative to SCS of %d kHz\n",eps,(int)(scs/1000)); if (eps>0) IFO=(int)(eps+0.5); @@ -644,11 +643,11 @@ int main(int argc, char **argv) if (ret!=0) n_errors++; } } //noise trials - printf("SNR %f: trials %d, n_errors_crc = %d, n_errors_payload %d\n", SNR,n_trials,n_errors,n_errors_payload); if (((float)n_errors/(float)n_trials <= target_error_rate) && (n_errors_payload==0)) { printf("PBCH test OK\n"); + printf("Synchronization obtained for i_ssb = %d\n",UE->rx_ind.rx_indication_body[0].mib_pdu.ssb_index); break; } From 2d39da3b57fee88a477b1666c6fb2ed897316ad7 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 8 Mar 2019 17:12:23 +0100 Subject: [PATCH 32/54] inc no physim exectuables in CI script --- ci-scripts/oai-ci-vm-tool | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index 940bcd2852..fd867b6661 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -252,7 +252,7 @@ case $key in VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim LOG_PATTERN=.Rel15.txt - NB_PATTERN_FILES=8 + NB_PATTERN_FILES=9 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=4096 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" @@ -331,7 +331,7 @@ case $key in VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim LOG_PATTERN=.Rel15.txt - NB_PATTERN_FILES=8 + NB_PATTERN_FILES=9 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=4096 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" From 3fc4c6a4647ab10a2c4e17cf2143c70368188b9c Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 12 Mar 2019 12:51:01 +0100 Subject: [PATCH 33/54] multiple ssb detection via pbch dmrs (selection of best ssb only, working in pbchsim for SNR>=0) --- .../nr_dl_channel_estimation.c | 163 ++++++++++++++++++ openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 6 + .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 59 +++++-- openair1/PHY/defs_nr_UE.h | 9 + 4 files changed, 222 insertions(+), 15 deletions(-) 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 f17f6eb9b8..99267152b0 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -32,6 +32,169 @@ //#define DEBUG_PDCCH +int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, + unsigned char Ns, + unsigned char symbol, + NR_UE_SSB *current_ssb) +{ + int pilot[200] __attribute__((aligned(16))); + unsigned char aarx; + unsigned short k; + unsigned int pilot_cnt; + int16_t ch[2],*pil,*rxF; + int symbol_offset; + int dmrss; + + uint8_t nushift; + uint8_t ssb_index=current_ssb->i_ssb; + uint8_t n_hf=current_ssb->n_hf; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; + + nushift = ue->frame_parms.Nid_cell%4; + ue->frame_parms.nushift = nushift; + unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; + if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size; + + if (ue->is_synchronized ==0 ) dmrss = symbol-1; + else dmrss = symbol-5; + + AssertFatal((symbol > 0 && symbol < 4 && ue->is_synchronized == 0) || + (symbol > 4 && symbol < 8 && ue->is_synchronized == 1), + "symbol %d is illegal for PBCH DM-RS (is_synchronized %d)\n", + symbol,ue->is_synchronized); + + symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; + + + 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, + ue->frame_parms.Ncp,Ns,k, symbol); +#endif + + // generate pilot + nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); + + int re_offset = ssb_offset; + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + + pil = (int16_t *)&pilot[0]; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; + +#ifdef DEBUG_CH + printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); + printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); + printf("rxF addr %p\n", rxF); +#endif + //if ((ue->frame_parms.N_RB_DL&1)==0) { + + // Treat first 2 pilots specially (left edge) + 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); + + current_ssb->c_re +=ch[0]; + current_ssb->c_im +=ch[1]; + +#ifdef DEBUG_CH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif + + pil+=2; + 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); + + current_ssb->c_re +=ch[0]; + current_ssb->c_im +=ch[1]; + +#ifdef DEBUG_CH + printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + + pil+=2; + re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; + + current_ssb->c_re +=ch[0]; + current_ssb->c_im +=ch[1]; + +#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 + + pil+=2; + re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; + + for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) { + + // if (pilot_cnt == 30) + // rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)]; + + // in 2nd symbol, skip middle REs (48 with DMRS, 144 for SSS, and another 48 with DMRS) + if (dmrss == 1 && pilot_cnt == 12) { + pilot_cnt=48; + re_offset = (re_offset+144)&(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); + + current_ssb->c_re +=ch[0]; + current_ssb->c_im +=ch[1]; + +#ifdef DEBUG_CH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + + pil+=2; + 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); + + current_ssb->c_re +=ch[0]; + current_ssb->c_im +=ch[1]; + +#ifdef DEBUG_CH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + pil+=2; + 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); + + current_ssb->c_re +=ch[0]; + current_ssb->c_im +=ch[1]; + +#ifdef DEBUG_CH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + + pil+=2; + re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; + + } + + + //} + + } + return(0); +} + int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 591b4733ce..1ec9cec96f 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -50,6 +50,12 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned short coreset_start_subcarrier, unsigned short nb_rb_coreset); +int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, + unsigned char Ns, + unsigned char symbol, + NR_UE_SSB *current_ssb); + int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 0b9795b6bc..a147d10457 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -58,6 +58,11 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; + uint8_t best_ssb =0; + uint8_t n_hf =0; + uint32_t best_metric =0; + + NR_UE_SSB *current_ssb = malloc(sizeof(NR_UE_SSB)); #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync: starting PBCH detection (rx_offset %d)\n",ue->Mod_id, @@ -70,30 +75,53 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod // loops over possible pbch dmrs cases to retrive best estimated i_ssb (and n_hf for Lmax=4) for multiple ssb detection for (int hf = 0; hf < N_hf; hf++) { for (int l = 0; l < N_L ; l++) { - if (ret !=0) { + + // initialization of structure parameters + current_ssb->n_hf = hf; + current_ssb->i_ssb = l; + current_ssb->c_re = 0; + current_ssb->c_im = 0; #if UE_TIMING_TRACE - start_meas(&ue->dlsch_channel_estimation_stats); + start_meas(&ue->dlsch_channel_estimation_stats); #endif - for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); + stop_meas(&ue->dlsch_channel_estimation_stats); #endif - - ret = nr_rx_pbch(ue, - &ue->proc.proc_rxtx[0], - ue->pbch_vars[0], - frame_parms, - 0, - l, - SISO, - ue->high_speed_flag); - + + current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im+current_ssb->c_re; + + if(current_ssb->metric > best_metric) { // if metric of current structure is higher than the best one + best_metric = current_ssb->metric; + best_ssb = l; + n_hf = hf; } + } } +#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); +#endif + // computing channel estimation for selected best ssb + for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); +#endif + + ret = nr_rx_pbch(ue, + &ue->proc.proc_rxtx[0], + ue->pbch_vars[0], + frame_parms, + 0, + best_ssb, + SISO, + ue->high_speed_flag); + if (ret==0) { frame_parms->nb_antenna_ports_eNB = 1; //pbch_tx_ant; @@ -116,6 +144,7 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully\n",ue->Mod_id); #endif + return(0); } else { return(-1); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a482a48207..a846f46e0f 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -950,6 +950,15 @@ typedef struct { int16_t *prach; } NR_UE_PRACH; +// structure used for multiple SSB detection +typedef struct NR_UE_SSB { + uint8_t i_ssb; // i_ssb between 0 and 7 (it corresponds to ssb_index only for Lmax=4,8) + uint8_t n_hf; // n_hf = 0,1 for Lmax =4 or n_hf = 0 for Lmax =8,64 + uint32_t metric; // metric to order SSB hypothesis + uint32_t c_re; + uint32_t c_im; +} NR_UE_SSB; + /*typedef enum { /// do not detect any DCIs in the current subframe NO_DCI = 0x0, From 2c75720d798bae449649841e84fc33fbb42f6558 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 13 Mar 2019 17:48:23 +0100 Subject: [PATCH 34/54] multiple ssb detection via pbch dmrs (ordered list) --- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 104 +++++++++++++----- openair1/PHY/defs_nr_UE.h | 3 +- 2 files changed, 79 insertions(+), 28 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index a147d10457..e75f5a647a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -54,15 +54,61 @@ int cnt=0; #define DEBUG_INITIAL_SYNCH +// create a new node of SSB structure +NR_UE_SSB* create_ssb_node(uint8_t i, uint8_t h) { + + NR_UE_SSB *new_node = (NR_UE_SSB*)malloc(sizeof(NR_UE_SSB)); + new_node->i_ssb = i; + new_node->n_hf = h; + new_node->c_re = 0; + new_node->c_im = 0; + new_node->metric = 0; + new_node->next_ssb = NULL; + + return new_node; +} + + +// insertion of the structure in the ordered list (highest metric first) +NR_UE_SSB* insert_into_list(NR_UE_SSB *head, NR_UE_SSB *node) { + + if (node->metric > head->metric) { + node->next_ssb = head; + head = node; + return head; + } + + NR_UE_SSB *current = head; + while (current->next_ssb !=NULL) { + NR_UE_SSB *temp=current->next_ssb; + if(node->metric > current->metric) { + node->next_ssb = temp; + current->next_ssb = node; + return head; + } + else + current = temp; + } + current->next_ssb = node; + + return head; +} + + +void free_list(NR_UE_SSB *node) { + if (node->next_ssb != NULL) + free_list(node->next_ssb); + free(node); +} + + int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mode) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; - uint8_t best_ssb =0; - uint8_t n_hf =0; - uint32_t best_metric =0; - NR_UE_SSB *current_ssb = malloc(sizeof(NR_UE_SSB)); + NR_UE_SSB *best_ssb = NULL; + NR_UE_SSB *current_ssb; #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync: starting PBCH detection (rx_offset %d)\n",ue->Mod_id, @@ -76,11 +122,8 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod for (int hf = 0; hf < N_hf; hf++) { for (int l = 0; l < N_L ; l++) { - // initialization of structure parameters - current_ssb->n_hf = hf; - current_ssb->i_ssb = l; - current_ssb->c_re = 0; - current_ssb->c_im = 0; + // initialization of structure + current_ssb = create_ssb_node(l,hf); #if UE_TIMING_TRACE start_meas(&ue->dlsch_channel_estimation_stats); @@ -94,34 +137,42 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im+current_ssb->c_re; - if(current_ssb->metric > best_metric) { // if metric of current structure is higher than the best one - best_metric = current_ssb->metric; - best_ssb = l; - n_hf = hf; - } + // generate a list of SSB structures + if (best_ssb == NULL) + best_ssb = current_ssb; + else + best_ssb = insert_into_list(best_ssb,current_ssb); } } + NR_UE_SSB *temp_ptr=best_ssb; + while (ret!=0 && temp_ptr != NULL) { + #if UE_TIMING_TRACE - start_meas(&ue->dlsch_channel_estimation_stats); + start_meas(&ue->dlsch_channel_estimation_stats); #endif // computing channel estimation for selected best ssb - for(int i=pbch_initial_symbol; ii_ssb,best_ssb->n_hf); #if UE_TIMING_TRACE - stop_meas(&ue->dlsch_channel_estimation_stats); + stop_meas(&ue->dlsch_channel_estimation_stats); #endif - ret = nr_rx_pbch(ue, - &ue->proc.proc_rxtx[0], - ue->pbch_vars[0], - frame_parms, - 0, - best_ssb, - SISO, - ue->high_speed_flag); + ret = nr_rx_pbch(ue, + &ue->proc.proc_rxtx[0], + ue->pbch_vars[0], + frame_parms, + 0, + temp_ptr->i_ssb, + SISO, + ue->high_speed_flag); + temp_ptr=temp_ptr->next_ssb; + } + + free_list(best_ssb); + if (ret==0) { frame_parms->nb_antenna_ports_eNB = 1; //pbch_tx_ant; @@ -144,7 +195,6 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully\n",ue->Mod_id); #endif - return(0); } else { return(-1); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a846f46e0f..2a17bbbbe5 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -957,6 +957,7 @@ typedef struct NR_UE_SSB { uint32_t metric; // metric to order SSB hypothesis uint32_t c_re; uint32_t c_im; + struct NR_UE_SSB *next_ssb; } NR_UE_SSB; /*typedef enum { @@ -1088,7 +1089,7 @@ typedef struct { uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; /// PDSCH DMRS - uint32_t nr_gold_pdsch[2][20][2][21]; + uint32_t nr_gold_pdsch[2][20][2][52]; /// PDCCH DMRS uint32_t nr_gold_pdcch[7][20][3][52]; From cc847e9c5c9a4d4c618ff668c3a3cb77fbcceeb2 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 14 Mar 2019 17:29:17 +0100 Subject: [PATCH 35/54] bugfix in nr_initial_sync --- openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index e75f5a647a..26c01d3bb6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -154,7 +154,7 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod #endif // computing channel estimation for selected best ssb for(int i=pbch_initial_symbol; ii_ssb,best_ssb->n_hf); + nr_pbch_channel_estimation(ue,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); #endif From 02d3decd6d74f50adaac09986c8d9bfe1440a28a Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 15 Mar 2019 12:43:47 +0100 Subject: [PATCH 36/54] another bugfix nr_initial_sync --- openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 26c01d3bb6..23baadda8a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -81,7 +81,7 @@ NR_UE_SSB* insert_into_list(NR_UE_SSB *head, NR_UE_SSB *node) { NR_UE_SSB *current = head; while (current->next_ssb !=NULL) { NR_UE_SSB *temp=current->next_ssb; - if(node->metric > current->metric) { + if(node->metric > temp->metric) { node->next_ssb = temp; current->next_ssb = node; return head; From afb40cf509507b96d7f245d2fe7ce91043e6b8c3 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Mon, 18 Mar 2019 17:13:19 +0100 Subject: [PATCH 37/54] CI: trying to increase the RAM size on the phy-sim VM Signed-off-by: Raphael Defosseux --- ci-scripts/oai-ci-vm-tool | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index fd867b6661..1245d046ff 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -254,7 +254,7 @@ case $key in LOG_PATTERN=.Rel15.txt NB_PATTERN_FILES=9 BUILD_OPTIONS="--phy_simulators" - VM_MEMORY=4096 + VM_MEMORY=8192 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" NBARGS=$[$NBARGS+256] shift @@ -333,7 +333,7 @@ case $key in LOG_PATTERN=.Rel15.txt NB_PATTERN_FILES=9 BUILD_OPTIONS="--phy_simulators" - VM_MEMORY=4096 + VM_MEMORY=8192 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" NBARGS=$[$NBARGS+256] ;; From b68366e54ae41f899283f4324e7d97ec322dd649 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 5 Mar 2019 09:50:03 +0100 Subject: [PATCH 38/54] bugfix --- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 a90450b0a5..079cec04b9 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -50,8 +50,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; uint8_t nushift, ssb_index=0, n_hf=0; - int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset]; - int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; + int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_offset]; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; @@ -78,7 +78,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, k = nushift; #ifdef DEBUG_CH - printf("PBCH 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>>1], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, + printf("PBCH 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); #endif From 8e5c8ad2dfd0dc2e264231231ba7ac1a3cf196b2 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 8 Mar 2019 11:09:08 +0100 Subject: [PATCH 39/54] adding external ref to config file --- .../GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3aaf0c5506..24a6e69e7c 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 @@ -254,7 +254,7 @@ RUs = ( max_pdschReferenceSignalPower = -27; max_rxgain = 114; eNB_instances = [0]; - sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.100.8"; + sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.100.8,clock_source=external,time_source=external"; } ); From 02de5fd0782e4dec388c1bb84545925a6180121c Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 8 Mar 2019 11:09:31 +0100 Subject: [PATCH 40/54] disabling debug messages --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 6f2f5bcf2d..2e02ab5811 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -1418,11 +1418,11 @@ void nr_dci_decoding_procedure0(int s, *format_found=_format_2_3_found; } - //#ifdef NR_PDCCH_DCI_DEBUG +#ifdef NR_PDCCH_DCI_DEBUG printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d\n",*format_found); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled); + #endif - //#endif if (*format_found!=255) { dci_alloc[*dci_cnt].dci_length = sizeof_bits; dci_alloc[*dci_cnt].rnti = crc; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index e821e9696a..c067142897 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -52,7 +52,7 @@ //#define DEBUG_DCI #define NR_PDCCH_DCI_TOOLS -#define NR_PDCCH_DCI_TOOLS_DEBUG +//#define NR_PDCCH_DCI_TOOLS_DEBUG typedef unsigned __int128 uint128_t; From c4188d80130f7bb260b998f9f9fa75a55607626e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 8 Mar 2019 11:09:56 +0100 Subject: [PATCH 41/54] moving adjust sync out of measurement procedures and making it dependent on successfull decoding of DCI --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 60 ++++++++------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1a631000f5..1dc042e93a 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2760,37 +2760,6 @@ void nr_ue_measurement_procedures( } #endif - // accumulate and filter timing offset estimation every nr_tti_rx (instead of every frame) - if (( slot == 2) && (l==(1-frame_parms->Ncp))) { - - // AGC -/* - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL, VCD_FUNCTION_IN); - -#ifndef OAI_USRP -#ifndef OAI_BLADERF -#ifndef OAI_LMSSDR -#ifndef OAI_ADRV9371_ZC706 - phy_adjust_gain (ue,dB_fixed(ue->measurements.rssi),0); -#endif -#endif -#endif -#endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL, VCD_FUNCTION_OUT); -*/ - eNB_id = 0; - - LOG_D(PHY,"start adjust sync l = %d slot = %d no timing %d\n",l, slot, ue->no_timing_correction); - if (ue->no_timing_correction==0) - nr_adjust_synch_ue(&ue->frame_parms, - ue, - eNB_id, - nr_tti_rx, - 0, - 16384); - - } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); } @@ -3364,7 +3333,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * } // end for loop nb_searchspace_active - return(0); + return(dci_cnt); } #endif // NR_PDCCH_SCHED @@ -4969,6 +4938,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 dci_cnt = 0; LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx); @@ -4978,7 +4948,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN #ifdef NR_PDCCH_SCHED nr_gold_pdcch(ue,0, 2); - //if (nr_tti_rx==1){ + LOG_D(PHY," ------ --> PDCCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); for (uint16_t l=0; lMod_id,frame_rx,nr_tti_rx); - return(-1); + dci_cnt = nr_ue_pdcch_procedures(eNB_id,ue,proc); + + if (dci_cnt > 0) { + + LOG_I(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n",ue->Mod_id,frame_rx,nr_tti_rx,dci_cnt); + + if (0/*ue->no_timing_correction==0*/) { + LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); + nr_adjust_synch_ue(&ue->frame_parms, + ue, + eNB_id, + nr_tti_rx, + 0, + 16384); + } + } + else { + LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: No DCIs found\n",ue->Mod_id,frame_rx,nr_tti_rx); } - //} #endif //NR_PDCCH_SCHED From 7ca8fc9de1a2bbaea6fb587bca6c219b81f49e4e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 19 Mar 2019 15:43:20 +0100 Subject: [PATCH 42/54] increasing timeout on trx_read for x300/n300 in usrp_lib.cpp removing unncesessary sleeps and mallocs, improving error messages in nr-ue.c --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 4 +- targets/RT/USER/nr-ue.c | 48 ++++++-------------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index ffdec958a9..58a8697f79 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -597,10 +597,10 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp for (int i=0; irx_stream->recv(buff_ptrs, nsamps, s->rx_md); + samples_received = s->rx_stream->recv(buff_ptrs, nsamps, s->rx_md,1.0); } else { // receive a single channel (e.g. from connector RF A) - samples_received = s->rx_stream->recv(buff[0], nsamps, s->rx_md); + samples_received = s->rx_stream->recv(buff[0], nsamps, s->rx_md,1.0); } } diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 4ab0781787..e3e5cb962e 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -756,10 +756,6 @@ static void *UE_thread_rxn_txnp4(void *arg) { void readFrame(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 i=0; iframe_parms.nb_antennas_rx; i++) @@ -770,37 +766,28 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { timestamp, rxp, UE->frame_parms.samples_per_subframe, - UE->frame_parms.nb_antennas_rx), ""); + UE->frame_parms.nb_antennas_rx), "readFrame error"); } - for (int i=0; iframe_parms.nb_antennas_tx; i++) - free(dummy_tx[i]); } void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { - 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); - void *dummy_rx[UE->frame_parms.nb_antennas_rx]; for (int i=0; iframe_parms.nb_antennas_rx; i++) dummy_rx[i]=malloc16(UE->frame_parms.samples_per_subframe*4); for (int sf=0; sfrfdevice.trx_read_func(&UE->rfdevice, - timestamp, - dummy_rx, - UE->frame_parms.samples_per_subframe, - UE->frame_parms.nb_antennas_rx); - usleep(500); // this sleep improves in the case of simulated RF and doesn't harm with true radio + //printf("Reading dummy sf %d\n",sf); + AssertFatal( UE->frame_parms.samples_per_subframe == + UE->rfdevice.trx_read_func(&UE->rfdevice, + timestamp, + dummy_rx, + UE->frame_parms.samples_per_subframe, + UE->frame_parms.nb_antennas_rx), "trashFrame error"); + //usleep(500); // this sleep improves in the case of simulated RF and doesn't harm with true radio } - for (int i=0; iframe_parms.nb_antennas_tx; i++) - free(dummy_tx[i]); - for (int i=0; iframe_parms.nb_antennas_rx; i++) free(dummy_rx[i]); } @@ -808,10 +795,6 @@ void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { if (UE->no_timing_correction==0) { LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); - 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 size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) { int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ; @@ -820,11 +803,8 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { timestamp, (void **)UE->common_vars.rxdata, unitTransfer, - UE->frame_parms.nb_antennas_rx),""); + UE->frame_parms.nb_antennas_rx),"syncInFrame error"); } - - for (int i=0; iframe_parms.nb_antennas_tx; i++) - free(dummy_tx[i]); } } @@ -952,7 +932,7 @@ void *UE_thread(void *arg) { ×tamp, (void **)UE->common_vars.rxdata, UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, - UE->frame_parms.nb_antennas_rx),""); + UE->frame_parms.nb_antennas_rx),"first symbol read error"); //write_output("txdata_sym.m", "txdata_sym", UE->common_vars.rxdata[0], (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0), 1, 1); //nr_slot_fep(UE,0, 0, 0, 1, 1, NR_PDCCH_EST); } //UE->mode != loop_through_memory @@ -1031,7 +1011,7 @@ void *UE_thread(void *arg) { ×tamp, rxp, readBlockSize, - UE->frame_parms.nb_antennas_rx),""); + UE->frame_parms.nb_antennas_rx),"read error"); AssertFatal( writeBlockSize == UE->rfdevice.trx_write_func(&UE->rfdevice, timestamp+ @@ -1041,7 +1021,7 @@ void *UE_thread(void *arg) { txp, writeBlockSize, UE->frame_parms.nb_antennas_tx, - 1),""); + 1),"write error"); if( slot_nr==(nb_slot_frame-1)) { // read in first symbol of next frame and adjust for timing drift @@ -1053,7 +1033,7 @@ void *UE_thread(void *arg) { ×tamp, (void **)UE->common_vars.rxdata, first_symbols, - UE->frame_parms.nb_antennas_rx),""); + UE->frame_parms.nb_antennas_rx),"first symbols read error"); else LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); } From c3e567bb33902ed8665df17231703c64a11bd70b Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 22 Mar 2019 10:17:03 +0100 Subject: [PATCH 43/54] CI: removing TDD 20MHz scenarios from CI test-suite temporarly Signed-off-by: Raphael Defosseux --- ...0mhz_tm1.xml => enb_usrp210_band40_test_20mhz_tm1_not_run.xml} | 0 ...test_20mhz.xml => if4p5_usrp210_band40_test_20mhz_not_run.xml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename ci-scripts/xml_files/{enb_usrp210_band40_test_20mhz_tm1.xml => enb_usrp210_band40_test_20mhz_tm1_not_run.xml} (100%) rename ci-scripts/xml_files/{if4p5_usrp210_band40_test_20mhz.xml => if4p5_usrp210_band40_test_20mhz_not_run.xml} (100%) diff --git a/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1_not_run.xml similarity index 100% rename from ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1.xml rename to ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1_not_run.xml diff --git a/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz_not_run.xml similarity index 100% rename from ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml rename to ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz_not_run.xml From 0ba1958e3991de12a8f06ba42d460a9f58033714 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 22 Mar 2019 11:59:22 +0100 Subject: [PATCH 44/54] CI: fix when XML file is missing during HtmlInit Signed-off-by: Raphael Defosseux --- ci-scripts/main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 70bfa1894f..dc101fe7ea 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -2542,14 +2542,19 @@ elif re.match('^InitiateHtml$', mode, re.IGNORECASE): Usage() sys.exit('Insufficient Parameter') count = 0 + foundCount = 0 while (count < SSH.nbTestXMLfiles): xml_test_file = sys.path[0] + "/" + SSH.testXMLfiles[count] - xmlTree = ET.parse(xml_test_file) - xmlRoot = xmlTree.getroot() - SSH.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-' + str(count))) - SSH.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-' + str(count))) - SSH.htmlTabIcons.append(xmlRoot.findtext('htmlTabIcon',default='info-sign')) + if (os.path.isfile(xml_test_file)): + xmlTree = ET.parse(xml_test_file) + xmlRoot = xmlTree.getroot() + SSH.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-' + str(count))) + SSH.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-' + str(count))) + SSH.htmlTabIcons.append(xmlRoot.findtext('htmlTabIcon',default='info-sign')) + foundCount += 1 count += 1 + if foundCount != SSH.nbTestXMLfiles: + SSH.nbTestXMLfiles = foundCount SSH.CreateHtmlHeader() elif re.match('^FinalizeHtml$', mode, re.IGNORECASE): SSH.CreateHtmlFooter(SSH.finalStatus) From 0f04910f2f6d5349d976ae6d75bdaee561599417 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 22 Mar 2019 15:22:19 +0100 Subject: [PATCH 45/54] moving get_band to separate function --- openair1/PHY/INIT/nr_parms.c | 63 ++++++++++++++++++++++++++++++++ openair1/PHY/INIT/phy_init.h | 3 ++ openair1/PHY/defs_nr_common.h | 17 +++++++++ targets/RT/USER/nr-ue.c | 39 ++------------------ targets/RT/USER/nr-uesoftmodem.c | 14 +++---- 5 files changed, 93 insertions(+), 43 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 021d0b10bb..7fee692f08 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -300,3 +300,66 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp) LOG_I(PHY,"fp->initial_bwp_dl.location=%d\n",fp->initial_bwp_dl.location); LOG_I(PHY,"fp->initial_bwp_dl.ofdm_symbol_size=%d\n",fp->initial_bwp_dl.ofdm_symbol_size); } + + +static const eutra_band_t eutra_bands[] = { + {1, 1920000, 1980000, 2110000, 2170000, FDD}, + {2, 1850000, 1910000, 1930000, 1990000, FDD}, + {3, 1710000, 1785000, 1805000, 1880000, FDD}, + {5, 824000, 849000, 869000, 894000, FDD}, + {7, 2500000, 2570000, 2620000, 2690000, FDD}, + {8, 880000, 915000, 925000, 960000, FDD}, + {12, 698000, 716000, 728000, 746000, FDD}, + {20, 832000, 862000, 791000, 821000, FDD}, + {25, 1850000, 1915000, 1930000, 1995000, FDD}, + {28, 703000, 758000, 758000, 813000, FDD}, + {34, 2010000, 2025000, 2010000, 2025000, TDD}, + {38, 2570000, 2620000, 2570000, 2630000, TDD}, + {39, 1880000, 1920000, 1880000, 1920000, TDD}, + {40, 2300000, 2400000, 2300000, 2400000, TDD}, + {41, 2496000, 2690000, 2496000, 2690000, TDD}, + {50, 1432000, 1517000, 1432000, 1517000, TDD}, + {51, 1427000, 1432000, 1427000, 1432000, TDD}, + {66, 1710000, 1780000, 2110000, 2200000, FDD}, + {70, 1695000, 1710000, 1995000, 2020000, FDD}, + {71, 663000, 698000, 617000, 652000, FDD}, + {74, 1427000, 1470000, 1475000, 1518000, FDD}, + {75, 000, 000, 1432000, 1517000, FDD}, + {76, 000, 000, 1427000, 1432000, FDD}, + {77, 3300000, 4200000, 3300000, 4200000, TDD}, + {78, 3300000, 3800000, 3300000, 3800000, TDD}, + {79, 4400000, 5000000, 4400000, 5000000, TDD}, + {80, 1710000, 1785000, 000, 000, FDD}, + {81, 860000, 915000, 000, 000, FDD}, + {82, 832000, 862000, 000, 000, FDD}, + {83, 703000, 748000, 000, 000, FDD}, + {84, 1920000, 1980000, 000, 000, FDD}, + {86, 1710000, 1785000, 000, 000, FDD} +}; + +int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { + + int ind; + int64_t dl_freq_khz = downlink_frequency/1000; + for ( ind=0; + ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]); + ind++) { + *current_band = eutra_bands[ind].band; + *current_type = eutra_bands[ind].frame_type; + LOG_I(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", ind, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min); + + if ( eutra_bands[ind].dl_min <= dl_freq_khz && eutra_bands[ind].dl_max >= dl_freq_khz ) { + *current_offset = (eutra_bands[ind].ul_min - eutra_bands[ind].dl_min)*1000; + + LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", + downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); + break; + } + } + + if( ind == sizeof(eutra_bands) / sizeof(eutra_bands[0])) { + LOG_E(PHY,"Can't find EUTRA band for frequency %d\n", downlink_frequency); + return(-1); + } +} + diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index ddda39a4c8..f500375e4b 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -391,6 +391,9 @@ void init_nr_transport(PHY_VARS_gNB *gNB); void init_dfts(void); +int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); + + /** @} */ #endif diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 267c156184..c09566c67e 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -321,4 +321,21 @@ typedef struct NR_DL_FRAME_PARMS { } NR_DL_FRAME_PARMS; +#define KHz (1000UL) +#define MHz (1000*KHz) + +typedef struct eutra_band_s { + int16_t band; + uint32_t ul_min; + uint32_t ul_max; + uint32_t dl_min; + uint32_t dl_max; + lte_frame_type_t frame_type; +} eutra_band_t; + +typedef struct band_info_s { + int nbands; + eutra_band_t band_info[100]; +} band_info_t; + #endif diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index afab7be1ad..a4afdcd6b6 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -150,27 +150,12 @@ void init_UE(int nb_inst); int32_t **rxdata; int32_t **txdata; -#define KHz (1000UL) -#define MHz (1000*KHz) #define SAIF_ENABLED #ifdef SAIF_ENABLED uint64_t g_ue_rx_thread_busy = 0; #endif -typedef struct eutra_band_s { - int16_t band; - uint32_t ul_min; - uint32_t ul_max; - uint32_t dl_min; - uint32_t dl_max; - lte_frame_type_t frame_type; -} eutra_band_t; - -typedef struct band_info_s { - int nbands; - eutra_band_t band_info[100]; -} band_info_t; band_info_t bands_to_scan; @@ -354,29 +339,11 @@ static void *UE_thread_synch(void *arg) { init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); UE->is_synchronized = 0; + printf("UE_scan %d\n",UE->UE_scan); + if (UE->UE_scan == 0) { - int ind; - int64_t dl_freq_khz = downlink_frequency[0][0]/1000; - for ( ind=0; - ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]); - ind++) { - current_band = eutra_bands[ind].band; - current_type = eutra_bands[ind].frame_type; - LOG_D(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", current_band, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min); - if ( eutra_bands[ind].dl_min <= dl_freq_khz && eutra_bands[ind].dl_max >= dl_freq_khz ) { - for (i=0; i<4; i++) - uplink_frequency_offset[CC_id][i] = (eutra_bands[ind].ul_min - eutra_bands[ind].dl_min)*1000; - - break; - } - } - - - AssertFatal( ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]), "Can't find EUTRA band for frequency"); - - UE->frame_parms.eutra_band = current_band; - UE->frame_parms.frame_type = current_type; + get_band(downlink_frequency[CC_id][0], &UE->frame_parms.eutra_band, &uplink_frequency_offset[CC_id][0], &UE->frame_parms.frame_type); LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n", downlink_frequency[0][0], downlink_frequency[0][0]+uplink_frequency_offset[0][0], diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index bb3dfe8282..226010a1db 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -932,14 +932,14 @@ int main( int argc, char **argv ) { LOG_I(PHY,"Set nb_rx_antenna %d , nb_tx_antenna %d \n",frame_parms[CC_id]->nb_antennas_rx, frame_parms[CC_id]->nb_antennas_tx); - //init_ul_hopping(frame_parms[CC_id]); - //phy_init_nr_top(frame_parms[CC_id]); - } + get_band(downlink_frequency[CC_id][0], &frame_parms[CC_id]->eutra_band, &uplink_frequency_offset[CC_id][0], &frame_parms[CC_id]->frame_type); - for (CC_id=0; CC_idprach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type); - // N_ZC = (prach_fmt <4)?839:139; + //init_ul_hopping(frame_parms[CC_id]); + //phy_init_nr_top(frame_parms[CC_id]); + + //init prach for openair1 test + // prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type); + // N_ZC = (prach_fmt <4)?839:139; } NB_UE_INST=1; From 0d91083eadc4a35e4a7370db03ab4a9f32468270 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 22 Mar 2019 17:40:47 +0100 Subject: [PATCH 46/54] trying to harmonize the nr_bandtable --- openair1/PHY/INIT/nr_parms.c | 83 +++++++++++++++-------------- openair1/PHY/defs_nr_common.h | 20 +++---- openair2/LAYER2/NR_MAC_gNB/config.c | 56 ++----------------- targets/RT/USER/nr-ue.c | 44 ++------------- 4 files changed, 62 insertions(+), 141 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 7fee692f08..095101fb89 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -302,39 +302,39 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp) } -static const eutra_band_t eutra_bands[] = { - {1, 1920000, 1980000, 2110000, 2170000, FDD}, - {2, 1850000, 1910000, 1930000, 1990000, FDD}, - {3, 1710000, 1785000, 1805000, 1880000, FDD}, - {5, 824000, 849000, 869000, 894000, FDD}, - {7, 2500000, 2570000, 2620000, 2690000, FDD}, - {8, 880000, 915000, 925000, 960000, FDD}, - {12, 698000, 716000, 728000, 746000, FDD}, - {20, 832000, 862000, 791000, 821000, FDD}, - {25, 1850000, 1915000, 1930000, 1995000, FDD}, - {28, 703000, 758000, 758000, 813000, FDD}, - {34, 2010000, 2025000, 2010000, 2025000, TDD}, - {38, 2570000, 2620000, 2570000, 2630000, TDD}, - {39, 1880000, 1920000, 1880000, 1920000, TDD}, - {40, 2300000, 2400000, 2300000, 2400000, TDD}, - {41, 2496000, 2690000, 2496000, 2690000, TDD}, - {50, 1432000, 1517000, 1432000, 1517000, TDD}, - {51, 1427000, 1432000, 1427000, 1432000, TDD}, - {66, 1710000, 1780000, 2110000, 2200000, FDD}, - {70, 1695000, 1710000, 1995000, 2020000, FDD}, - {71, 663000, 698000, 617000, 652000, FDD}, - {74, 1427000, 1470000, 1475000, 1518000, FDD}, - {75, 000, 000, 1432000, 1517000, FDD}, - {76, 000, 000, 1427000, 1432000, FDD}, - {77, 3300000, 4200000, 3300000, 4200000, TDD}, - {78, 3300000, 3800000, 3300000, 3800000, TDD}, - {79, 4400000, 5000000, 4400000, 5000000, TDD}, - {80, 1710000, 1785000, 000, 000, FDD}, - {81, 860000, 915000, 000, 000, FDD}, - {82, 832000, 862000, 000, 000, FDD}, - {83, 703000, 748000, 000, 000, FDD}, - {84, 1920000, 1980000, 000, 000, FDD}, - {86, 1710000, 1785000, 000, 000, FDD} +nr_bandentry_t nr_bandtable[] = { + {1, 1920000, 1980000, 2110000, 2170000, 20, 422000}, + {2, 1850000, 1910000, 1930000, 1990000, 20, 386000}, + {3, 1710000, 1785000, 1805000, 1880000, 20, 361000}, + {5, 824000, 849000, 869000, 894000, 20, 173800}, + {7, 2500000, 2570000, 2620000, 2690000, 20, 524000}, + {8, 880000, 915000, 925000, 960000, 20, 185000}, + {12, 698000, 716000, 728000, 746000, 20, 145800}, + {20, 832000, 862000, 791000, 821000, 20, 158200}, + {25, 1850000, 1915000, 1930000, 1995000, 20, 386000}, + {28, 703000, 758000, 758000, 813000, 20, 151600}, + {34, 2010000, 2025000, 2010000, 2025000, 20, 402000}, + {38, 2570000, 2620000, 2570000, 2630000, 20, 514000}, + {39, 1880000, 1920000, 1880000, 1920000, 20, 376000}, + {40, 2300000, 2400000, 2300000, 2400000, 20, 460000}, + {41, 2496000, 2690000, 2496000, 2690000, 3, 499200}, + {50, 1432000, 1517000, 1432000, 1517000, 20, 286400}, + {51, 1427000, 1432000, 1427000, 1432000, 20, 285400}, + {66, 1710000, 1780000, 2110000, 2200000, 20, 422000}, + {70, 1695000, 1710000, 1995000, 2020000, 20, 399000}, + {71, 663000, 698000, 617000, 652000, 20, 123400}, + {74, 1427000, 1470000, 1475000, 1518000, 20, 295000}, + {75, 000, 000, 1432000, 1517000, 20, 286400}, + {76, 000, 000, 1427000, 1432000, 20, 285400}, + {77, 3300000, 4200000, 3300000, 4200000, 1, 620000}, + {78, 3300000, 3800000, 3300000, 3800000, 1, 620000}, + {79, 4400000, 5000000, 4400000, 5000000, 2, 693334}, + {80, 1710000, 1785000, 000, 000, 20, 342000}, + {81, 860000, 915000, 000, 000, 20, 176000}, + {82, 832000, 862000, 000, 000, 20, 166400}, + {83, 703000, 748000, 000, 000, 20, 140600}, + {84, 1920000, 1980000, 000, 000, 20, 384000}, + {86, 1710000, 1785000, 000, 000, 20, 342000} }; int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { @@ -342,14 +342,17 @@ int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *cu int ind; int64_t dl_freq_khz = downlink_frequency/1000; for ( ind=0; - ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]); + ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); ind++) { - *current_band = eutra_bands[ind].band; - *current_type = eutra_bands[ind].frame_type; - LOG_I(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", ind, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min); + *current_band = nr_bandtable[ind].band; + LOG_I(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); - if ( eutra_bands[ind].dl_min <= dl_freq_khz && eutra_bands[ind].dl_max >= dl_freq_khz ) { - *current_offset = (eutra_bands[ind].ul_min - eutra_bands[ind].dl_min)*1000; + if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { + *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; + if (*current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); @@ -357,7 +360,7 @@ int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *cu } } - if( ind == sizeof(eutra_bands) / sizeof(eutra_bands[0])) { + if( ind == sizeof(nr_bandtable) / sizeof(nr_bandtable[0])) { LOG_E(PHY,"Can't find EUTRA band for frequency %d\n", downlink_frequency); return(-1); } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index c09566c67e..605ce8c4c8 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -324,18 +324,20 @@ typedef struct NR_DL_FRAME_PARMS { #define KHz (1000UL) #define MHz (1000*KHz) -typedef struct eutra_band_s { +typedef struct nr_bandentry_s { int16_t band; - uint32_t ul_min; - uint32_t ul_max; - uint32_t dl_min; - uint32_t dl_max; - lte_frame_type_t frame_type; -} eutra_band_t; + uint64_t ul_min; + uint64_t ul_max; + uint64_t dl_min; + uint64_t dl_max; + uint64_t N_OFFs_DL; + uint64_t step_size; +} nr_bandentry_t; typedef struct band_info_s { int nbands; - eutra_band_t band_info[100]; -} band_info_t; + nr_bandentry_t band_info[100]; +} nr_band_info_t; + #endif diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 12d01981d2..1e1258e089 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -49,59 +49,9 @@ extern RAN_CONTEXT_t RC; extern void mac_top_init_gNB(void); extern uint8_t nfapi_mode; -int32_t **rxdata; -int32_t **txdata; - -typedef struct nr_bandentry_s { - int16_t band; - uint64_t ul_min; - uint64_t ul_max; - uint64_t dl_min; - uint64_t dl_max; - uint64_t N_OFFs_DL; - uint64_t step_size; -} nr_bandentry_t; - -typedef struct band_info_s { - int nbands; - nr_bandentry_t band_info[100]; -} nr_band_info_t; - -static const nr_bandentry_t nr_bandtable[] = { - {1, 1920000, 1980000, 2110000, 2170000, 20, 422000}, - {2, 1850000, 1910000, 1930000, 1990000, 20, 386000}, - {3, 1710000, 1785000, 1805000, 1880000, 20, 361000}, - {5, 824000, 849000, 869000, 894000, 20, 173800}, - {7, 2500000, 2570000, 2620000, 2690000, 20, 524000}, - {8, 880000, 915000, 925000, 960000, 20, 185000}, - {12, 698000, 716000, 728000, 746000, 20, 145800}, - {20, 832000, 862000, 791000, 821000, 20, 158200}, - {25, 1850000, 1915000, 1930000, 1995000, 20, 386000}, - {28, 703000, 758000, 758000, 813000, 20, 151600}, - {34, 2010000, 2025000, 2010000, 2025000, 20, 402000}, - {38, 2570000, 2620000, 2570000, 2630000, 20, 514000}, - {39, 1880000, 1920000, 1880000, 1920000, 20, 376000}, - {40, 2300000, 2400000, 2300000, 2400000, 20, 460000}, - {41, 2496000, 2690000, 2496000, 2690000, 3, 499200}, - {50, 1432000, 1517000, 1432000, 1517000, 20, 286400}, - {51, 1427000, 1432000, 1427000, 1432000, 20, 285400}, - {66, 1710000, 1780000, 2110000, 2200000, 20, 422000}, - {70, 1695000, 1710000, 1995000, 2020000, 20, 399000}, - {71, 663000, 698000, 617000, 652000, 20, 123400}, - {74, 1427000, 1470000, 1475000, 1518000, 20, 295000}, - {75, 000, 000, 1432000, 1517000, 20, 286400}, - {76, 000, 000, 1427000, 1432000, 20, 285400}, - {77, 3300000, 4200000, 3300000, 4200000, 1, 620000}, - {78, 3300000, 3800000, 3300000, 3800000, 1, 620000}, - {79, 4400000, 5000000, 4400000, 5000000, 2, 693334}, - {80, 1710000, 1785000, 000, 000, 20, 342000}, - {81, 860000, 915000, 000, 000, 20, 176000}, - {82, 832000, 862000, 000, 000, 20, 166400}, - {83, 703000, 748000, 000, 000, 20, 140600}, - {84, 1920000, 1980000, 000, 000, 20, 384000}, - {86, 1710000, 1785000, 000, 000, 20, 342000} -}; - +//int32_t **rxdata; +//int32_t **txdata; +extern nr_bandentry_t *nr_bandtable; uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw) { diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index a4afdcd6b6..362300d4d7 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -157,43 +157,6 @@ int32_t **txdata; #endif -band_info_t bands_to_scan; - -static const eutra_band_t eutra_bands[] = { - {1, 1920000, 1980000, 2110000, 2170000, FDD}, - {2, 1850000, 1910000, 1930000, 1990000, FDD}, - {3, 1710000, 1785000, 1805000, 1880000, FDD}, - {5, 824000, 849000, 869000, 894000, FDD}, - {7, 2500000, 2570000, 2620000, 2690000, FDD}, - {8, 880000, 915000, 925000, 960000, FDD}, - {12, 698000, 716000, 728000, 746000, FDD}, - {20, 832000, 862000, 791000, 821000, FDD}, - {25, 1850000, 1915000, 1930000, 1995000, FDD}, - {28, 703000, 758000, 758000, 813000, FDD}, - {34, 2010000, 2025000, 2010000, 2025000, TDD}, - {38, 2570000, 2620000, 2570000, 2630000, TDD}, - {39, 1880000, 1920000, 1880000, 1920000, TDD}, - {40, 2300000, 2400000, 2300000, 2400000, TDD}, - {41, 2496000, 2690000, 2496000, 2690000, TDD}, - {50, 1432000, 1517000, 1432000, 1517000, TDD}, - {51, 1427000, 1432000, 1427000, 1432000, TDD}, - {66, 1710000, 1780000, 2110000, 2200000, FDD}, - {70, 1695000, 1710000, 1995000, 2020000, FDD}, - {71, 663000, 698000, 617000, 652000, FDD}, - {74, 1427000, 1470000, 1475000, 1518000, FDD}, - {75, 000, 000, 1432000, 1517000, FDD}, - {76, 000, 000, 1427000, 1432000, FDD}, - {77, 3300000, 4200000, 3300000, 4200000, TDD}, - {78, 3300000, 3800000, 3300000, 3800000, TDD}, - {79, 4400000, 5000000, 4400000, 5000000, TDD}, - {80, 1710000, 1785000, 000, 000, FDD}, - {81, 860000, 915000, 000, 000, FDD}, - {82, 832000, 862000, 000, 000, FDD}, - {83, 703000, 748000, 000, 000, FDD}, - {84, 1920000, 1980000, 000, 000, FDD}, - {86, 1710000, 1785000, 000, 000, FDD} -}; - PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag) @@ -364,7 +327,8 @@ static void *UE_thread_synch(void *arg) { sync_mode = pbch; } else { current_band=0; - + LOG_E(PHY,"Fixme!\n"); + /* for (i=0; irf_map.card].rx_num_channels; i++) { downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[CC_id].dl_min; uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = @@ -374,6 +338,7 @@ static void *UE_thread_synch(void *arg) { downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]; openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB; } + */ } // AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n"); @@ -388,6 +353,7 @@ static void *UE_thread_synch(void *arg) { AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); switch (sync_mode) { + /* case pss: LOG_I(PHY,"[SCHED][UE] Scanning band %d (%d), freq %u\n",bands_to_scan.band_info[current_band].band, current_band,bands_to_scan.band_info[current_band].dl_min+current_offset); //lte_sync_timefreq(UE,current_band,bands_to_scan.band_info[current_band].dl_min+current_offset); @@ -416,7 +382,7 @@ static void *UE_thread_synch(void *arg) { } break; - + */ case pbch: #if DISABLE_LOG_X printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); From 14ae2b54bd1aa8e0ba2b53d6f7f50c8f6a73a65a Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Mon, 25 Mar 2019 09:50:03 +0100 Subject: [PATCH 47/54] renaming band_info_s ton nr_band_info_s to avoid confusion with LTE --- openair1/PHY/defs_nr_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 605ce8c4c8..0c2f8771ec 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -334,7 +334,7 @@ typedef struct nr_bandentry_s { uint64_t step_size; } nr_bandentry_t; -typedef struct band_info_s { +typedef struct nr_band_info_s { int nbands; nr_bandentry_t band_info[100]; } nr_band_info_t; From 52a142d0df66c46abdedcca9c75f2e011ba8a282 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 26 Mar 2019 09:39:11 +0100 Subject: [PATCH 48/54] bugfix in pbch correlation --- .../PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 13 +++++-------- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 1 + openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) 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 f6fd1f28f2..917734f8ec 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -36,6 +36,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, unsigned char symbol, + int dmrss, NR_UE_SSB *current_ssb) { int pilot[200] __attribute__((aligned(16))); @@ -44,7 +45,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, unsigned int pilot_cnt; int16_t ch[2],*pil,*rxF; int symbol_offset; - int dmrss; + uint8_t nushift; uint8_t ssb_index=current_ssb->i_ssb; @@ -56,13 +57,9 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size; - if (ue->is_synchronized ==0 ) dmrss = symbol-1; - else dmrss = symbol-5; - - AssertFatal((symbol > 0 && symbol < 4 && ue->is_synchronized == 0) || - (symbol > 4 && symbol < 8 && ue->is_synchronized == 1), - "symbol %d is illegal for PBCH DM-RS (is_synchronized %d)\n", - symbol,ue->is_synchronized); + AssertFatal(dmrss >= 0 && dmrss < 3, + "symbol %d is illegal for PBCH DM-RS \n", + dmrss); symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 1ec9cec96f..29400bbdc7 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -54,6 +54,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned char Ns, unsigned char symbol, + int dmrss, NR_UE_SSB *current_ssb); int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 62dad0c027..0e0676b972 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -130,7 +130,7 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mod #endif // computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf for(int i=pbch_initial_symbol; idlsch_channel_estimation_stats); #endif From a3049674c6494fd3c9cd35623d960d6a91b672f4 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 26 Mar 2019 10:27:12 +0100 Subject: [PATCH 49/54] warning fixed in get_band --- openair1/PHY/INIT/nr_parms.c | 10 +++++----- openair1/PHY/INIT/phy_init.h | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 095101fb89..bdcf562e6a 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -337,13 +337,14 @@ nr_bandentry_t nr_bandtable[] = { {86, 1710000, 1785000, 000, 000, 20, 342000} }; -int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { +void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { int ind; int64_t dl_freq_khz = downlink_frequency/1000; for ( ind=0; ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); ind++) { + *current_band = nr_bandtable[ind].band; LOG_I(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); @@ -360,9 +361,8 @@ int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *cu } } - if( ind == sizeof(nr_bandtable) / sizeof(nr_bandtable[0])) { - LOG_E(PHY,"Can't find EUTRA band for frequency %d\n", downlink_frequency); - return(-1); - } + AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), + "Can't find EUTRA band for frequency %d\n", downlink_frequency); + } diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index f500375e4b..bc92d0939e 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -391,7 +391,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB); void init_dfts(void); -int get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); +void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); /** @} */ diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 652158605b..1416905696 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -154,7 +154,7 @@ int main(int argc, char **argv) int pbch_tx_ant; int N_RB_DL=273,mu=1; - uint64_t ssb_pattern = 0; + uint64_t ssb_pattern = 0x01; unsigned char frame_type = 0; unsigned char pbch_phase = 0; From dea3125734a40c8263cf6b6a1ea82f4e7152da34 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 26 Mar 2019 14:48:30 +0100 Subject: [PATCH 50/54] moving nr_bandtable back to MAC --- openair1/PHY/INIT/nr_parms.c | 63 ------------------------- openair1/PHY/INIT/phy_init.h | 2 - openair2/LAYER2/NR_MAC_gNB/config.c | 65 +++++++++++++++++++++++++- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 + 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index bdcf562e6a..a828804002 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -302,67 +302,4 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp) } -nr_bandentry_t nr_bandtable[] = { - {1, 1920000, 1980000, 2110000, 2170000, 20, 422000}, - {2, 1850000, 1910000, 1930000, 1990000, 20, 386000}, - {3, 1710000, 1785000, 1805000, 1880000, 20, 361000}, - {5, 824000, 849000, 869000, 894000, 20, 173800}, - {7, 2500000, 2570000, 2620000, 2690000, 20, 524000}, - {8, 880000, 915000, 925000, 960000, 20, 185000}, - {12, 698000, 716000, 728000, 746000, 20, 145800}, - {20, 832000, 862000, 791000, 821000, 20, 158200}, - {25, 1850000, 1915000, 1930000, 1995000, 20, 386000}, - {28, 703000, 758000, 758000, 813000, 20, 151600}, - {34, 2010000, 2025000, 2010000, 2025000, 20, 402000}, - {38, 2570000, 2620000, 2570000, 2630000, 20, 514000}, - {39, 1880000, 1920000, 1880000, 1920000, 20, 376000}, - {40, 2300000, 2400000, 2300000, 2400000, 20, 460000}, - {41, 2496000, 2690000, 2496000, 2690000, 3, 499200}, - {50, 1432000, 1517000, 1432000, 1517000, 20, 286400}, - {51, 1427000, 1432000, 1427000, 1432000, 20, 285400}, - {66, 1710000, 1780000, 2110000, 2200000, 20, 422000}, - {70, 1695000, 1710000, 1995000, 2020000, 20, 399000}, - {71, 663000, 698000, 617000, 652000, 20, 123400}, - {74, 1427000, 1470000, 1475000, 1518000, 20, 295000}, - {75, 000, 000, 1432000, 1517000, 20, 286400}, - {76, 000, 000, 1427000, 1432000, 20, 285400}, - {77, 3300000, 4200000, 3300000, 4200000, 1, 620000}, - {78, 3300000, 3800000, 3300000, 3800000, 1, 620000}, - {79, 4400000, 5000000, 4400000, 5000000, 2, 693334}, - {80, 1710000, 1785000, 000, 000, 20, 342000}, - {81, 860000, 915000, 000, 000, 20, 176000}, - {82, 832000, 862000, 000, 000, 20, 166400}, - {83, 703000, 748000, 000, 000, 20, 140600}, - {84, 1920000, 1980000, 000, 000, 20, 384000}, - {86, 1710000, 1785000, 000, 000, 20, 342000} -}; - -void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { - - int ind; - int64_t dl_freq_khz = downlink_frequency/1000; - for ( ind=0; - ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); - ind++) { - - *current_band = nr_bandtable[ind].band; - LOG_I(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); - - if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { - *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; - if (*current_offset == 0) - *current_type = TDD; - else - *current_type = FDD; - - LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", - downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); - break; - } - } - - AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), - "Can't find EUTRA band for frequency %d\n", downlink_frequency); - -} diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index bc92d0939e..6f9cff07bf 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -391,8 +391,6 @@ void init_nr_transport(PHY_VARS_gNB *gNB); void init_dfts(void); -void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); - /** @} */ #endif diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 1e1258e089..d41ff93e9b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -51,7 +51,70 @@ extern uint8_t nfapi_mode; //int32_t **rxdata; //int32_t **txdata; -extern nr_bandentry_t *nr_bandtable; + +nr_bandentry_t nr_bandtable[] = { + {1, 1920000, 1980000, 2110000, 2170000, 20, 422000}, + {2, 1850000, 1910000, 1930000, 1990000, 20, 386000}, + {3, 1710000, 1785000, 1805000, 1880000, 20, 361000}, + {5, 824000, 849000, 869000, 894000, 20, 173800}, + {7, 2500000, 2570000, 2620000, 2690000, 20, 524000}, + {8, 880000, 915000, 925000, 960000, 20, 185000}, + {12, 698000, 716000, 728000, 746000, 20, 145800}, + {20, 832000, 862000, 791000, 821000, 20, 158200}, + {25, 1850000, 1915000, 1930000, 1995000, 20, 386000}, + {28, 703000, 758000, 758000, 813000, 20, 151600}, + {34, 2010000, 2025000, 2010000, 2025000, 20, 402000}, + {38, 2570000, 2620000, 2570000, 2630000, 20, 514000}, + {39, 1880000, 1920000, 1880000, 1920000, 20, 376000}, + {40, 2300000, 2400000, 2300000, 2400000, 20, 460000}, + {41, 2496000, 2690000, 2496000, 2690000, 3, 499200}, + {50, 1432000, 1517000, 1432000, 1517000, 20, 286400}, + {51, 1427000, 1432000, 1427000, 1432000, 20, 285400}, + {66, 1710000, 1780000, 2110000, 2200000, 20, 422000}, + {70, 1695000, 1710000, 1995000, 2020000, 20, 399000}, + {71, 663000, 698000, 617000, 652000, 20, 123400}, + {74, 1427000, 1470000, 1475000, 1518000, 20, 295000}, + {75, 000, 000, 1432000, 1517000, 20, 286400}, + {76, 000, 000, 1427000, 1432000, 20, 285400}, + {77, 3300000, 4200000, 3300000, 4200000, 1, 620000}, + {78, 3300000, 3800000, 3300000, 3800000, 1, 620000}, + {79, 4400000, 5000000, 4400000, 5000000, 2, 693334}, + {80, 1710000, 1785000, 000, 000, 20, 342000}, + {81, 860000, 915000, 000, 000, 20, 176000}, + {82, 832000, 862000, 000, 000, 20, 166400}, + {83, 703000, 748000, 000, 000, 20, 140600}, + {84, 1920000, 1980000, 000, 000, 20, 384000}, + {86, 1710000, 1785000, 000, 000, 20, 342000} +}; + +void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { + + int ind; + int64_t dl_freq_khz = downlink_frequency/1000; + for ( ind=0; + ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); + ind++) { + + *current_band = nr_bandtable[ind].band; + LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); + + if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { + *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; + if (*current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; + + LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", + downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); + break; + } + } + + AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), + "Can't find EUTRA band for frequency %d\n", downlink_frequency); + +} uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index a214b160a2..9c14b84a23 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -102,4 +102,6 @@ int to_absslot(nfapi_nr_config_request_t *cfg,int frame,int slot); int get_symbolsperslot(nfapi_nr_config_request_t *cfg); +void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); + #endif /*__LAYER2_NR_MAC_PROTO_H__*/ From 40b52195fcc4b3dd9a2b192f4e366774bfc7a4e2 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 26 Mar 2019 16:16:34 +0100 Subject: [PATCH 51/54] redefining max number of UEs for memory allocation. Using the PHYSIM macro, different allocations are used for phy_simulators and real-time modem. --- .gitignore | 1 - cmake_targets/CMakeLists.txt | 2 +- openair2/LAYER2/MAC/mac_extern.h | 4 ---- openair2/RRC/LTE/rrc_extern.h | 6 ------ openair2/RRC/NR/nr_rrc_extern.h | 6 ------ targets/COMMON/openairinterface5g_limits.h | 9 ++++++++- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 61d9558916..2adc5d457c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ cmake_targets/log/ -cmake_targets/ran_build/ cmake_targets/*/build/ targets/bin/ diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 79f057c29e..7899c71a7b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -671,7 +671,7 @@ add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LOCALIZATION False "???") add_integer_option(MAX_NUM_CCs 1 "????") add_boolean_option(MU_RECEIVER False "????") -add_boolean_option(PHYSIM True "for L1 simulators (dlsim, ulsim, ...)") +add_boolean_option(PHYSIM False "for L1 simulators (dlsim, ulsim, ...)") add_boolean_option(PHY_CONTEXT True "not clear: must remain False for dlsim") add_boolean_option(PHY_EMUL False "not clear: must remain False for dlsim") add_boolean_option(SMBV False "Rohde&Schwarz SMBV100A vector signal generator") diff --git a/openair2/LAYER2/MAC/mac_extern.h b/openair2/LAYER2/MAC/mac_extern.h index ca72882471..825756a095 100644 --- a/openair2/LAYER2/MAC/mac_extern.h +++ b/openair2/LAYER2/MAC/mac_extern.h @@ -58,11 +58,7 @@ extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES -#ifndef PHYSIM -#define NB_INST 1 -#else extern unsigned char NB_INST; -#endif extern unsigned char NB_eNB_INST; extern unsigned char NB_UE_INST; extern unsigned char NB_RN_INST; diff --git a/openair2/RRC/LTE/rrc_extern.h b/openair2/RRC/LTE/rrc_extern.h index 59200fb9cc..68c805dffe 100644 --- a/openair2/RRC/LTE/rrc_extern.h +++ b/openair2/RRC/LTE/rrc_extern.h @@ -44,17 +44,11 @@ extern LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue; extern LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue; -#ifndef PHY_EMUL -#ifndef PHYSIM -//#define NB_INST 1 -#else extern unsigned char NB_INST; -#endif extern unsigned char NB_eNB_INST; extern unsigned char NB_UE_INST; extern unsigned short NODE_ID[1]; extern void* bigphys_malloc(int); -#endif //CONSTANTS diff --git a/openair2/RRC/NR/nr_rrc_extern.h b/openair2/RRC/NR/nr_rrc_extern.h index 7509dfc727..a9af422f02 100644 --- a/openair2/RRC/NR/nr_rrc_extern.h +++ b/openair2/RRC/NR/nr_rrc_extern.h @@ -43,17 +43,11 @@ extern LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue; extern LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue; -#ifndef PHY_EMUL -#ifndef PHYSIM -//#define NB_INST 1 -#else extern unsigned char NB_INST; -#endif extern unsigned char NB_eNB_INST; extern unsigned char NB_UE_INST; extern unsigned short NODE_ID[1]; extern void* bigphys_malloc(int); -#endif //CONSTANTS diff --git a/targets/COMMON/openairinterface5g_limits.h b/targets/COMMON/openairinterface5g_limits.h index d44f0c5601..9645acf4dd 100644 --- a/targets/COMMON/openairinterface5g_limits.h +++ b/targets/COMMON/openairinterface5g_limits.h @@ -1,11 +1,12 @@ #ifndef OPENAIRINTERFACE5G_LIMITS_H_ #define OPENAIRINTERFACE5G_LIMITS_H_ -#if defined(CBMIMO1) || defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) +#if 1 /*defined(CBMIMO1) || defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)*/ # define NUMBER_OF_eNB_MAX 1 # define NUMBER_OF_gNB_MAX 1 # define NUMBER_OF_RU_MAX 2 # define NUMBER_OF_NR_RU_MAX 2 +# ifndef PHYSIM # ifndef UE_EXPANSION # define NUMBER_OF_UE_MAX 16 # define NUMBER_OF_NR_UE_MAX 16 @@ -17,6 +18,12 @@ # define NUMBER_OF_CONNECTED_eNB_MAX 1 # define NUMBER_OF_CONNECTED_gNB_MAX 1 # endif +# else +# define NUMBER_OF_UE_MAX 1 +# define NUMBER_OF_NR_UE_MAX 1 +# define NUMBER_OF_CONNECTED_eNB_MAX 1 +# define NUMBER_OF_CONNECTED_gNB_MAX 1 +# endif #else # define NUMBER_OF_eNB_MAX 7 # define NUMBER_OF_gNB_MAX 7 From 97f4ec965ec28cacb9fcbb8526ea86a3817a37e9 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Tue, 26 Mar 2019 18:19:36 +0100 Subject: [PATCH 52/54] desparate to get the get_band function to work for all targets --- cmake_targets/CMakeLists.txt | 59 +++----- openair2/LAYER2/NR_MAC_gNB/config.c | 117 ---------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 4 + openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c | 148 +++++++++++++++++++++ 4 files changed, 167 insertions(+), 161 deletions(-) create mode 100644 openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index af9c3edf68..8f11e99a75 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -167,7 +167,7 @@ endif() # set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC ") + "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC") # add autotools definitions that were maybe used! set(MKVER "'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'") set(CMAKE_C_FLAGS @@ -1575,6 +1575,7 @@ add_library(L2 ${ENB_APP_SRC} ) add_dependencies(L2 rrc_flag s1ap_flag x2_flag) + add_library(MAC_NR ${MAC_NR_SRC} ) @@ -1593,7 +1594,6 @@ add_dependencies(S1AP_LIB nr_rrc_flag s1ap_flag) add_library(L2_UE ${L2_SRC_UE} ${MAC_SRC_UE} - #${MAC_NR_SRC_UE} ) if (NOT ${NOS1}) target_compile_definitions(L2_UE PUBLIC -DPDCP_USE_NETLINK) @@ -1602,44 +1602,13 @@ endif() add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag) add_library( NR_L2_UE - #${L2_SRC_UE} ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} - #${MAC_SRC_UE} -) - -set ( NR_LTE_UE_REUSE_SRC - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.c - ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c - #${OPENAIR1_DIR}/SCHED_UE/phy_procedures_lte_ue.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch_common.c - - #${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec.c - #${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach_common.c -# ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c - ${OPENAIR1_DIR}/PHY/CODING/crc_byte.c - ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c - ${OPENAIR1_DIR}/PHY/CODING/viterbi.c - #${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich_common.c - ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c - -# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c -# ${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c - ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c - ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_est_freq_offset.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ue_measurements.c - #${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c - #${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c -) - -add_library( NR_LTE_UE_REUSE_LIB - ${NR_LTE_UE_REUSE_SRC} -) + ) + +add_library( MAC_NR_COMMON + ${OPENAIR2_DIR}/LAYER2/NR_MAC_gNB/nr_mac_common.c + ) include_directories("${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE") include_directories("${OPENAIR2_DIR}/LAYER2/NR_MAC_UE") @@ -2368,7 +2337,7 @@ target_link_libraries (nr-softmodem -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2409,7 +2378,7 @@ target_link_libraries (nr-softmodem-nos1 -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${MIH_LIB} - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2444,7 +2413,7 @@ add_executable(nr-uesoftmodem target_link_libraries (nr-uesoftmodem -Wl,--start-group - RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_RU LFDS NR_L2_UE #NR_LTE_UE_REUSE_LIB + RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_RU LFDS NR_L2_UE MAC_NR_COMMON ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -2478,7 +2447,7 @@ add_executable(nr-uesoftmodem-nos1 target_link_libraries (nr-uesoftmodem-nos1 -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_UE PHY_RU LFDS NR_L2_UE + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_UE PHY_RU LFDS NR_L2_UE MAC_NR_COMMON ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -2555,7 +2524,7 @@ add_executable(nr_dlsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR_DIR}/common/utils/backtrace.c ${T_SOURCE}) -target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) +target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) @@ -2688,7 +2657,9 @@ L2 L2_NR L2_UE NR_L2_UE -NR_LTE_UE_REUSE_LIB +MAC_NR_COMMON +MAC_NR +MAC_UE_NR CN_UTILS GTPV1U SCTP_CLIENT diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index d41ff93e9b..6954b9507d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -49,123 +49,6 @@ extern RAN_CONTEXT_t RC; extern void mac_top_init_gNB(void); extern uint8_t nfapi_mode; -//int32_t **rxdata; -//int32_t **txdata; - -nr_bandentry_t nr_bandtable[] = { - {1, 1920000, 1980000, 2110000, 2170000, 20, 422000}, - {2, 1850000, 1910000, 1930000, 1990000, 20, 386000}, - {3, 1710000, 1785000, 1805000, 1880000, 20, 361000}, - {5, 824000, 849000, 869000, 894000, 20, 173800}, - {7, 2500000, 2570000, 2620000, 2690000, 20, 524000}, - {8, 880000, 915000, 925000, 960000, 20, 185000}, - {12, 698000, 716000, 728000, 746000, 20, 145800}, - {20, 832000, 862000, 791000, 821000, 20, 158200}, - {25, 1850000, 1915000, 1930000, 1995000, 20, 386000}, - {28, 703000, 758000, 758000, 813000, 20, 151600}, - {34, 2010000, 2025000, 2010000, 2025000, 20, 402000}, - {38, 2570000, 2620000, 2570000, 2630000, 20, 514000}, - {39, 1880000, 1920000, 1880000, 1920000, 20, 376000}, - {40, 2300000, 2400000, 2300000, 2400000, 20, 460000}, - {41, 2496000, 2690000, 2496000, 2690000, 3, 499200}, - {50, 1432000, 1517000, 1432000, 1517000, 20, 286400}, - {51, 1427000, 1432000, 1427000, 1432000, 20, 285400}, - {66, 1710000, 1780000, 2110000, 2200000, 20, 422000}, - {70, 1695000, 1710000, 1995000, 2020000, 20, 399000}, - {71, 663000, 698000, 617000, 652000, 20, 123400}, - {74, 1427000, 1470000, 1475000, 1518000, 20, 295000}, - {75, 000, 000, 1432000, 1517000, 20, 286400}, - {76, 000, 000, 1427000, 1432000, 20, 285400}, - {77, 3300000, 4200000, 3300000, 4200000, 1, 620000}, - {78, 3300000, 3800000, 3300000, 3800000, 1, 620000}, - {79, 4400000, 5000000, 4400000, 5000000, 2, 693334}, - {80, 1710000, 1785000, 000, 000, 20, 342000}, - {81, 860000, 915000, 000, 000, 20, 176000}, - {82, 832000, 862000, 000, 000, 20, 166400}, - {83, 703000, 748000, 000, 000, 20, 140600}, - {84, 1920000, 1980000, 000, 000, 20, 384000}, - {86, 1710000, 1785000, 000, 000, 20, 342000} -}; - -void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { - - int ind; - int64_t dl_freq_khz = downlink_frequency/1000; - for ( ind=0; - ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); - ind++) { - - *current_band = nr_bandtable[ind].band; - LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); - - if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { - *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; - if (*current_offset == 0) - *current_type = TDD; - else - *current_type = FDD; - - LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", - downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); - break; - } - } - - AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), - "Can't find EUTRA band for frequency %d\n", downlink_frequency); - -} - -uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw) -{ - - uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000; - int bw_kHz = bw / 1000; - - int i; - - LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw); - AssertFatal(nr_bandP < 86, "nr_band %d > 86\n", nr_bandP); - for (i = 0; i < 30 && nr_bandtable[i].band != nr_bandP; i++); - - AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min, - "Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n", - nr_bandP, bw, (long long unsigned int)dl_CarrierFreq_by_1k, - (long long unsigned int)nr_bandtable[i].dl_min); - AssertFatal(dl_CarrierFreq_by_1k <= - (nr_bandtable[i].dl_max - bw_kHz), - "Band %d, dl_CarrierFreq %llu bw %u: DL carrier frequency %llu kHz > %llu\n", - nr_bandP, (long long unsigned int)dl_CarrierFreq,bw, (long long unsigned int)dl_CarrierFreq_by_1k, - (long long unsigned int)(nr_bandtable[i].dl_max - bw_kHz)); - - int deltaFglobal; - - if (dl_CarrierFreq < 3e9) deltaFglobal = 5; - else deltaFglobal = 15; - - // This is equation before Table 5.4.2.1-1 in 38101-1-f30 - // F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs) - return (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal) + - nr_bandtable[i].N_OFFs_DL); -} - - -uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn) -{ - - int i; - int deltaFglobal; - - if (nr_bandP < 77 || nr_bandP > 79) deltaFglobal = 5; - else deltaFglobal = 15; - - AssertFatal(nr_bandP < 87, "nr_band %d > 86\n", nr_bandP); - for (i = 0; i < 31 && nr_bandtable[i].band != nr_bandP; i++); - AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL %llu\n",dl_nrarfcn, (long long unsigned int)nr_bandtable[i].N_OFFs_DL); - - return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal); - -} void config_nr_mib(int Mod_idP, int CC_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 9c14b84a23..6f0bd9d595 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -104,4 +104,8 @@ int get_symbolsperslot(nfapi_nr_config_request_t *cfg); void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); +uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn); + +uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw); + #endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c b/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c new file mode 100644 index 0000000000..f2c2e437cc --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c @@ -0,0 +1,148 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file nr_mac_common.c + * \brief Common MAC functions for NR UE and gNB + * \author Florian Kaltenberger and Raymond Knopp + * \date 2019 + * \version 0.1 + * \company Eurecom, NTUST + * \email: florian.kalteberger@eurecom.fr, raymond.knopp@eurecom.fr + * @ingroup _mac + + */ + +#include "LAYER2/NR_MAC_gNB/mac_proto.h" + +nr_bandentry_t nr_bandtable[] = { + {1, 1920000, 1980000, 2110000, 2170000, 20, 422000}, + {2, 1850000, 1910000, 1930000, 1990000, 20, 386000}, + {3, 1710000, 1785000, 1805000, 1880000, 20, 361000}, + {5, 824000, 849000, 869000, 894000, 20, 173800}, + {7, 2500000, 2570000, 2620000, 2690000, 20, 524000}, + {8, 880000, 915000, 925000, 960000, 20, 185000}, + {12, 698000, 716000, 728000, 746000, 20, 145800}, + {20, 832000, 862000, 791000, 821000, 20, 158200}, + {25, 1850000, 1915000, 1930000, 1995000, 20, 386000}, + {28, 703000, 758000, 758000, 813000, 20, 151600}, + {34, 2010000, 2025000, 2010000, 2025000, 20, 402000}, + {38, 2570000, 2620000, 2570000, 2630000, 20, 514000}, + {39, 1880000, 1920000, 1880000, 1920000, 20, 376000}, + {40, 2300000, 2400000, 2300000, 2400000, 20, 460000}, + {41, 2496000, 2690000, 2496000, 2690000, 3, 499200}, + {50, 1432000, 1517000, 1432000, 1517000, 20, 286400}, + {51, 1427000, 1432000, 1427000, 1432000, 20, 285400}, + {66, 1710000, 1780000, 2110000, 2200000, 20, 422000}, + {70, 1695000, 1710000, 1995000, 2020000, 20, 399000}, + {71, 663000, 698000, 617000, 652000, 20, 123400}, + {74, 1427000, 1470000, 1475000, 1518000, 20, 295000}, + {75, 000, 000, 1432000, 1517000, 20, 286400}, + {76, 000, 000, 1427000, 1432000, 20, 285400}, + {77, 3300000, 4200000, 3300000, 4200000, 1, 620000}, + {78, 3300000, 3800000, 3300000, 3800000, 1, 620000}, + {79, 4400000, 5000000, 4400000, 5000000, 2, 693334}, + {80, 1710000, 1785000, 000, 000, 20, 342000}, + {81, 860000, 915000, 000, 000, 20, 176000}, + {82, 832000, 862000, 000, 000, 20, 166400}, + {83, 703000, 748000, 000, 000, 20, 140600}, + {84, 1920000, 1980000, 000, 000, 20, 384000}, + {86, 1710000, 1785000, 000, 000, 20, 342000} +}; + +void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) { + + int ind; + int64_t dl_freq_khz = downlink_frequency/1000; + for ( ind=0; + ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); + ind++) { + + *current_band = nr_bandtable[ind].band; + LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); + + if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { + *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; + if (*current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; + + LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", + downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); + break; + } + } + + AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), + "Can't find EUTRA band for frequency %d\n", downlink_frequency); + +} + +uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw) +{ + + uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000; + int bw_kHz = bw / 1000; + + int i; + + LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw); + AssertFatal(nr_bandP < 86, "nr_band %d > 86\n", nr_bandP); + for (i = 0; i < 30 && nr_bandtable[i].band != nr_bandP; i++); + + AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min, + "Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n", + nr_bandP, bw, (long long unsigned int)dl_CarrierFreq_by_1k, + (long long unsigned int)nr_bandtable[i].dl_min); + AssertFatal(dl_CarrierFreq_by_1k <= + (nr_bandtable[i].dl_max - bw_kHz), + "Band %d, dl_CarrierFreq %llu bw %u: DL carrier frequency %llu kHz > %llu\n", + nr_bandP, (long long unsigned int)dl_CarrierFreq,bw, (long long unsigned int)dl_CarrierFreq_by_1k, + (long long unsigned int)(nr_bandtable[i].dl_max - bw_kHz)); + + int deltaFglobal; + + if (dl_CarrierFreq < 3e9) deltaFglobal = 5; + else deltaFglobal = 15; + + // This is equation before Table 5.4.2.1-1 in 38101-1-f30 + // F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs) + return (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal) + + nr_bandtable[i].N_OFFs_DL); +} + + +uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn) +{ + + int i; + int deltaFglobal; + + if (nr_bandP < 77 || nr_bandP > 79) deltaFglobal = 5; + else deltaFglobal = 15; + + AssertFatal(nr_bandP < 87, "nr_band %d > 86\n", nr_bandP); + for (i = 0; i < 31 && nr_bandtable[i].band != nr_bandP; i++); + AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL %llu\n",dl_nrarfcn, (long long unsigned int)nr_bandtable[i].N_OFFs_DL); + + return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal); + +} From ab299dd2e289a1296f501a8dcc8aac415b85a68e Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 27 Mar 2019 09:43:09 +0100 Subject: [PATCH 53/54] modification to pbchsim without initial sync --- openair1/SIMULATION/NR_PHY/pbchsim.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 548a4f3dc3..e4ff2f48d7 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -618,9 +618,18 @@ int main(int argc, char **argv) 0, 0, NR_PBCH_EST); + + nr_pbch_channel_estimation(UE,0,0,i,i-(UE->symbol_offset+1),ssb_index%8,n_hf); } - ret = nr_pbch_detection(UE,UE->symbol_offset+1,0); + ret = nr_rx_pbch(UE, + 0, + UE->pbch_vars[0], + frame_parms, + 0, + ssb_index%8, + SISO, + UE->high_speed_flag); if (ret==0) { //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically From 4af9f321cfc030d6e0f8e25ccb65b604ec4abbb2 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 27 Mar 2019 16:10:51 +0100 Subject: [PATCH 54/54] Fix multiple SSB support for PUSCH --- openair1/SIMULATION/NR_PHY/ulschsim.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 9b0c3562af..ca3860c5b0 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -146,7 +146,7 @@ int main(int argc, char **argv) { //char input_val_str[50],input_val_str2[50]; //uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr; - uint8_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; + uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame = 0, subframe = 0; @@ -162,7 +162,7 @@ int main(int argc, char **argv) { //int run_initial_sync=0; int loglvl = OAILOG_WARNING; float target_error_rate = 0.01; - + uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12; uint16_t nb_rb = 50; uint8_t Imcs = 9; @@ -176,7 +176,7 @@ int main(int argc, char **argv) { //logInit(); randominit(0); - while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { + while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { switch (c) { case 'f': write_output_file = 1; @@ -287,6 +287,10 @@ int main(int argc, char **argv) { break; + case 'M': + SSB_positions = atoi(optarg); + break; + case 'N': Nid_cell = atoi(optarg); break; @@ -346,6 +350,7 @@ int main(int argc, char **argv) { printf("-z Number of RX antennas used in UE\n"); printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -365,7 +370,8 @@ int main(int argc, char **argv) { if (snr1set == 0) snr1 = snr0 + 10; - gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, 61.44e6, //N_RB2sampling_rate(N_RB_DL), + gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, + 61.44e6, //N_RB2sampling_rate(N_RB_DL), 40e6, //N_RB2channel_bandwidth(N_RB_DL), 0, 0, 0); @@ -389,7 +395,7 @@ int main(int argc, char **argv) { crcTableInit(); - nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); + nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell, SSB_positions); phy_init_nr_gNB(gNB, 0, 0); //init_eNB_afterRU(); @@ -649,8 +655,10 @@ int main(int argc, char **argv) { (float) n_false_positive / (float) n_trials); printf("*****************************************\n"); - if ((float) n_errors / (float) n_trials < target_error_rate) + if ((float) n_errors / (float) n_trials < target_error_rate) { + printf("PUSCH test OK\n"); break; + } } /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);