From f68d124dcc9ffeac95921f26cabc232347f19ef1 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Wed, 4 Jul 2018 17:01:41 +0200 Subject: [PATCH 1/7] ue changing pbch dmrs modulation --- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 19 ++++++++++++------- openair1/PHY/NR_REFSIG/nr_mod_table.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index f9b4afeb34..26d883eb17 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -41,6 +41,7 @@ #include "refsig_defs_ue.h" #include "PHY/defs_nr_UE.h" +#include "nr_mod_table.h" #include "log.h" /*Table 7.4.1.1.2-1/2 from 38.211 */ @@ -50,7 +51,7 @@ int wf2[12][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1},{1,1},{1,-1 int wt2[12][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1}}; //short nr_mod_table[14] = {0,0,-23170,-23170,23170,23170,-23170,-23170,-23170,23170,23170,-23170,23170,23170}; - short nr_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,23170,-23170,-23170,-23170,23170}; + short nr_rx_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,23170,-23170,-23170,-23170,23170}; //short nr_mod_table[14] = {0,0,23170,23170,-23170,-23170,23170,23170,23170,-23170,-23170,23170,-23170,-23170}; //extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; @@ -143,16 +144,20 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, int nr_pbch_dmrs_rx(unsigned int *nr_gold_pbch, int32_t *output ) { - int m; + int m; + uint8_t idx=0; + + /// QPSK modulation + for (m=0; m>1; m++) { + idx = ((((nr_gold_pbch[(m<<1)>>5])>>((m<<1)&0x1f))&1)<<1) ^ (((nr_gold_pbch[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1); + ((int16_t*)output)[m<<1] = nr_rx_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + ((int16_t*)output)[(m<<1)+1] = nr_rx_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; - /// BPSK modulation - for (m=0; m>5]&(1<<(m&0x1f)))>>(m&0x1f)))<<1)]; - ((int16_t*)output)[(m<<1)+1] = nr_mod_table[((1 + ((nr_gold_pbch[m>>5]&(1<<(m&0x1f)))>>(m&0x1f)))<<1) + 1]; #ifdef DEBUG_PBCH - //printf("nr_gold_pbch[m>>5] %x\n",nr_gold_pbch[m>>5]); if (m<16) + {printf("nr_gold_pbch[(m<<1)>>5] %x\n",nr_gold_pbch[(m<<1)>>5]); printf("m %d output %d %d addr %p\n", m, ((int16_t*)output)[m<<1], ((int16_t*)output)[(m<<1)+1],&output[0]); + } #endif } diff --git a/openair1/PHY/NR_REFSIG/nr_mod_table.h b/openair1/PHY/NR_REFSIG/nr_mod_table.h index 75d8262147..3c0c808d1d 100644 --- a/openair1/PHY/NR_REFSIG/nr_mod_table.h +++ b/openair1/PHY/NR_REFSIG/nr_mod_table.h @@ -1,4 +1,4 @@ #define NR_MOD_TABLE_SIZE_SHORT 14 #define NR_MOD_TABLE_BPSK_OFFSET 1 #define NR_MOD_TABLE_QPSK_OFFSET 3 -short nr_mod_table[MOD_TABLE_SIZE_SHORT] = {0,0,23170,23170,-23170,-23170,23170,23170,23170,-23170,-23170,23170,-23170,-23170}; +short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,23170,23170,-23170,-23170,23170,23170,23170,-23170,-23170,23170,-23170,-23170}; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 3c062dbfa7..a3180beee8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -496,7 +496,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; //uint16_t crc; //short nr_demod_table[8] = {0,0,0,1,1,0,1,1}; - double nr_demod_table[8] = {0.707,0.707,0.707,-0.707,-0.707,0.707,-0.707,-0.707}; + double nr_demod_table[8] = {0.707,0.707,-0.707,0.707,0.707,-0.707,-0.707,-0.707}; double *demod_pbch_e = malloc (sizeof(double) * 864); unsigned short idx_demod =0; int8_t decoderState=0; @@ -607,8 +607,8 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, //polar decoding de-rate matching decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); - //for (i=0; i Date: Fri, 13 Jul 2018 15:20:51 +0200 Subject: [PATCH 2/7] ue adding 2nd decrambling and deinterleaving --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 98 ++++++++++++++++++++------ openair1/PHY/defs_nr_UE.h | 7 +- 2 files changed, 80 insertions(+), 25 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index a3180beee8..8e52a89893 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -386,31 +386,53 @@ void nr_pbch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, #endif } -void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, - uint8_t* pbch_a, - uint32_t length) +void nr_pbch_unscrambling(NR_UE_PBCH *pbch, + uint16_t Nid, + uint8_t nushift, + uint16_t M, + uint16_t length, + uint8_t bitwise) { int i; - uint8_t reset; + uint8_t reset, offset; uint32_t x1, x2, s=0; + uint8_t *pbch_e = pbch->pbch_e; + uint32_t *pbch_a_prime = (uint32_t*)pbch->pbch_a_prime; + uint32_t *pbch_a_interleaved = (uint32_t*)pbch->pbch_a_interleaved; + uint32_t unscrambling_mask = 0x100006D; //printf("unscramb nid_cell %d\n",frame_parms->Nid_cell); reset = 1; // x1 is set in first call to lte_gold_generic - x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 + x2 = Nid; //this is c_init - for (i=0; i>(i%32))&1) ); - if (((s>>(i%32))&1)==1) - pbch_a[i] = 1-pbch_a[i]; + // The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words + for (int i=0; i<(uint16_t)ceil((nushift*M)/32); i++) { + s = lte_gold_generic(&x1, &x2, reset); + reset = 0; } + // Scrambling is now done with offset (nushift*M)%32 + offset = (nushift*M)&0x1f; + + for (int i=0; i>i)&1)? (((*pbch_a_prime)>>i)&1)<>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<>((i+offset)&0x1f))&1)==1) + pbch_e[i] = -pbch_e[i]; + } + } + } void nr_pbch_alamouti(NR_DL_FRAME_PARMS *frame_parms, @@ -473,6 +495,8 @@ unsigned char sign(int8_t x) { return (unsigned char)x >> 7; } +uint8_t pbch_deinterleaving_pattern[32] = {28,0,31,30,1,29,25,27,22,2,24,3,4,5,6,7,18,21,20,8,9,10,11,19,26,12,13,14,15,16,23,17}; + uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, NR_UE_PBCH *nr_ue_pbch_vars, @@ -490,10 +514,14 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, int symbol,i; //uint8_t pbch_a[64]; - uint8_t *pbch_a = malloc(sizeof(uint8_t) * 32); ; - + uint8_t *pbch_a = malloc(sizeof(uint8_t) * 32); + uint8_t *pbch_a_prime; int8_t *pbch_e_rx; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; + uint8_t nushift; + uint16_t M; + uint8_t Lmax=8; //to update + uint8_t ssb_index=0; //uint16_t crc; //short nr_demod_table[8] = {0,0,0,1,1,0,1,1}; double nr_demod_table[8] = {0.707,0.707,-0.707,0.707,0.707,-0.707,-0.707,-0.707}; @@ -582,6 +610,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, } pbch_e_rx = nr_ue_pbch_vars->llr; + demod_pbch_e = nr_ue_pbch_vars->demod_pbch_e; + pbch_a = nr_ue_pbch_vars->pbch_a; + pbch_a_prime = nr_ue_pbch_vars->pbch_a_prime; #ifdef DEBUG_PBCH //pbch_e_rx = &nr_ue_pbch_vars->llr[0]; @@ -603,19 +634,40 @@ uint16_t 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; + nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0); //polar decoding de-rate matching - decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + decoderState = polar_decoder(demod_pbch_e, pbch_a_prime, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); for (i=0; i>6)&1)<<1) ^ ((pbch_a_prime[3])&1); + nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1); + + //payload deinterleaving + uint32_t in=0, out=0; + for (int i=0; i>3; i++) + in |= (uint32_t)(nr_ue_pbch_vars->pbch_a_interleaved[i]<<((3-i)<<3)); + + for (int i=0; i<32; i++) { + out |= ((in>>i)&1)<<(pbch_deinterleaving_pattern[i]); +#ifdef DEBUG_PBCH + printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaver_pattern[i], (in>>i)&1); +#endif + } + + for (int i=0; i>3; i++) + nr_ue_pbch_vars->pbch_a[i] = (uint8_t)((out>>(i<<3))&0xff); // Fix byte endian - for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS); i++) - decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS)-i-1] = pbch_a[i]; + for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) + decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; //#ifdef DEBUG_PBCH for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS); i++) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 4a25e62c77..ab9953308e 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -149,8 +149,6 @@ #include "targets/ARCH/COMMON/common_lib.h" - - /// Context data structure for RX/TX portion of subframe processing typedef struct { /// index of the current UE RX/TX proc @@ -850,6 +848,11 @@ typedef struct { /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..287] (hard coded) int32_t **dl_ch_estimates_ext; + uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; + uint8_t pbch_a_interleaved[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; + uint8_t pbch_a_prime[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; + uint8_t pbch_e[NR_POLAR_PBCH_E]; + double demod_pbch_e[NR_POLAR_PBCH_E]; /// \brief Pointer to PBCH llrs. /// - first index: ? [0..1919] (hard coded) int8_t *llr; From bdf0d29c2026f5c9a83436d969d95aa4ae564a54 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Fri, 13 Jul 2018 15:29:32 +0200 Subject: [PATCH 3/7] adding pbch logs --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 8e52a89893..6b4541f864 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -630,7 +630,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, if (i<16){ printf("idx[%d]= %d\n", i , idx_demod); printf("sign[%d]= %d sign[%d]= %d\n", i<<1 , sign(pbch_e_rx[i<<1]), (i<<1)+1 , sign(pbch_e_rx[(i<<1)+1])); - printf("demod_pbch_e2[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);} + printf("demod_pbch_e[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);} #endif } @@ -638,6 +638,11 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, M = NR_POLAR_PBCH_E; nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0); + +#ifdef DEBUG_PBCH + if (i<16){ + printf("unscrambling demod_pbch_e[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);} +#endif //polar decoding de-rate matching decoderState = polar_decoder(demod_pbch_e, pbch_a_prime, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); From a49a0d627ff2286c8c98690d8d871d955ac80df3 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 19 Jul 2018 15:11:48 +0200 Subject: [PATCH 4/7] ue bug fix 2nd unscrambling --- .../nr_dl_channel_estimation.c | 5 +-- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 37 +++++++++++++------ 2 files changed, 27 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 ad3f74452c..87361f5e9e 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -46,12 +46,11 @@ 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, Lmax, ssb_index=0, n_hf=0; + 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; - Lmax = 8; //to be updated - nushift = (Lmax < 8)? ssb_index&3 : ssb_index&7; + nushift = ue->frame_parms.Nid_cell%4; ue->frame_parms.nushift = nushift; if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 6b4541f864..5c2f949341 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -396,7 +396,7 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, int i; uint8_t reset, offset; uint32_t x1, x2, s=0; - uint8_t *pbch_e = pbch->pbch_e; + double *demod_pbch_e = pbch->demod_pbch_e; uint32_t *pbch_a_prime = (uint32_t*)pbch->pbch_a_prime; uint32_t *pbch_a_interleaved = (uint32_t*)pbch->pbch_a_interleaved; uint32_t unscrambling_mask = 0x100006D; @@ -421,6 +421,7 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, reset = 0; } #ifdef DEBUG_PBCH_ENCODING + if (i<8) printf("s: %04x\t", s); #endif if (bitwise) { @@ -429,7 +430,7 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, else { if (((s>>((i+offset)&0x1f))&1)==1) - pbch_e[i] = -pbch_e[i]; + demod_pbch_e[i] = -demod_pbch_e[i]; } } @@ -516,6 +517,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, //uint8_t pbch_a[64]; uint8_t *pbch_a = malloc(sizeof(uint8_t) * 32); uint8_t *pbch_a_prime; + uint8_t *pbch_a_b = malloc(sizeof(uint8_t) *NR_POLAR_PBCH_PAYLOAD_BITS); int8_t *pbch_e_rx; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; uint8_t nushift; @@ -645,40 +647,51 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, #endif //polar decoding de-rate matching - decoderState = polar_decoder(demod_pbch_e, pbch_a_prime, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + decoderState = polar_decoder(demod_pbch_e, pbch_a_b, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + memset(&pbch_a_prime[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); for (i=0; i>3; i++) + printf("pbch_a_prime[%d] = 0x%02x\n", i,pbch_a_prime[i]); +#endif //payload un-scrambling + memset(nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); - nushift = (((pbch_a_prime[0]>>6)&1)<<1) ^ ((pbch_a_prime[3])&1); + nushift = ((pbch_a_prime[0]>>6)&1) ^ (((pbch_a_prime[3])&1)<<1); + //printf("payload unscrambling nushift %d sfn3 %d sfn2 %d M %d\n",nushift, ((pbch_a_prime[0]>>6)&1),((pbch_a_prime[3])&1),M); nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1); //payload deinterleaving uint32_t in=0, out=0; for (int i=0; i>3; i++) - in |= (uint32_t)(nr_ue_pbch_vars->pbch_a_interleaved[i]<<((3-i)<<3)); + in |= (uint32_t)(nr_ue_pbch_vars->pbch_a_interleaved[i]<<(i<<3)); for (int i=0; i<32; i++) { out |= ((in>>i)&1)<<(pbch_deinterleaving_pattern[i]); #ifdef DEBUG_PBCH - printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaver_pattern[i], (in>>i)&1); + printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaving_pattern[i], (in>>i)&1); #endif } for (int i=0; i>3; i++) - nr_ue_pbch_vars->pbch_a[i] = (uint8_t)((out>>(i<<3))&0xff); + pbch_a[i] = (uint8_t)((out>>(i<<3))&0xff); // Fix byte endian for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; //#ifdef DEBUG_PBCH - for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS); i++) - printf("unscrambling pbch_a[%d] = %d \n", i,pbch_a[i]); - //for (i=0; i>3); i++){ + printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); + printf("[PBCH] decoder_output[%d] = %x\n",i,decoded_output[i]); + } //#endif } From 3a5f22d99dce3e3985580294bf797fb5295640d9 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 19 Jul 2018 17:37:36 +0200 Subject: [PATCH 5/7] UE: add MAC and RRC instance initialization --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 16 +-- openair2/LAYER2/NR_MAC_UE/mac.h | 21 ---- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 11 +- openair2/RRC/NR_UE/main_ue.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 10 +- openair2/RRC/NR_UE/rrc_proto.h | 106 ------------------- targets/RT/USER/nr-ue.c | 3 + 7 files changed, 31 insertions(+), 138 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index f5c3e14cc4..4df4e25c4a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -641,10 +641,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0); -#ifdef DEBUG_PBCH +//#ifdef DEBUG_PBCH if (i<16){ printf("unscrambling demod_pbch_e[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);} -#endif +//#endif //polar decoding de-rate matching decoderState = polar_decoder(demod_pbch_e, pbch_a_b, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); @@ -656,10 +656,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, //printf("pbch_a_b[%d] = %u pbch_a_prime[i/8] 0x%02x \n", i,pbch_a_b[i],pbch_a_prime[i/8]); } -#ifdef DEBUG_PBCH +//#ifdef DEBUG_PBCH for (i=0; i>3; i++) printf("pbch_a_prime[%d] = 0x%02x\n", i,pbch_a_prime[i]); -#endif +//#endif //payload un-scrambling memset(nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); @@ -675,9 +675,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, for (int i=0; i<32; i++) { out |= ((in>>i)&1)<<(pbch_deinterleaving_pattern[i]); -#ifdef DEBUG_PBCH +//#ifdef DEBUG_PBCH printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaving_pattern[i], (in>>i)&1); -#endif +//#endif } for (int i=0; i>3; i++) @@ -697,7 +697,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, ue->dl_indication.rx_ind.rx_request_body.pdu_index = FAPI_NR_RX_PDU_BCCH_BCH_TYPE; ue->dl_indication.rx_ind.rx_request_body.pdu_length = 3; - ue->dl_indication.rx_ind.rx_request_body.pdu = &pbch_a[0]; +// ue->dl_indication.rx_ind.rx_request_body.pdu = &pbch_a[0]; + + ue->dl_indication.rx_ind.rx_request_body.pdu = &decoded_output[0]; ue->if_inst->dl_indication(&ue->dl_indication); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac.h b/openair2/LAYER2/NR_MAC_UE/mac.h index a8e7a05609..9cd567b242 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac.h +++ b/openair2/LAYER2/NR_MAC_UE/mac.h @@ -33,28 +33,13 @@ #ifndef __LAYER2_NR_UE_MAC_DEFS_H__ #define __LAYER2_NR_UE_MAC_DEFS_H__ - - #include #include #include - -/** @defgroup _mac MAC - * @ingroup _oai2 - * @{ - */ - -/*!\brief Values of BCCH logical channel (fake)*/ #define NR_BCCH_DL_SCH 3 // SI -/*!\brief Values of PCCH logical channel (fake) */ #define NR_BCCH_BCH 5 // MIB -/*@}*/ - - - - /*!\brief UE layer 2 status */ typedef enum { @@ -65,10 +50,4 @@ typedef enum { } UE_L2_STATE_t; - - - - - - #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index dc3b57ddc1..35d39bc9c8 100755 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -53,7 +53,6 @@ int8_t nr_ue_decode_mib( nr_mac_rrc_data_ind_ue( module_id, CC_id, gNB_index, NR_BCCH_BCH, (uint8_t *) pduP, pdu_len ); - uint32_t frame = mac->mib->systemFrameNumber.buf[0]; uint32_t frame_number_4lsb = (uint32_t)(extra_bits & 0xf); // extra bits[0:3] uint32_t half_frame_bit = (uint32_t)(( extra_bits >> 4 ) & 0x1 ); // extra bits[4] @@ -76,6 +75,16 @@ int8_t nr_ue_decode_mib( } +printf("subcarrier spacing: %d\n", mac->mib->subCarrierSpacingCommon); +printf("ssb carrier offset: %d\n", ssb_subcarrier_offset); +printf("dmrs type A position: %d\n", mac->mib->dmrs_TypeA_Position); +printf("pdcch config sib1: %d\n", mac->mib->pdcch_ConfigSIB1); +printf("cell barred: %d\n", mac->mib->cellBarred); +printf("intra frequcney reselection: %d\n", mac->mib->intraFreqReselection); +printf("system frame number: %d\n", frame); +printf("half frame bit: %d\n", half_frame_bit); + + // fill in the elements in config request inside P5 message mac->phy_config.config_req.pbch_config.system_frame_number = frame; // after calculation mac->phy_config.config_req.pbch_config.subcarrier_spacing_common = mac->mib->subCarrierSpacingCommon; diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index c3557a068d..8188b4f572 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -38,6 +38,6 @@ int nr_l3_init_ue(void){ openair_rrc_top_init_ue_nr(); - return 1; + return 0; } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index b8e3aefae9..4e10d0b55f 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -299,11 +299,17 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( SEQUENCE_free( &asn_DEF_NR_BCCH_BCH_Message, (void *)mib, 1 ); } + +for(i=0; i<4; ++i){ +printf("[RRC] bcch undecod : %d\n", bufferP[i]); +} + asn_dec_rval_t dec_rval = uper_decode_complete( NULL, &asn_DEF_NR_BCCH_BCH_Message, (void **)&bcch_message, - (const void *)bufferP, - buffer_len ); + (const void *)bufferP[1], + 3//buffer_len + ); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 5f932f1675..22be67bcc9 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -104,110 +104,4 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, cons /** @}*/ #endif -/* - * 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 proto.h - * \brief RRC functions prototypes for eNB and UE - * \author Navid Nikaein and Raymond Knopp - * \date 2010 - 2014 - * \email navid.nikaein@eurecom.fr - * \version 1.0 - - */ -/** \addtogroup _rrc - * @{ - */ -#ifndef _RRC_PROTO_H_ -#define _RRC_PROTO_H_ - - -#include "rrc_defs.h" -#include "NR_RRCReconfiguration.h" -#include "NR_MeasConfig.h" -#include "NR_CellGroupConfig.h" -#include "NR_RadioBearerConfig.h" -// -// main_rrc.c -// -/**\brief Layer 3 initialization*/ -int nr_l3_init_ue(void); - -// -// UE_rrc.c -// - -/**\brief Initial the top level RRC structure instance*/ -int8_t openair_rrc_top_init_ue_nr(void); - - - -/**\brief Decode RRC Connection Reconfiguration, sent from E-UTRA RRC Connection Reconfiguration v1510 carring EN-DC config - \param buffer encoded NR-RRC-Connection-Reconfiguration/Secondary-Cell-Group-Config message. - \param size length of buffer*/ -//TODO check to use which one -int8_t nr_rrc_ue_decode_rrcReconfiguration(const uint8_t *buffer, const uint32_t size); -int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const uint8_t *buffer, const uint32_t size); - - -/**\brief Process NR RRC connection reconfiguration via SRB3 - \param rrcReconfiguration decoded rrc connection reconfiguration*/ -int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfiguration); - -/**\prief Process measurement config from NR RRC connection reconfiguration message - \param meas_config measurement configuration*/ -int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config); - -/**\prief Process secondary cell group config from NR RRC connection reconfiguration message or EN-DC primitives - \param cell_group_config secondary cell group configuration*/ -//TODO check EN-DC function call flow. -int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config); - -/**\prief Process radio bearer config from NR RRC connection reconfiguration message - \param radio_bearer_config radio bearer configuration*/ -int8_t nr_rrc_ue_process_radio_bearer_config(NR_RadioBearerConfig_t *radio_bearer_config); - -/**\brief decode NR BCCH-BCH (MIB) message - \param module_idP module id - \param gNB_index gNB index - \param sduP pointer to buffer of ASN message BCCH-BCH - \param sdu_len length of buffer*/ -int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(const module_id_t module_id, const uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len); - -/**\brief Decode NR DCCH from gNB, sent from lower layer through SRB3 - \param module_id module id - \param gNB_index gNB index - \param buffer encoded DCCH bytes stream message - \param size length of buffer*/ -int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(const module_id_t module_id, const uint8_t gNB_index, const uint8_t *buffer, const uint32_t size); - -/**\brief interface between MAC and RRC thru SRB0 (RLC TM/no PDCP) - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param frameP pointer to frame for calculation - \param channel indicator for channel of the pdu - \param pduP pointer to pdu - \param pdu_len data length of pdu*/ -int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index, const uint32_t *frameP, const channel_t channel, const uint8_t* pduP, const sdu_size_t pdu_len); - -/** @}*/ -#endif diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index b530fdb921..2f285ed437 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -43,6 +43,7 @@ #include "fapi_nr_ue_l1.h" #include "PHY/phy_extern_nr_ue.h" #include "LAYER2/NR_MAC_UE/proto.h" +#include "RRC/NR_UE/rrc_proto.h" #include "SCHED_NR/extern.h" //#ifndef NO_RAT_NR @@ -221,6 +222,8 @@ void init_UE(int nb_inst) PHY_vars_UE_g[inst][0] = init_nr_ue_vars(NULL,inst,0); AssertFatal((UE->if_inst = nr_ue_if_module_init(inst)) != NULL,"Can't register interface module\n"); +nr_l3_init_ue(); +nr_l2_init_ue(); UE->if_inst->scheduled_response = nr_ue_scheduled_response; UE->if_inst->phy_config_request = nr_ue_phy_config_request; From 33bd476c85aa72a78e4481a9bf67b4b888183f1f Mon Sep 17 00:00:00 2001 From: Calvin HSU Date: Thu, 19 Jul 2018 18:27:50 +0200 Subject: [PATCH 6/7] UE: Fixed mac/ue_procedures --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 25 ++++++++++---------- openair2/RRC/NR_UE/rrc_UE.c | 10 ++++---- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 35d39bc9c8..779a96afa6 100755 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -58,32 +58,30 @@ int8_t nr_ue_decode_mib( uint32_t half_frame_bit = (uint32_t)(( extra_bits >> 4 ) & 0x1 ); // extra bits[4] uint32_t ssb_subcarrier_offset_msb = (uint32_t)(( extra_bits >> 5 ) & 0x1 ); // extra bits[5] - uint32_t ssb_subcarrier_offset = mac->mib->subCarrierSpacingCommon; + uint32_t ssb_subcarrier_offset = mac->mib->ssb_SubcarrierOffset; - uint32_t ssb_index; + uint32_t ssb_index = 0; frame = frame << 4; frame = frame | frame_number_4lsb; if(l_ssb_equal_64){ ssb_index = (( extra_bits >> 5 ) & 0x7 ); // extra bits[5:7] - mac->phy_config.config_req.pbch_config.ssb_index = ssb_index; }else{ if(ssb_subcarrier_offset_msb){ ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10; } } - -printf("subcarrier spacing: %d\n", mac->mib->subCarrierSpacingCommon); -printf("ssb carrier offset: %d\n", ssb_subcarrier_offset); -printf("dmrs type A position: %d\n", mac->mib->dmrs_TypeA_Position); -printf("pdcch config sib1: %d\n", mac->mib->pdcch_ConfigSIB1); -printf("cell barred: %d\n", mac->mib->cellBarred); -printf("intra frequcney reselection: %d\n", mac->mib->intraFreqReselection); -printf("system frame number: %d\n", frame); -printf("half frame bit: %d\n", half_frame_bit); - +printf("system frame number(with LSB): %d\n", (int)frame); +printf("subcarrier spacing: %d\n", (int)mac->mib->subCarrierSpacingCommon); +printf("ssb carrier offset(with MSB): %d\n", (int)ssb_subcarrier_offset); +printf("dmrs type A position: %d\n", (int)mac->mib->dmrs_TypeA_Position); +printf("pdcch config sib1: %d\n", (int)mac->mib->pdcch_ConfigSIB1); +printf("cell barred: %d\n", (int)mac->mib->cellBarred); +printf("intra frequcney reselection: %d\n", (int)mac->mib->intraFreqReselection); +printf("half frame bit(extra bits): %d\n", (int)half_frame_bit); +printf("ssb index(extra bits): %d\n", (int)ssb_index); // fill in the elements in config request inside P5 message mac->phy_config.config_req.pbch_config.system_frame_number = frame; // after calculation @@ -94,6 +92,7 @@ printf("half frame bit: %d\n", half_frame_bit); mac->phy_config.config_req.pbch_config.cell_barred = mac->mib->cellBarred; mac->phy_config.config_req.pbch_config.intra_frequency_reselection = mac->mib->intraFreqReselection; mac->phy_config.config_req.pbch_config.half_frame_bit = half_frame_bit; + mac->phy_config.config_req.pbch_config.ssb_index = ssb_index; mac->phy_config.config_req.config_mask |= FAPI_NR_CONFIG_REQUEST_MASK_PBCH; if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL){ diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 4e10d0b55f..926f9d8529 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -300,15 +300,15 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( } -for(i=0; i<4; ++i){ -printf("[RRC] bcch undecod : %d\n", bufferP[i]); -} + for(i=0; i Date: Fri, 20 Jul 2018 16:46:42 +0200 Subject: [PATCH 7/7] UE: Add P5 phy_config_request with MIB information. MIB PDU decode complete. --- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 9 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 15 ++-- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 8 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 87 ++++++++++--------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 +- openair2/RRC/NR_UE/rrc_UE.c | 35 ++++---- targets/RT/USER/nr-ue.c | 2 + 7 files changed, 89 insertions(+), 71 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 6baa08cf2c..5b641b102a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -223,7 +223,14 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) nr_gold_pbch(ue); ret = nr_pbch_detection(ue,mode); - ret = -1; //to be deleted + +LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n", + ue->Mod_id, + ue->proc.proc_rxtx[0].frame_rx, + ue->rx_offset, + ue->common_vars.freq_offset ); + + //ret = -1; //to be deleted // write_output("rxdata2.m","rxd2",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1); #ifdef DEBUG_INITIAL_SYNCH diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 4df4e25c4a..ad9e0262e4 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -616,13 +616,13 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, pbch_a = nr_ue_pbch_vars->pbch_a; pbch_a_prime = nr_ue_pbch_vars->pbch_a_prime; -#ifdef DEBUG_PBCH +//#ifdef DEBUG_PBCH //pbch_e_rx = &nr_ue_pbch_vars->llr[0]; short *p = (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][1*20*12]); for (int cnt = 0; cnt < 8 ; cnt++) printf("pbch rx llr %d rxdata_comp %d addr %p\n",*(pbch_e_rx+cnt), p[cnt], &p[0]); -#endif +//#endif for (i=0; ipbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + if(decoderState == -1) + return(decoderState); memset(&pbch_a_prime[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); for (i=0; i>i)&1)<<(pbch_deinterleaving_pattern[i]); -//#ifdef DEBUG_PBCH +#ifdef DEBUG_PBCH printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaving_pattern[i], (in>>i)&1); -//#endif +#endif } for (int i=0; i>3; i++) @@ -693,12 +695,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, printf("[PBCH] decoder_output[%d] = %x\n",i,decoded_output[i]); } //#endif - - + ue->dl_indication.rx_ind.rx_request_body.pdu_index = FAPI_NR_RX_PDU_BCCH_BCH_TYPE; ue->dl_indication.rx_ind.rx_request_body.pdu_length = 3; -// ue->dl_indication.rx_ind.rx_request_body.pdu = &pbch_a[0]; - ue->dl_indication.rx_ind.rx_request_body.pdu = &decoded_output[0]; ue->if_inst->dl_indication(&ue->dl_indication); diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index f0e6a9b6bc..38c16f2228 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -34,6 +34,10 @@ #include "fapi_nr_ue_interface.h" #include "fapi_nr_ue_l1.h" +//#include "PHY/phy_vars_nr_ue.h" + +#include "PHY/defs_nr_UE.h" +extern PHY_VARS_NR_UE ***PHY_vars_UE_g; int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ @@ -70,6 +74,8 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){ printf("ssb index: %d\n", phy_config->config_req.pbch_config.ssb_index); printf("half frame bit: %d\n", phy_config->config_req.pbch_config.half_frame_bit); printf("-------------------------------\n"); + + PHY_vars_UE_g[0][0]->proc.proc_rxtx[0].frame_rx = phy_config->config_req.pbch_config.system_frame_number; } if(phy_config->config_req.config_mask & FAPI_NR_CONFIG_REQUEST_MASK_DL_BWP_COMMON){ @@ -92,4 +98,4 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){ return 0; -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 779a96afa6..0d86399b8a 100755 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -53,52 +53,55 @@ int8_t nr_ue_decode_mib( nr_mac_rrc_data_ind_ue( module_id, CC_id, gNB_index, NR_BCCH_BCH, (uint8_t *) pduP, pdu_len ); - uint32_t frame = mac->mib->systemFrameNumber.buf[0]; - uint32_t frame_number_4lsb = (uint32_t)(extra_bits & 0xf); // extra bits[0:3] - uint32_t half_frame_bit = (uint32_t)(( extra_bits >> 4 ) & 0x1 ); // extra bits[4] - uint32_t ssb_subcarrier_offset_msb = (uint32_t)(( extra_bits >> 5 ) & 0x1 ); // extra bits[5] - - uint32_t ssb_subcarrier_offset = mac->mib->ssb_SubcarrierOffset; - uint32_t ssb_index = 0; + if(mac->mib != NULL){ + uint32_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused); + uint32_t frame_number_4lsb = (uint32_t)(extra_bits & 0xf); // extra bits[0:3] + uint32_t half_frame_bit = (uint32_t)(( extra_bits >> 4 ) & 0x1 ); // extra bits[4] + uint32_t ssb_subcarrier_offset_msb = (uint32_t)(( extra_bits >> 5 ) & 0x1 ); // extra bits[5] + + uint32_t ssb_subcarrier_offset = mac->mib->ssb_SubcarrierOffset; - frame = frame << 4; - frame = frame | frame_number_4lsb; + uint32_t ssb_index = 0; - if(l_ssb_equal_64){ - ssb_index = (( extra_bits >> 5 ) & 0x7 ); // extra bits[5:7] - }else{ - if(ssb_subcarrier_offset_msb){ - ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10; - } + frame = frame << 4; + frame = frame | frame_number_4lsb; + + if(l_ssb_equal_64){ + ssb_index = (( extra_bits >> 5 ) & 0x7 ); // extra bits[5:7] + }else{ + if(ssb_subcarrier_offset_msb){ + ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10; + } + } + + printf("system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]); + printf("system frame number(with LSB): %d\n", (int)frame); + printf("subcarrier spacing: %d\n", (int)mac->mib->subCarrierSpacingCommon); + printf("ssb carrier offset(with MSB): %d\n", (int)ssb_subcarrier_offset); + printf("dmrs type A position: %d\n", (int)mac->mib->dmrs_TypeA_Position); + printf("pdcch config sib1: %d\n", (int)mac->mib->pdcch_ConfigSIB1); + printf("cell barred: %d\n", (int)mac->mib->cellBarred); + printf("intra frequcney reselection: %d\n", (int)mac->mib->intraFreqReselection); + printf("half frame bit(extra bits): %d\n", (int)half_frame_bit); + printf("ssb index(extra bits): %d\n", (int)ssb_index); + + // fill in the elements in config request inside P5 message + mac->phy_config.config_req.pbch_config.system_frame_number = frame; // after calculation + mac->phy_config.config_req.pbch_config.subcarrier_spacing_common = mac->mib->subCarrierSpacingCommon; + mac->phy_config.config_req.pbch_config.ssb_subcarrier_offset = ssb_subcarrier_offset; // after calculation + mac->phy_config.config_req.pbch_config.dmrs_type_a_position = mac->mib->dmrs_TypeA_Position; + mac->phy_config.config_req.pbch_config.pdcch_config_sib1 = mac->mib->pdcch_ConfigSIB1; + mac->phy_config.config_req.pbch_config.cell_barred = mac->mib->cellBarred; + mac->phy_config.config_req.pbch_config.intra_frequency_reselection = mac->mib->intraFreqReselection; + mac->phy_config.config_req.pbch_config.half_frame_bit = half_frame_bit; + mac->phy_config.config_req.pbch_config.ssb_index = ssb_index; + mac->phy_config.config_req.config_mask |= FAPI_NR_CONFIG_REQUEST_MASK_PBCH; + + if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL){ + mac->if_module->phy_config_request(&mac->phy_config); + } } - -printf("system frame number(with LSB): %d\n", (int)frame); -printf("subcarrier spacing: %d\n", (int)mac->mib->subCarrierSpacingCommon); -printf("ssb carrier offset(with MSB): %d\n", (int)ssb_subcarrier_offset); -printf("dmrs type A position: %d\n", (int)mac->mib->dmrs_TypeA_Position); -printf("pdcch config sib1: %d\n", (int)mac->mib->pdcch_ConfigSIB1); -printf("cell barred: %d\n", (int)mac->mib->cellBarred); -printf("intra frequcney reselection: %d\n", (int)mac->mib->intraFreqReselection); -printf("half frame bit(extra bits): %d\n", (int)half_frame_bit); -printf("ssb index(extra bits): %d\n", (int)ssb_index); - - // fill in the elements in config request inside P5 message - mac->phy_config.config_req.pbch_config.system_frame_number = frame; // after calculation - mac->phy_config.config_req.pbch_config.subcarrier_spacing_common = mac->mib->subCarrierSpacingCommon; - mac->phy_config.config_req.pbch_config.ssb_subcarrier_offset = ssb_subcarrier_offset; // after calculation - mac->phy_config.config_req.pbch_config.dmrs_type_a_position = mac->mib->dmrs_TypeA_Position; - mac->phy_config.config_req.pbch_config.pdcch_config_sib1 = mac->mib->pdcch_ConfigSIB1; - mac->phy_config.config_req.pbch_config.cell_barred = mac->mib->cellBarred; - mac->phy_config.config_req.pbch_config.intra_frequency_reselection = mac->mib->intraFreqReselection; - mac->phy_config.config_req.pbch_config.half_frame_bit = half_frame_bit; - mac->phy_config.config_req.pbch_config.ssb_index = ssb_index; - mac->phy_config.config_req.config_mask |= FAPI_NR_CONFIG_REQUEST_MASK_PBCH; - - if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL){ - mac->if_module->phy_config_request(&mac->phy_config); - } - return 0; } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 75341d3569..efc5e0631c 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -43,13 +43,13 @@ static nr_ue_if_module_t *nr_ue_if_module_inst[MAX_IF_MODULES]; int8_t handle_bcch_bch(uint32_t pdu_len, uint8_t *pduP){ // pdu_len = 4, 32bits - uint8_t extra_bits = pduP[3]; + uint8_t extra_bits = pduP[0]; nr_ue_decode_mib( (module_id_t)0, 0, 0, extra_bits, 0, // Lssb = 64 is not support - pduP, + &pduP[1], pdu_len ); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 926f9d8529..6d7aa59136 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -311,25 +311,26 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( buffer_len ); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - - for (i=0; imessage.choice.mib->systemFrameNumber.buf != 0){ + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + + for (i=0; imessage.choice.mib; + //memcpy( (void *)mib, + // (void *)&bcch_message->message.choice.mib, + // sizeof(NR_MIB_t) ); + + nr_rrc_mac_config_req_ue( 0, 0, 0, mib, NULL, NULL, NULL); } - - // link to rrc instance - mib = bcch_message->message.choice.mib; - //memcpy( (void *)mib, - // (void *)&bcch_message->message.choice.mib, - // sizeof(NR_MIB_t) ); - - nr_rrc_mac_config_req_ue( 0, 0, 0, mib, NULL, NULL, NULL); - return 0; } diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 2f285ed437..e0e8b1ee94 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -224,6 +224,8 @@ void init_UE(int nb_inst) AssertFatal((UE->if_inst = nr_ue_if_module_init(inst)) != NULL,"Can't register interface module\n"); nr_l3_init_ue(); nr_l2_init_ue(); +NR_UE_MAC_INST_t *UE_MAC_INST = get_mac_inst(0); +UE_MAC_INST->if_module = UE->if_inst; UE->if_inst->scheduled_response = nr_ue_scheduled_response; UE->if_inst->phy_config_request = nr_ue_phy_config_request;