From fbbb2e03cbe0371c8887f9dfa4bd3583660c45a1 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Tue, 19 Jun 2018 10:15:00 +0200 Subject: [PATCH 01/10] ue nr pbch channel est fix --- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 4 +- .../nr_dl_channel_estimation.c | 30 ++++---- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 72 ++++++++++--------- 3 files changed, 52 insertions(+), 54 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index 0b3ffe5bc7..1af712a26f 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -49,7 +49,9 @@ int wt1[8][2] = {{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1}}; int wf2[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}}; 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_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}; //extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; 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 2d262e8458..ebd68bc11a 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -27,7 +27,7 @@ #include "PHY/defs_nr_UE.h" #include "filt16a_32.h" #include "T.h" -#define DEBUG_CH +//#define DEBUG_CH int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_id, @@ -154,7 +154,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, 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) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[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 multadd_real_vector_complex_scalar(fl, ch, @@ -162,8 +162,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, 16); pil+=2; rxF+=8; - for (int i= 0; i<8; i++) - printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); + //for (int i= 0; i<8; i++) + //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); 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); @@ -174,19 +174,15 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 16); - //printf("after dl_ch %d %d\n", dl_ch, *(dl_ch)); - //for (int i= 0; i<16; i++) - // printf("dl_ch %d %d\n", dl_ch+i, *(dl_ch+i)); - pil+=2; rxF+=8; 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 +#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 multadd_real_vector_complex_scalar(fr, ch, @@ -204,7 +200,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]); + 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 multadd_real_vector_complex_scalar(fl, ch, @@ -220,7 +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]); + 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 multadd_real_vector_complex_scalar(fm, ch, @@ -232,9 +228,9 @@ 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 +#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 multadd_real_vector_complex_scalar(fr, ch, @@ -249,8 +245,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } - printf("finish dl_ch addr %p\n", dl_ch); - } return(0); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index bbb2987776..b50b5636d9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -71,17 +71,17 @@ uint16_t nr_pbch_extract(int **rxdataF, int nushiftmod4 = frame_parms->nushift; for (aarx=0; aarxnb_antennas_rx; aarx++) { - - printf("extract_rbs (nushift %d): rx_offset=%d, symbol %d\n",frame_parms->nushift, - (rx_offset + (symbol*(frame_parms->ofdm_symbol_size))),symbol); - + rxF = &rxdataF[aarx][(rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; rxF_ext = &rxdataF_ext[aarx][symbol*(20*12)]; #ifdef DEBUG_PBCH + printf("extract_rbs (nushift %d): rx_offset=%d, symbol %d\n",frame_parms->nushift, + (rx_offset + (symbol*(frame_parms->ofdm_symbol_size))),symbol); int16_t *p = (int16_t *)rxF; - for (int i =0; i<240;i++){ + for (int i =0; i<8;i++){ printf("rxF [%d]= %d\n",i,rxF[i]); - printf("pbch pss %d %d @%p\n", p[2*i], p[2*i+1], &p[2*i]); + printf("pbch extract rxF %d %d addr %p\n", p[2*i], p[2*i+1], &p[2*i]); + printf("rxF ext addr %p\n", &rxF_ext[i]); } #endif @@ -105,13 +105,13 @@ uint16_t nr_pbch_extract(int **rxdataF, rxF+=12; rxF_ext+=9; } else { //symbol 2 - if ((rb < 4) && (rb >15)){ + if ((rb < 4) || (rb >15)){ for (i=0; i<12; i++) { if ((i!=nushiftmod4) && (i!=(nushiftmod4+4)) && (i!=(nushiftmod4+8))) { rxF_ext[j]=rxF[i]; - //printf("rxF ext[%d] = %d at %p\n",j,rxF_ext[j],&rxF[i]); + //printf("symbol2 rxF ext[%d] = %d at %p\n",j,rxF_ext[j],&rxF[i]); j++; } } @@ -128,7 +128,7 @@ uint16_t nr_pbch_extract(int **rxdataF, else dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][0]; - printf("dl_ch0 addr %p\n",dl_ch0); + //printf("dl_ch0 addr %p\n",dl_ch0); dl_ch0_ext = &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*(20*12)]; @@ -140,8 +140,8 @@ uint16_t nr_pbch_extract(int **rxdataF, (i!=(nushiftmod4+4)) && (i!=(nushiftmod4+8))) { dl_ch0_ext[j]=dl_ch0[i]; - if ((rb==0) && (i<2)) - printf("dl ch0 ext[%d] = %d dl_ch0 [%d]= %d\n",j,dl_ch0_ext[j],i,dl_ch0[i]); + //if ((rb==0) && (i<2)) + //printf("dl ch0 ext[%d] = %d dl_ch0 [%d]= %d\n",j,dl_ch0_ext[j],i,dl_ch0[i]); j++; } } @@ -150,12 +150,13 @@ uint16_t nr_pbch_extract(int **rxdataF, dl_ch0_ext+=9; } else { //symbol 2 - if ((rb < 4) && (rb >15)){ + if ((rb < 4) || (rb >15)){ for (i=0; i<12; i++) { if ((i!=nushiftmod4) && (i!=(nushiftmod4+4)) && (i!=(nushiftmod4+8))) { dl_ch0_ext[j]=dl_ch0[i]; + //printf("symbol2 dl ch0 ext[%d] = %d dl_ch0 [%d]= %d\n",j,dl_ch0_ext[j],i,dl_ch0[i]); j++; } } @@ -181,7 +182,7 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext, uint32_t symbol) { - int16_t rb, nb_rb=6; + int16_t rb, nb_rb=20; uint8_t aatx,aarx; #if defined(__x86_64__) || defined(__i386__) @@ -193,19 +194,16 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext, #endif int avg1=0,avg2=0; - uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; - uint32_t symbol_mod = symbol % nsymb; - - for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) + for (aatx=0; aatxnb_antenna_ports_eNB;aatx++) for (aarx=0; aarxnb_antennas_rx; aarx++) { //clear average level #if defined(__x86_64__) || defined(__i386__) avg128 = _mm_setzero_si128(); - dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; + dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]; #elif defined(__arm__) avg128 = vdupq_n_s32(0); - dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; + dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]; #endif for (rb=0; rb=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) + for (aatx=0; aatxnb_antenna_ports_eNB;aatx++) for (aarx=0; aarxnb_antennas_rx; aarx++) { #if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol_mod*6*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol_mod*6*12]; + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*20*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]; + //printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]); + //printf("rxdataf ext addr %p symbol %d\n", &rxdataF_ext[aarx][symbol*20*12], symbol); + //printf("rxdataf_comp addr %p\n",&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]); #elif defined(__arm__) // to be filled in @@ -321,7 +321,6 @@ void nr_pbch_channel_compensation(int **rxdataF_ext, // print_shorts("ch:",dl_ch128+1); // print_shorts("pack:",rxdataF_comp128+1); - if (symbol_mod>1) { // multiply by conjugated channel mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) @@ -342,11 +341,7 @@ void nr_pbch_channel_compensation(int **rxdataF_ext, dl_ch128+=3; rxdataF128+=3; rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } + #elif defined(__arm__) // to be filled in #endif @@ -559,7 +554,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, msg("[PBCH] starting extract ofdm size %d\n",frame_parms->ofdm_symbol_size ); #endif - printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF); + //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF); //write_output("rxdataF0_pbch.m","rxF0pbch",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF,frame_parms->ofdm_symbol_size*4,2,1); nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF, @@ -590,6 +585,8 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, symbol, log2_maxh); // log2_maxh+I0_shift + //write_output("rxdataF_comp.m","rxFcomp",nr_ue_pbch_vars->rxdataF_comp,180,2,1); + /*if (frame_parms->nb_antennas_rx > 1) pbch_detection_mrc(frame_parms, nr_ue_pbch_vars->rxdataF_comp, @@ -607,13 +604,13 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, if (symbol>(nsymb>>1)+1) { nr_pbch_quantize(pbch_e_rx, - (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), + (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*240]), 144); pbch_e_rx+=144; } else { nr_pbch_quantize(pbch_e_rx, - (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), + (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*240]), 96); pbch_e_rx+=96; @@ -623,8 +620,13 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, } pbch_e_rx = nr_ue_pbch_vars->llr; + //#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 //un-scrambling #ifdef DEBUG_PBCH From 1ecb006291a6aa8773209d1b09430dcda66fa114 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 19 Jun 2018 15:38:30 +0200 Subject: [PATCH 02/10] ue adding nr polar decoder --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/INIT/nr_init_ue.c | 4 + openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 197 +++++-------------------- openair1/PHY/defs_nr_UE.h | 8 +- 4 files changed, 46 insertions(+), 164 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 4df0cc51e1..3339f3fb58 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1292,6 +1292,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ${OPENAIR1_DIR}/PHY/INIT/nr_init_ue.c + ${PHY_POLARSRC} ) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 91b318f94e..07a3c3ec6e 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -33,6 +33,7 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/LTE_REFSIG/lte_refsig.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" //uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; @@ -955,6 +956,9 @@ void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms) generate_ul_reference_signal_sequences(SHRT_MAX); + // Polar encoder init for PBCH + nr_polar_init(&frame_parms->pbch_polar_params, 1); + //lte_sync_time_init(frame_parms); //generate_ul_ref_sigs(); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index b50b5636d9..8361d55baf 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -31,20 +31,11 @@ */ #include "PHY/defs_nr_UE.h" #include "PHY/CODING/coding_extern.h" -#include "PHY/CODING/lte_interleaver_inline.h" -//#include "defs.h" -//#include "extern.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/sse_intrin.h" -#ifdef PHY_ABSTRACTION -#include "SIMULATION/TOOLS/defs.h" -#endif - - //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING -//#define INTERFERENCE_MITIGATION 1 #ifdef OPENAIR2 //#include "PHY_INTERFACE/defs.h" @@ -255,8 +246,8 @@ void nr_pbch_channel_compensation(int **rxdataF_ext, uint8_t output_shift) { - uint16_t rb,nb_rb=20; - uint8_t aatx,aarx,symbol_mod; + uint16_t rb,nb_rb=15; + uint8_t aatx,aarx; #if defined(__x86_64__) || defined(__i386__) __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; #elif defined(__arm__) @@ -394,35 +385,9 @@ void nr_pbch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, #endif } -void nr_pbch_scrambling(NR_DL_FRAME_PARMS *frame_parms, - uint8_t *pbch_e, - uint32_t length) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in lte_gold_generic - x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 - // msg("pbch_scrambling: Nid_cell = %d\n",x2); - - for (i=0; i>(i&0x1f))&1); - - } -} - void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, int8_t* llr, - uint32_t length, - uint8_t frame_mod4) + uint32_t length) { int i; uint8_t reset; @@ -440,13 +405,8 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, reset = 0; } - // take the quarter of the PBCH that corresponds to this frame - if ((i>=(frame_mod4*(length>>2))) && (i<((1+frame_mod4)*(length>>2)))) { - // if (((s>>(i%32))&1)==1) - - if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; - } + if (((s>>(i%32))&1)==0) + llr[i] = -llr[i]; } } @@ -488,7 +448,7 @@ void nr_pbch_alamouti(NR_DL_FRAME_PARMS *frame_parms, } -void nr_pbch_quantize(int8_t *pbch_llr8, +void nr_pbch_quantize(int16_t *pbch_llr16, int16_t *pbch_llr, uint16_t len) { @@ -496,20 +456,16 @@ void nr_pbch_quantize(int8_t *pbch_llr8, uint16_t i; for (i=0; i7) + /*if (pbch_llr[i]>7) pbch_llr8[i]=7; else if (pbch_llr[i]<-8) pbch_llr8[i]=-8; - else - pbch_llr8[i] = (char)(pbch_llr[i]); + else*/ + pbch_llr16[i] = (char)(pbch_llr[i]); } } -static unsigned char dummy_w_rx[3*3*(16+PBCH_A)]; -static int8_t pbch_w_rx[3*3*(16+PBCH_A)],pbch_d_rx[96+(3*(16+PBCH_A))]; - - uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, NR_UE_PBCH *nr_ue_pbch_vars, @@ -522,38 +478,28 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; - uint8_t log2_maxh;//,aatx,aarx; + uint8_t log2_maxh; int max_h=0; int symbol,i; - uint32_t nsymb = (frame_parms->Ncp==0) ? 14:12; - uint16_t pbch_E; uint8_t pbch_a[8]; - uint8_t RCC; - int8_t *pbch_e_rx; + int16_t *pbch_e_rx; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; uint16_t crc; + int8_t decoderState=0; + uint8_t decoderListSize = 8, pathMetricAppr = 0; + double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. int subframe_rx = proc->subframe_rx; - // pbch_D = 16+PBCH_A; - - pbch_E = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK) - pbch_e_rx = &nr_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)]; -#ifdef DEBUG_PBCH - msg("[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode); -#endif + pbch_e_rx = &nr_ue_pbch_vars->llr[0]; // clear LLR buffer - memset(nr_ue_pbch_vars->llr,0,pbch_E); + memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_PAYLOAD_BITS); for (symbol=1; symbol<4; symbol++) { -#ifdef DEBUG_PBCH - msg("[PBCH] starting extract ofdm size %d\n",frame_parms->ofdm_symbol_size ); -#endif - //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF); //write_output("rxdataF0_pbch.m","rxF0pbch",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF,frame_parms->ofdm_symbol_size*4,2,1); @@ -565,7 +511,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, high_speed_flag, frame_parms); #ifdef DEBUG_PBCH - msg("[PHY] PBCH Symbol %d\n",symbol); + msg("[PHY] PBCH Symbol %d ofdm size %d\n",symbol, frame_parms->ofdm_symbol_size ); msg("[PHY] PBCH starting channel_level\n"); #endif @@ -595,31 +541,30 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, if (mimo_mode == ALAMOUTI) { nr_pbch_alamouti(frame_parms,nr_ue_pbch_vars->rxdataF_comp,symbol); - // msg("[PBCH][RX] Alamouti receiver not yet implemented!\n"); - // return(-1); } else if (mimo_mode != SISO) { msg("[PBCH][RX] Unsupported MIMO mode\n"); return(-1); } - if (symbol>(nsymb>>1)+1) { + if (symbol==2) { nr_pbch_quantize(pbch_e_rx, - (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*240]), - 144); + (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), + 108); - pbch_e_rx+=144; + pbch_e_rx+=108; } else { nr_pbch_quantize(pbch_e_rx, - (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*240]), - 96); + (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), + 360); - pbch_e_rx+=96; + pbch_e_rx+=360; } } pbch_e_rx = nr_ue_pbch_vars->llr; + //#ifdef DEBUG_PBCH //pbch_e_rx = &nr_ue_pbch_vars->llr[0]; @@ -628,53 +573,25 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, printf("pbch rx llr %d rxdata_comp %d addr %p\n",*(pbch_e_rx+cnt), p[cnt], &p[0]); //#endif + //polar decoding de-rate matching + decoderState = polar_decoder(pbch_e_rx, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + + memset(pbch_a,0,((16+NR_POLAR_PBCH_PAYLOAD_BITS)>>3)); //un-scrambling -#ifdef DEBUG_PBCH - msg("[PBCH] doing unscrambling\n"); -#endif - - nr_pbch_unscrambling(frame_parms, - pbch_e_rx, - pbch_E, - frame_mod4); + pbch_a, + NR_POLAR_PBCH_PAYLOAD_BITS); - - - //un-rate matching -#ifdef DEBUG_PBCH - msg("[PBCH] doing un-rate-matching\n"); -#endif - - - memset(dummy_w_rx,0,3*3*(16+PBCH_A)); - RCC = generate_dummy_w_cc(16+PBCH_A, - dummy_w_rx); - - - lte_rate_matching_cc_rx(RCC,pbch_E,pbch_w_rx,dummy_w_rx,pbch_e_rx); - - sub_block_deinterleaving_cc((unsigned int)(PBCH_A+16), - &pbch_d_rx[96], - &pbch_w_rx[0]); - - memset(pbch_a,0,((16+PBCH_A)>>3)); - - - - - phy_viterbi_lte_sse2(pbch_d_rx+96,pbch_a,16+PBCH_A); - - // Fix byte endian of PBCH (bit 23 goes in first) - for (i=0; i<(PBCH_A>>3); i++) - decoded_output[(PBCH_A>>3)-i-1] = pbch_a[i]; + // 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<(PBCH_A>>3); i++) + for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) msg("[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); -#endif //DEBUG_PBCH +#endif #ifdef DEBUG_PBCH msg("PBCH CRC %x : %x\n", @@ -694,46 +611,4 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, else return(-1); - } - -#ifdef PHY_ABSTRACTION -uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue, - uint8_t eNB_id, - uint8_t pbch_phase) -{ - - double bler=0.0;//, x=0.0; - double sinr=0.0; - uint16_t nb_rb = phy_vars_ue->frame_parms.N_RB_DL; - int16_t f; - uint8_t CC_id=phy_vars_ue->CC_id; - int frame_rx = phy_vars_ue->proc.proc_rxtx[0].frame_rx; - - // compute effective sinr - // TODO: adapt this to varible bandwidth - for (f=(nb_rb*6-3*12); f<(nb_rb*6+3*12); f++) { - if (f!=0) //skip DC - sinr += pow(10, 0.1*(phy_vars_ue->sinr_dB[f])); - } - - sinr = 10*log10(sinr/(6*12)); - - bler = pbch_bler(sinr); - - LOG_D(PHY,"EMUL UE rx_pbch_emul: eNB_id %d, pbch_phase %d, sinr %f dB, bler %f \n", - eNB_id, - pbch_phase, - sinr, - bler); - - if (pbch_phase == (frame_rx % 4)) { - if (uniformrandom() >= bler) { - memcpy(phy_vars_ue->pbch_vars[eNB_id]->decoded_output,PHY_vars_eNB_g[eNB_id][CC_id]->pbch_pdu,PBCH_PDU_SIZE); - return(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.nb_antenna_ports_eNB); - } else - return(-1); - } else - return(-1); -} -#endif diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index bf8020ecda..0c13919bd0 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -34,6 +34,8 @@ #include "defs_nr_common.h" +#include "CODING/nrPolar_tools/nr_polar_pbch_defs.h" + #define _GNU_SOURCE #include @@ -110,8 +112,8 @@ #define openair_sched_exit() exit(-1) -#define max(a,b) ((a)>(b) ? (a) : (b)) -#define min(a,b) ((a)<(b) ? (a) : (b)) +//#define max(a,b) ((a)>(b) ? (a) : (b)) +//#define min(a,b) ((a)<(b) ? (a) : (b)) #define bzero(s,n) (memset((s),0,(n))) @@ -640,7 +642,7 @@ typedef struct { int32_t **dl_ch_estimates_ext; /// \brief Pointer to PBCH llrs. /// - first index: ? [0..1919] (hard coded) - int8_t *llr; + int16_t *llr; /// \brief Pointer to PBCH decoded output. /// - first index: ? [0..63] (hard coded) uint8_t *decoded_output; From 269e2182e4ae5546eff45ad65a95f4da3525143a Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 19 Jun 2018 15:59:35 +0200 Subject: [PATCH 03/10] ue nr pbch update --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 8361d55baf..0048ea73ff 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -386,7 +386,7 @@ void nr_pbch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, } void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, - int8_t* llr, + uint8_t* pbch_a, uint32_t length) { int i; @@ -406,7 +406,7 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, } if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; + pbch_a[i] = -pbch_a[i]; } } @@ -496,7 +496,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, pbch_e_rx = &nr_ue_pbch_vars->llr[0]; // clear LLR buffer - memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_PAYLOAD_BITS); + memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_E); for (symbol=1; symbol<4; symbol++) { @@ -549,9 +549,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, if (symbol==2) { nr_pbch_quantize(pbch_e_rx, (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), - 108); + 144); - pbch_e_rx+=108; + pbch_e_rx+=144; } else { nr_pbch_quantize(pbch_e_rx, (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), @@ -574,7 +574,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, //#endif //polar decoding de-rate matching - decoderState = polar_decoder(pbch_e_rx, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + decoderState = polar_decoder((double *)pbch_e_rx, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); memset(pbch_a,0,((16+NR_POLAR_PBCH_PAYLOAD_BITS)>>3)); //un-scrambling From 227216f023b701709688297e33e27e76a5129c38 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 21 Jun 2018 15:39:58 +0200 Subject: [PATCH 04/10] ue add pbch demodulation --- openair1/PHY/INIT/nr_init_ue.c | 8 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 55 +++++++++++++++++++------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 07a3c3ec6e..1d393af8d6 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -842,17 +842,17 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, pbch_vars[eNB_id]->rxdataF_ext = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); pbch_vars[eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pbch_vars[eNB_id]->llr = (int8_t*)malloc16_clear( 1920 ); + pbch_vars[eNB_id]->llr = (int8_t*)malloc16_clear( 1920 );// prach_vars[eNB_id]->prachF = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); prach_vars[eNB_id]->prach = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); for (i=0; inb_antennas_rx; i++) { - pbch_vars[eNB_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); + pbch_vars[eNB_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*20*12*4 ); for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) { int idx = (j<<1)+i; - pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); - pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); + pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*20*12*4 ); + pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*20*12*4 ); } } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 0048ea73ff..16189af5ac 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -33,6 +33,7 @@ #include "PHY/CODING/coding_extern.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/sse_intrin.h" +#include "SIMULATION/TOOLS/sim.h" //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING @@ -246,7 +247,7 @@ void nr_pbch_channel_compensation(int **rxdataF_ext, uint8_t output_shift) { - uint16_t rb,nb_rb=15; + uint16_t rb,nb_rb=20; uint8_t aatx,aarx; #if defined(__x86_64__) || defined(__i386__) __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; @@ -466,6 +467,10 @@ void nr_pbch_quantize(int16_t *pbch_llr16, } } +unsigned short sign(short x) { + return (unsigned short)x >> 15; +} + uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, NR_UE_PBCH *nr_ue_pbch_vars, @@ -482,14 +487,24 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, int max_h=0; int symbol,i; - uint8_t pbch_a[8]; + uint8_t pbch_a[64]; int16_t *pbch_e_rx; 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 *demod_pbch_e = malloc (sizeof(double) * 864); + unsigned short idx_demod =0; int8_t decoderState=0; uint8_t decoderListSize = 8, pathMetricAppr = 0; double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. + double *channelOutput = malloc (sizeof(double) * 864); //add noise + uint8_t *estimatedOutput = malloc(sizeof(uint8_t) * 32); //decoder output + memset(&channelOutput[0], 0, sizeof(double) * 864); + memset(&estimatedOutput[0], 0, sizeof(uint8_t) * 32); + + for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; int subframe_rx = proc->subframe_rx; @@ -573,25 +588,37 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, printf("pbch rx llr %d rxdata_comp %d addr %p\n",*(pbch_e_rx+cnt), p[cnt], &p[0]); //#endif - //polar decoding de-rate matching - decoderState = polar_decoder((double *)pbch_e_rx, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + for (int i=0; i>3)); + + //polar decoding de-rate matching + decoderState = polar_decoder(demod_pbch_e, estimatedOutput, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + + //memset(pbch_a,0,((16+NR_POLAR_PBCH_PAYLOAD_BITS)>>3)); //un-scrambling - nr_pbch_unscrambling(frame_parms, - pbch_a, - NR_POLAR_PBCH_PAYLOAD_BITS); + // nr_pbch_unscrambling(frame_parms, + // pbch_a, + // NR_POLAR_PBCH_PAYLOAD_BITS); // 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]; + for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) + printf("estimated output[%d] = %d \n", i,estimatedOutput[i]); + //decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; -#ifdef DEBUG_PBCH + //#ifdef DEBUG_PBCH - for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) - msg("[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); + // for (i=0; i<2; i++) + // printf("[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); -#endif + //#endif #ifdef DEBUG_PBCH msg("PBCH CRC %x : %x\n", From 8ae993aef5d0e06126e37aa27871d85d468c27a8 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Fri, 22 Jun 2018 11:19:41 +0200 Subject: [PATCH 05/10] ue add nr pbch unscrambling --- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 3 ++ openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 40 ++++++++++++------- targets/RT/USER/nr-ue.c | 4 +- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index f791a1d597..4af870fb5f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -95,6 +95,8 @@ int pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) pbch_decoded = 0; + printf("pbch_detection nid_cell %d\n",frame_parms->Nid_cell); + //for (frame_mod4=0; frame_mod4<4; frame_mod4++) { pbch_tx_ant = nr_rx_pbch(ue, &ue->proc.proc_rxtx[0], @@ -265,6 +267,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) nr_gold_pbch(ue); ret = pbch_detection(ue,mode); + ret = -1; // 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 16189af5ac..c7e32e0a5e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -394,6 +394,8 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, uint8_t reset; uint32_t x1, x2, s=0; + 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 @@ -402,12 +404,13 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, for (i=0; i>(i%32))&1)==0) - pbch_a[i] = -pbch_a[i]; + printf("s = %d\n",((s>>(i%32))&1) ); + if (((s>>(i%32))&1)==1) + pbch_a[i] = 1-pbch_a[i]; } } @@ -449,7 +452,7 @@ void nr_pbch_alamouti(NR_DL_FRAME_PARMS *frame_parms, } -void nr_pbch_quantize(int16_t *pbch_llr16, +void nr_pbch_quantize(int8_t *pbch_llr8, int16_t *pbch_llr, uint16_t len) { @@ -462,7 +465,7 @@ void nr_pbch_quantize(int16_t *pbch_llr16, else if (pbch_llr[i]<-8) pbch_llr8[i]=-8; else*/ - pbch_llr16[i] = (char)(pbch_llr[i]); + pbch_llr8[i] = (char)(pbch_llr[i]); } } @@ -487,9 +490,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, int max_h=0; int symbol,i; - uint8_t pbch_a[64]; + //uint8_t pbch_a[64]; + uint8_t *pbch_a = malloc(sizeof(uint8_t) * 32); ; - int16_t *pbch_e_rx; + int8_t *pbch_e_rx; 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}; @@ -504,6 +508,11 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, memset(&channelOutput[0], 0, sizeof(double) * 864); memset(&estimatedOutput[0], 0, sizeof(uint8_t) * 32); + memset(&pbch_a[0], 0, sizeof(uint8_t) * 32); + frame_parms->Nid_cell = 100; + + printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); + for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; int subframe_rx = proc->subframe_rx; @@ -600,17 +609,20 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, //polar decoding de-rate matching - decoderState = polar_decoder(demod_pbch_e, estimatedOutput, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); - //memset(pbch_a,0,((16+NR_POLAR_PBCH_PAYLOAD_BITS)>>3)); + for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) + printf("pbch_a[%d] = %d \n", i,pbch_a[i]); + //un-scrambling - // nr_pbch_unscrambling(frame_parms, - // pbch_a, - // NR_POLAR_PBCH_PAYLOAD_BITS); + nr_pbch_unscrambling(frame_parms,pbch_a,NR_POLAR_PBCH_PAYLOAD_BITS); + + for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) + printf("after unscrambling pbch_a[%d] = %d \n", i,pbch_a[i]); // Fix byte endian - for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) - printf("estimated output[%d] = %d \n", i,estimatedOutput[i]); + //for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) + // printf("estimated output[%d] = %d \n", i,estimatedOutput[i]); //decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; //#ifdef DEBUG_PBCH diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index ac0acef776..49a2307c9e 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -61,6 +61,8 @@ #include "T.h" extern double cpuf; +static nfapi_config_request_t config_t; +static nfapi_config_request_t* config =&config_t; #define FRAME_PERIOD 100000000ULL #define DAQ_PERIOD 66667ULL @@ -413,7 +415,7 @@ static void *UE_thread_synch(void *arg) { //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]); //UE->rfdevice.trx_stop_func(&UE->rfdevice); // sleep(1); - nr_init_frame_parms_ue(&UE->frame_parms); + nr_init_frame_parms_ue(config,&UE->frame_parms); /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { LOG_E(HW,"Could not start the device\n"); oai_exit=1; From d091e8469457caa38fda8e39d5f14ddd279cfe9d Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Mon, 25 Jun 2018 11:54:18 +0200 Subject: [PATCH 06/10] ue nr pbch bug fix --- openair1/PHY/INIT/nr_parms.c | 12 ------------ openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 8 ++++---- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 6 +++--- openair1/PHY/defs_nr_UE.h | 2 +- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 1fcaaed494..8512beb0d5 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -165,18 +165,6 @@ int nr_init_frame_parms_ue(nfapi_config_request_t* config, LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB, Ncp); #endif - frame_parms->frame_type = FDD; - frame_parms->tdd_config = 3; - //frame_parms[CC_id]->tdd_config_S = 0; - frame_parms->N_RB_DL = 100; - frame_parms->N_RB_UL = 100; - frame_parms->Ncp = NORMAL; - //frame_parms[CC_id]->Ncp_UL = NORMAL; - frame_parms->Nid_cell = 0; - //frame_parms[CC_id]->num_MBSFN_config = 0; - frame_parms->nb_antenna_ports_eNB = 1; - frame_parms->nb_antennas_tx = 1; - frame_parms->nb_antennas_rx = 1; if (Ncp == EXTENDED) AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 4af870fb5f..793ded988f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -52,7 +52,7 @@ void set_default_frame_parms_single(nfapi_config_request_t *config, NR_DL_FRAME_ //#define DEBUG_INITIAL_SYNCH -int pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) +int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) { uint8_t l,pbch_decoded,frame_mod4,pbch_tx_ant,dummy; @@ -262,12 +262,12 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) rx_sss_nr(ue,&metric_fdd_ncp,&phase_fdd_ncp); - set_default_frame_parms_single(config,&ue->frame_parms); + //set_default_frame_parms_single(config,&ue->frame_parms); nr_init_frame_parms_ue(config,&ue->frame_parms); nr_gold_pbch(ue); - ret = pbch_detection(ue,mode); - ret = -1; + ret = nr_pbch_detection(ue,mode); + 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 c7e32e0a5e..6c942795e3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -470,8 +470,8 @@ void nr_pbch_quantize(int8_t *pbch_llr8, } } -unsigned short sign(short x) { - return (unsigned short)x >> 15; +unsigned char sign(int8_t x) { + return (unsigned char)x >> 7; } uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, @@ -612,7 +612,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) - printf("pbch_a[%d] = %d \n", i,pbch_a[i]); + printf("pbch_a[%d] = %u \n", i,pbch_a[i]); //un-scrambling nr_pbch_unscrambling(frame_parms,pbch_a,NR_POLAR_PBCH_PAYLOAD_BITS); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 0c13919bd0..3df36fdc66 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -642,7 +642,7 @@ typedef struct { int32_t **dl_ch_estimates_ext; /// \brief Pointer to PBCH llrs. /// - first index: ? [0..1919] (hard coded) - int16_t *llr; + int8_t *llr; /// \brief Pointer to PBCH decoded output. /// - first index: ? [0..63] (hard coded) uint8_t *decoded_output; From 51ffa4f62be75fe81883d30d8cf65043e7846fb6 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 26 Jun 2018 09:10:15 +0200 Subject: [PATCH 07/10] ue removing logs --- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 52 +---------------- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 58 +++++-------------- 2 files changed, 18 insertions(+), 92 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 793ded988f..b0b56608c2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -107,11 +107,8 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) ue->high_speed_flag, frame_mod4); - if ((pbch_tx_ant>0) && (pbch_tx_ant<=2)) { pbch_decoded = 1; // break; - } - //} @@ -129,43 +126,6 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) // ue->pbch_vars[0]->decoded_output[0] = ue->pbch_vars[0]->decoded_output[2]; // ue->pbch_vars[0]->decoded_output[2] = dummy; - // now check for Bandwidth of Cell - dummy = (ue->pbch_vars[0]->decoded_output[2]>>5)&7; - - switch (dummy) { - - case 0 : - frame_parms->N_RB_DL = 6; - break; - - case 1 : - frame_parms->N_RB_DL = 15; - break; - - case 2 : - frame_parms->N_RB_DL = 25; - break; - - case 3 : - frame_parms->N_RB_DL = 50; - break; - - case 4 : - frame_parms->N_RB_DL = 75; - break; - - case 5: - frame_parms->N_RB_DL = 100; - break; - - default: - LOG_E(PHY,"[UE%d] Initial sync: PBCH decoding: Unknown N_RB_DL\n",ue->Mod_id); - return -1; - break; - } - - - for(int i=0; iproc.proc_rxtx[i].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; @@ -178,14 +138,11 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) ue->proc.proc_rxtx[i].frame_tx = ue->proc.proc_rxtx[0].frame_rx; } #ifdef DEBUG_INITIAL_SYNCH - LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully mode1_flag %d, tx_ant %d, frame %d, N_RB_DL %d, phich_duration %d, phich_resource %s!\n", + LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully mode1_flag %d, tx_ant %d, frame %d\n", ue->Mod_id, frame_parms->mode1_flag, pbch_tx_ant, - ue->proc.proc_rxtx[0].frame_rx, - frame_parms->N_RB_DL, - frame_parms->phich_config_common.phich_duration, - phich_resource); //frame_parms->phich_config_common.phich_resource); + ue->proc.proc_rxtx[0].frame_rx,); #endif return(0); } else { @@ -194,7 +151,6 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) } -char phich_string[13][4] = {"","1/6","","1/2","","","one","","","","","","two"}; char duplex_string[2][4] = {"FDD","TDD"}; char prefix_string[2][9] = {"NORMAL","EXTENDED"}; @@ -325,10 +281,6 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) } #endif - generate_pcfich_reg_mapping(frame_parms); - generate_phich_reg_mapping(frame_parms); - - ue->pbch_vars[0]->pdu_errors_conseq=0; } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 6c942795e3..96b1425cd3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -394,21 +394,20 @@ void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, uint8_t reset; uint32_t x1, x2, s=0; - printf("unscramb nid_cell %d\n",frame_parms->Nid_cell); + //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 - // msg("pbch_unscrambling: Nid_cell = %d\n",x2); for (i=0; i>(i%32))&1) ); + //printf("s = %d\n",((s>>(i%32))&1) ); if (((s>>(i%32))&1)==1) pbch_a[i] = 1-pbch_a[i]; } @@ -503,15 +502,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, int8_t decoderState=0; uint8_t decoderListSize = 8, pathMetricAppr = 0; double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. - double *channelOutput = malloc (sizeof(double) * 864); //add noise - uint8_t *estimatedOutput = malloc(sizeof(uint8_t) * 32); //decoder output - memset(&channelOutput[0], 0, sizeof(double) * 864); - memset(&estimatedOutput[0], 0, sizeof(uint8_t) * 32); - memset(&pbch_a[0], 0, sizeof(uint8_t) * 32); - frame_parms->Nid_cell = 100; + memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); - printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); + //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; @@ -597,57 +591,37 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, printf("pbch rx llr %d rxdata_comp %d addr %p\n",*(pbch_e_rx+cnt), p[cnt], &p[0]); //#endif - for (int i=0; ipbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); - for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) - printf("pbch_a[%d] = %u \n", i,pbch_a[i]); + //for (i=0; i>3)*/; i++) - printf("after unscrambling pbch_a[%d] = %d \n", i,pbch_a[i]); - // Fix byte endian - //for (i=0; i<32 /*(NR_POLAR_PBCH_PAYLOAD_BITS>>3)*/; i++) - // printf("estimated output[%d] = %d \n", i,estimatedOutput[i]); - //decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; - - //#ifdef DEBUG_PBCH - - // for (i=0; i<2; i++) - // printf("[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); - - //#endif + for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS); i++) + decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS)-i-1] = pbch_a[i]; #ifdef DEBUG_PBCH - msg("PBCH CRC %x : %x\n", - crc16(pbch_a,PBCH_A), - ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); + 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>16) ^ - (((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); - - if (crc == 0x0000) - return(1); - else if (crc == 0xffff) - return(2); - else if (crc == 0x5555) - return(4); - else - return(-1); - } From 59e6d72e3d40654193d0ca8ca02d547562505492 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Tue, 26 Jun 2018 15:52:53 +0200 Subject: [PATCH 08/10] ue pbch update --- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 4 ++-- .../NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 15 ++++++--------- openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 8 ++++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index 1af712a26f..f9b4afeb34 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -151,8 +151,8 @@ int nr_pbch_dmrs_rx(unsigned int *nr_gold_pbch, ((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<6) - printf("m %d output %d %d addr %p\n", m, output[2*m], output[2*m+1],&output[0]); + if (m<16) + 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_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index ebd68bc11a..cbb58527da 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -46,15 +46,15 @@ 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 nushift, Lmax, ssb_index=1, n_hf=0; uint8_t previous_thread_id = ue->current_thread_id[Ns>>1]==0 ? (RX_NB_TH-1):(ue->current_thread_id[Ns>>1]-1); 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; - - // recompute nushift with eNB_offset corresponding to adjacent eNB on which to perform channel estimation - nushift = Nid_cell%4; - + Lmax = 8; //to be updated + nushift = (Lmax < 8)? ssb_index&3 : ssb_index&7; + ue->frame_parms.nushift = nushift; + if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage ch_offset = ue->frame_parms.ofdm_symbol_size ; else @@ -124,11 +124,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, break; } - - // generate pilot - nr_pbch_dmrs_rx(ue->nr_gold_pbch, - &pilot[p][0]); + nr_pbch_dmrs_rx(ue->nr_gold_pbch[n_hf][ssb_index], &pilot[p][0]); for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index b0b56608c2..a4b8679f37 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -107,7 +107,7 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) ue->high_speed_flag, frame_mod4); - pbch_decoded = 1; + pbch_decoded = 0; //to be updated // break; //} diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 96b1425cd3..11f1095df3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -617,11 +617,11 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS); i++) decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS)-i-1] = pbch_a[i]; -#ifdef DEBUG_PBCH + //#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 Date: Tue, 26 Jun 2018 16:00:29 +0200 Subject: [PATCH 09/10] ue removing some warnings --- .../nr_dl_channel_estimation.c | 31 ++----------------- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 6 ++-- 2 files changed, 6 insertions(+), 31 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 cbb58527da..2ea277e759 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -41,14 +41,13 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char aarx; unsigned short k; unsigned int pilot_cnt; - int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*f2l,*fr,f1,*f2r,*fl_dc,*fm_dc,*fr_dc; + int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; int ch_offset,symbol_offset; - uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; + //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=1, n_hf=0; - uint8_t previous_thread_id = ue->current_thread_id[Ns>>1]==0 ? (RX_NB_TH-1):(ue->current_thread_id[Ns>>1]-1); - 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 **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 @@ -74,48 +73,24 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, fl = filt16a_l0; fm = filt16a_m0; fr = filt16a_r0; - fl_dc = filt16a_l0; - fm_dc = filt16a_m0; - fr_dc = filt16a_r0; - f1 = filt16a_1; - f2l = filt16a_2l0; - f2r = filt16a_2r0; break; case 1: fl = filt16a_l1; fm = filt16a_m1; fr = filt16a_r1; - fl_dc = filt16a_l1; - fm_dc = filt16a_m1; - fr_dc = filt16a_r1; - f1 = filt16a_1; - f2l = filt16a_2l1; - f2r = filt16a_2r1; break; case 2: fl = filt16a_l2; fm = filt16a_m2; fr = filt16a_r2; - fl_dc = filt16a_l2; - fm_dc = filt16a_m2; - fr_dc = filt16a_r2; - f1 = filt16a_1; - f2l = filt16a_2l0; - f2r = filt16a_2r0; break; case 3: fl = filt16a_l3; fm = filt16a_m3; fr = filt16a_r3; - fl_dc = filt16a_l3; - fm_dc = filt16a_m3; - fr_dc = filt16a_r3; - f1 = filt16a_1; - f2l = filt16a_2l1; - f2r = filt16a_2r1; break; default: diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 11f1095df3..3a556070e5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -494,7 +494,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, int8_t *pbch_e_rx; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; - uint16_t crc; + //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 *demod_pbch_e = malloc (sizeof(double) * 864); @@ -583,13 +583,13 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, pbch_e_rx = nr_ue_pbch_vars->llr; - //#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; i Date: Tue, 26 Jun 2018 16:35:52 +0200 Subject: [PATCH 10/10] ue setting ssb index --- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 2 +- 2 files changed, 2 insertions(+), 2 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 2ea277e759..ad3f74452c 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -46,7 +46,7 @@ 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=1, n_hf=0; + uint8_t nushift, Lmax, 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; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 3a556070e5..3c062dbfa7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -608,7 +608,7 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); //for (i=0; i