From a79992bc7563446e266d4b5c8f77dc54a90a62a7 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Mon, 2 Jul 2018 16:35:39 +0200 Subject: [PATCH 1/4] ue adding nr pdcch channel est --- openair1/PHY/MODULATION/modulation_UE.h | 5 +- openair1/PHY/MODULATION/slot_fep.c | 42 ++++- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 70 ++++++-- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 44 +++++ openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 16 +- .../nr_dl_channel_estimation.c | 166 ++++++++++++++++++ openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 11 +- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 15 +- openair1/PHY/NR_UE_TRANSPORT/sss_nr.c | 10 +- openair1/PHY/defs_nr_UE.h | 9 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 5 +- targets/RT/USER/nr-ue.c | 2 +- 12 files changed, 355 insertions(+), 40 deletions(-) diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h index 92afcea724..9734c02907 100644 --- a/openair1/PHY/MODULATION/modulation_UE.h +++ b/openair1/PHY/MODULATION/modulation_UE.h @@ -48,12 +48,13 @@ int slot_fep(PHY_VARS_UE *phy_vars_ue, int no_prefix, int reset_freq_est); -int slot_fep_pbch(PHY_VARS_NR_UE *phy_vars_ue, +int nr_slot_fep(PHY_VARS_NR_UE *phy_vars_ue, unsigned char l, unsigned char Ns, int sample_offset, int no_prefix, - int reset_freq_est); + int reset_freq_est, + NR_CHANNEL_EST_t channel); int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, unsigned char l, diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index 28fc0e02ff..f46ad35bd7 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -28,12 +28,13 @@ #define SOFFSET 0 -int slot_fep_pbch(PHY_VARS_NR_UE *ue, +int nr_slot_fep(PHY_VARS_NR_UE *ue, unsigned char l, unsigned char Ns, int sample_offset, int no_prefix, - int reset_freq_est) + int reset_freq_est, + NR_CHANNEL_EST_t channel) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_UE_COMMON *common_vars = &ue->common_vars; @@ -181,6 +182,9 @@ int slot_fep_pbch(PHY_VARS_NR_UE *ue, } if (ue->perfect_ce == 0) { + + switch(channel){ + case NR_PBCH_EST: if ((l>0) && (l<4)) { for (aa=0; aanb_antenna_ports_eNB; aa++) { @@ -196,7 +200,9 @@ int slot_fep_pbch(PHY_VARS_NR_UE *ue, l, symbol); } - +#if UE_TIMING_TRACE + stop_meas(&ue->dlsch_channel_estimation_stats); +#endif // do frequency offset estimation here! // use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1}) @@ -221,6 +227,36 @@ int slot_fep_pbch(PHY_VARS_NR_UE *ue, } } + break; + + case NR_PDCCH_EST: + for (aa=0; aanb_antenna_ports_eNB; aa++) { + +#ifdef DEBUG_FEP + printf("Channel estimation eNB %d, aatx %d, slot %d, symbol %d\n",eNB_id,aa,Ns,l); +#endif +#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); +#endif + nr_pdcch_channel_estimation(ue,eNB_id,0, + Ns, + aa, + l, + symbol); +#if UE_TIMING_TRACE + stop_meas(&ue->dlsch_channel_estimation_stats); +#endif + } + break; + + case NR_SSS_EST: + break; + + default: + LOG_E(PHY,"[UE][FATAL] Unknown channel format %d\n",channel); + return(-1); + break; + } } diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index f9b4afeb34..72d5f56029 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -49,20 +49,70 @@ 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}; -//extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; +short nr_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,23170,-23170,-23170,-23170,23170}; + +int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, + unsigned int Ns, + unsigned int nr_gold_pdcch[2][20][3][10], + int32_t *output, + unsigned short p, + int length_dmrs, + unsigned short nb_rb_coreset) +{ + int32_t qpsk[4],n; + int w,ind,l,ind_dword,ind_qpsk_symb,kp,k; + short pamp; + + // Compute the correct pilot amplitude, sqrt_rho_b = Q3.13 + pamp = ONE_OVER_SQRT2_Q15; + + // This includes complex conjugate for channel estimation + ((short *)&qpsk[0])[0] = pamp; + ((short *)&qpsk[0])[1] = -pamp; + ((short *)&qpsk[1])[0] = -pamp; + ((short *)&qpsk[1])[1] = -pamp; + ((short *)&qpsk[2])[0] = pamp; + ((short *)&qpsk[2])[1] = pamp; + ((short *)&qpsk[3])[0] = -pamp; + ((short *)&qpsk[3])[1] = pamp; + + if (p==2000) { + // r_n from 38.211 7.4.1.3 + for (n=0; n>4; + ind_qpsk_symb = ind&0xf; + + output[k] = qpsk[(ue->nr_gold_pdcch[0][Ns][l][ind_dword]>>(2*ind_qpsk_symb))&3]; + +#ifdef DEBUG_DL_DMRS + LOG_I(PHY,"Ns %d, p %d, ind_dword %d, ind_qpsk_symbol %d\n", + Ns,p,idx_dword,idx_qpsk_symb); + LOG_I(PHY,"index = %d\n",(nr_gold_pdsch[0][Ns][lprime][ind_dword]>>(2*ind_qpsk_symb))&3); +#endif + + k++; + } + } + } + } else { + LOG_E(PHY,"Illegal PDCCH DMRS port %d\n",p); + } + + return(0); +} int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, - unsigned int ncp, unsigned int Ns, unsigned int nr_gold_pdsch[2][20][2][21], int32_t *output, unsigned short p, int length_dmrs, - unsigned short nb_pdsch_rb) + unsigned short nb_rb_pdsch) { int32_t qpsk[4],nqpsk[4],*qpsk_p, n; int w,mprime,ind,l,ind_dword,ind_qpsk_symb,kp,lp, config_type, k; @@ -76,7 +126,7 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, printf("dmrs config type %d port %d\n", config_type, p); // Compute the correct pilot amplitude, sqrt_rho_b = Q3.13 - pamp = 23170; //ONE_OVER_SQRT2_Q15; + pamp = ONE_OVER_SQRT2_Q15; // This includes complex conjugate for channel estimation ((short *)&qpsk[0])[0] = pamp; @@ -104,10 +154,9 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, LOG_E(PHY,"Bad PDSCH DMRS config type %d\n", config_type); if ((p>=1000) && (p<((config_type==0) ? 1008 : 1012))) { - if (/*ue->frame_parms.Ncp == NORMAL*/ncp ==0) { // r_n from 38.211 7.4.1.1 - for (n=0; n>1) ^ (x2>>2) ^ (x2>>3))<<31); + + // skip first 50 double words (1600 bits) + for (n=1; n<50; n++) { + x1 = (x1>>1) ^ (x1>>4); + x1 = x1 ^ (x1<<31) ^ (x1<<28); + x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); + x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); + //printf("x1 : %x, x2 : %x\n",x1,x2); + } + + for (n=0; n<10; n++) { + x1 = (x1>>1) ^ (x1>>4); + x1 = x1 ^ (x1<<31) ^ (x1<<28); + x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); + x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); + nr_gold_pdcch[ns][l][n] = x1^x2; + //printf("n=%d : c %x\n",n,x1^x2); + } + } + } +} + void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int nr_gold_pdsch[2][20][2][21],unsigned int Nid_cell, unsigned short *n_idDMRS, unsigned short length_dmrs) { diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h index 2d4db86ef9..c2f286aacd 100644 --- a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h +++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h @@ -31,14 +31,24 @@ */ int nr_pbch_dmrs_rx(unsigned int *nr_gold_pbch, int32_t *output ); -/*int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, - unsigned int ncp, +/*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PDCCH DMRS. +@param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables + */ +int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, + unsigned int Ns, + unsigned int nr_gold_pdcch[2][20][3][10], + int32_t *output, + unsigned short p, + int length_dmrs, + unsigned short nb_rb_corset); + +int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, unsigned int Ns, unsigned int nr_gold_pdsch[2][20][2][21], int32_t *output, unsigned short p, int length_dmrs, - unsigned short nb_pdsch_rb);*/ + unsigned short nb_rb_pdsch); void nr_gold_pbch(PHY_VARS_NR_UE* ue); 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..fae1a42d8b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -222,3 +222,169 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, return(0); } +int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, + uint8_t eNB_id, + uint8_t eNB_offset, + unsigned char Ns, + unsigned char p, + unsigned char l, + unsigned char symbol, + unsigned short nb_rb_coreset) +{ + int pilot[2][200] __attribute__((aligned(16))); + unsigned char aarx; + unsigned short k; + unsigned int pilot_cnt; + 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]; + + uint8_t nushift; + int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_offset]; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; + + nushift = 1; + 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 + ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; + + symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; + + k = nushift; + +#ifdef DEBUG_CH + printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d cell_id %d ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns>>1], eNB_offset,Nid_cell,ch_offset,ue->frame_parms.ofdm_symbol_size, + ue->frame_parms.Ncp,l,Ns,k, symbol); +#endif + + fl = filt16a_l1; + fm = filt16a_m1; + fr = filt16a_r1; + + // generate pilot + nr_pdcch_dmrs_rx(ue->nr_gold_pdcch[0][Ns][symbol], &pilot[p][0]); + + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + + pil = (int16_t *)&pilot[p][0]; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+(ue->frame_parms.ofdm_symbol_size-12*(nb_rb_coreset>>1)))]; + dl_ch = (int16_t *)&dl_ch_estimates[(p<<1)+aarx][ch_offset]; + + memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); + if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha + multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), + ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), + 1,ue->frame_parms.ofdm_symbol_size); +#ifdef DEBUG_CH + printf("ch est pilot addr %p RB_DL %d\n",&pilot[p][0], ue->frame_parms.N_RB_DL); + printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); + printf("rxF addr %p\n", rxF); + printf("dl_ch addr %p\n",dl_ch); +#endif + if ((ue->frame_parms.N_RB_DL&1)==0) { + + // Treat first 2 pilots specially (left edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fl, + ch, + dl_ch, + 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)); + + 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 + multadd_real_vector_complex_scalar(fm, + ch, + dl_ch, + 16); + 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 + + multadd_real_vector_complex_scalar(fr, + ch, + dl_ch, + 16); + pil+=2; + rxF+=8; + dl_ch+=24; + + for (pilot_cnt=3; pilot_cnt<(3*24); pilot_cnt+=3) { + + if (pilot_cnt == 36) + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)]; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fl, + ch, + dl_ch, + 16); + + //for (int i= 0; i<8; i++) + // printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, 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 %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, + dl_ch, + 16); + 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 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, + dl_ch, + 16); + pil+=2; + rxF+=8; + dl_ch+=24; + + } + + + } + + } + + return(0); +} + diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index fd079b9f7b..787032095c 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -1141,16 +1141,15 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { if (high_speed_flag == 1){ - dl_ch0 = &dl_ch_estimates[aarx][5 + (symbol * (frame_parms->ofdm_symbol_size))]; + dl_ch0 = &dl_ch_estimates[aarx][(symbol * (frame_parms->ofdm_symbol_size))]; #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0 = &dl_ch_estimates[aarx = (%d)][5 + (symbol * (frame_parms->ofdm_symbol_size (%d))) = (%d)]\n", - aarx,frame_parms->ofdm_symbol_size,5 + (symbol * (frame_parms->ofdm_symbol_size))); - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> why pointer is pointing to that position (what does '5' mean)?\n"); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0 = &dl_ch_estimates[aarx = (%d)][ (symbol * (frame_parms->ofdm_symbol_size (%d))) = (%d)]\n", + aarx,frame_parms->ofdm_symbol_size,(symbol * (frame_parms->ofdm_symbol_size))); #endif } else { - dl_ch0 = &dl_ch_estimates[aarx][5]; + dl_ch0 = &dl_ch_estimates[aarx][0]; #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0 = &dl_ch_estimates[aarx = (%d)][5]\n",aarx); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0 = &dl_ch_estimates[aarx = (%d)][0]\n",aarx); #endif } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index a4b8679f37..047357a7f8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -68,28 +68,31 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) frame_parms->nb_prefix_samples0 = 0; //symbol 1 - slot_fep_pbch(ue, + nr_slot_fep(ue, 1, 0, ue->rx_offset, 0, - 1); + 1, + NR_PBCH_EST); //symbol 2 - slot_fep_pbch(ue, + nr_slot_fep(ue, 2, 0, ue->rx_offset, 0, - 1); + 1, + NR_PBCH_EST); //symbol 3 - slot_fep_pbch(ue, + nr_slot_fep(ue, 3, 0, ue->rx_offset, 0, - 1); + 1, + NR_PBCH_EST); frame_parms->nb_prefix_samples0 = nb_prefix_samples0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c index 41b9383a91..73f42ee442 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c @@ -466,20 +466,22 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric,uint8_t *phase_max) // Do FFTs for SSS/PSS // SSS - slot_fep_pbch(ue, + nr_slot_fep(ue, SSS_SYMBOL_NB, // symbol number 0, // Ns slot number ue->rx_offset, // sample_offset of int16_t 0, // no_prefix - 1); // reset frequency estimation + 1, // reset frequency estimation + NR_SSS_EST); // PSS - slot_fep_pbch(ue, + nr_slot_fep(ue, PSS_SYMBOL_NB, 0, ue->rx_offset, 0, - 1); + 1, + NR_SSS_EST); frame_parms->nb_prefix_samples0 = nb_prefix_samples0; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 4a25e62c77..f3c3e58f1b 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -282,6 +282,13 @@ typedef struct { UE_nr_rxtx_proc_t proc_rxtx[RX_NB_TH]; } UE_nr_proc_t; +typedef enum { + NR_PBCH_EST=0, + NR_PDCCH_EST, + NR_PDSCH_EST, + NR_SSS_EST, +} NR_CHANNEL_EST_t; + #define debug_msg if (((mac_xface->frame%100) == 0) || (mac_xface->frame < 50)) msg typedef struct { @@ -988,7 +995,7 @@ typedef struct { uint32_t nr_gold_pdsch[2][20][2][21]; /// PDCCH DMRS - uint32_t nr_gold_pdcch[10][3][42]; + uint32_t nr_gold_pdcch[2][20][3][10]; uint32_t X_u[64][839]; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 58aef56602..4d007c766c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -5951,12 +5951,13 @@ int phy_procedures_UE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ start_meas(&ue->ofdm_demod_stats); #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - slot_fep_pbch(ue, + nr_slot_fep(ue, l, (nr_tti_rx<<1), 0, 0, - 0); + 0, + NR_PDCCH_EST); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE stop_meas(&ue->ofdm_demod_stats); diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 49a2307c9e..9afcb6e879 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -819,7 +819,7 @@ void *UE_thread(void *arg) { (void**)UE->common_vars.rxdata, UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, UE->frame_parms.nb_antennas_rx),""); - slot_fep_pbch(UE,0, 0, 0, 0, 0); + nr_slot_fep(UE,0, 0, 0, 0, 0, NR_PBCH_EST); } //UE->mode != loop_through_memory else rt_sleep_ns(1000*1000); From 8ee10be2532b2adf584bb792c4d35078f3f8a643 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Mon, 9 Jul 2018 17:08:08 +0200 Subject: [PATCH 2/4] ue nr pdcch channel est update --- openair1/PHY/MODULATION/slot_fep.c | 8 +++++++- .../nr_dl_channel_estimation.c | 18 +++++++++++------- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 12 +++++++----- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index f46ad35bd7..84a1c85c56 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -23,6 +23,7 @@ #include "PHY/defs_nr_UE.h" #include "modulation_UE.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/NR_UE_ESTIMATION/nr_estimation.h" //#define DEBUG_FEP @@ -48,6 +49,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, int i; unsigned int frame_length_samples = frame_parms->samples_per_subframe * 10; unsigned int rx_offset; + //NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[Ns>>1]][0]; + uint16_t coreset_start_subcarrier = frame_parms->first_carrier_offset; + uint16_t nb_rb_coreset = 24; /*LTE_UE_DLSCH_t **dlsch_ue = phy_vars_ue->dlsch_ue[eNB_id]; unsigned char harq_pid = dlsch_ue[0]->current_harq_pid; @@ -242,7 +246,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, Ns, aa, l, - symbol); + symbol, + coreset_start_subcarrier, + nb_rb_coreset); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_channel_estimation_stats); #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 fae1a42d8b..11a50ca20f 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -229,6 +229,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char p, unsigned char l, unsigned char symbol, + unsigned short coreset_start_subcarrier, unsigned short nb_rb_coreset) { int pilot[2][200] __attribute__((aligned(16))); @@ -241,8 +242,8 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; uint8_t nushift; - int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].dl_ch_estimates[eNB_offset]; - int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; + int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset]; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; nushift = 1; ue->frame_parms.nushift = nushift; @@ -254,7 +255,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; - k = nushift; + k = coreset_start_subcarrier; #ifdef DEBUG_CH printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d cell_id %d ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns>>1], eNB_offset,Nid_cell,ch_offset,ue->frame_parms.ofdm_symbol_size, @@ -271,7 +272,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { pil = (int16_t *)&pilot[p][0]; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+(ue->frame_parms.ofdm_symbol_size-12*(nb_rb_coreset>>1)))]; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; dl_ch = (int16_t *)&dl_ch_estimates[(p<<1)+aarx][ch_offset]; memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); @@ -329,11 +330,13 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, pil+=2; rxF+=8; dl_ch+=24; + k+=12; - for (pilot_cnt=3; pilot_cnt<(3*24); pilot_cnt+=3) { + for (pilot_cnt=3; pilot_cnt<(3*nb_rb_coreset); pilot_cnt+=3) { - if (pilot_cnt == 36) - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)]; + if (k >= ue->frame_parms.ofdm_symbol_size){ + k-=ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];} 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); @@ -377,6 +380,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, pil+=2; rxF+=8; dl_ch+=24; + k+=12; } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 7ec222727b..fdc184918d 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -19,12 +19,12 @@ * contact@openairinterface.org */ -#ifndef __LTE_ESTIMATION_DEFS__H__ -#define __LTE_ESTIMATION_DEFS__H__ +#ifndef __NR_ESTIMATION_DEFS__H__ +#define __NR_ESTIMATION_DEFS__H__ #include "PHY/defs_nr_UE.h" -#include "PHY/defs_gNB.h" +//#include "PHY/defs_gNB.h" /** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_ * @{ */ @@ -42,13 +42,15 @@ \param l symbol within slot \param symbol symbol within frame */ -int nr_dl_channel_estimation(PHY_VARS_NR_UE *ue, +int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t eNB_offset, unsigned char Ns, unsigned char p, unsigned char l, - unsigned char symbol); + unsigned char symbol, + unsigned short coreset_start_subcarrier, + unsigned short nb_rb_coreset); int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t eNB_id, From 31d5682d6b61b89a7e3f29ba52a0eb59a199b823 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 10 Jul 2018 16:34:36 +0200 Subject: [PATCH 3/4] ue adding nr pdsch channel est --- openair1/PHY/MODULATION/slot_fep.c | 24 +++ openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 10 +- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 10 +- openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 12 +- openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h | 25 +++ .../nr_dl_channel_estimation.c | 193 +++++++++++++++++- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 10 + openair1/PHY/defs_nr_UE.h | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 13 +- 9 files changed, 284 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index 84a1c85c56..b655426d0b 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -52,6 +52,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, //NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[Ns>>1]][0]; uint16_t coreset_start_subcarrier = frame_parms->first_carrier_offset; uint16_t nb_rb_coreset = 24; + uint16_t bwp_start_subcarrier = frame_parms->first_carrier_offset; + uint16_t nb_rb_pdsch = 100; /*LTE_UE_DLSCH_t **dlsch_ue = phy_vars_ue->dlsch_ue[eNB_id]; unsigned char harq_pid = dlsch_ue[0]->current_harq_pid; @@ -255,6 +257,28 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, } break; + case NR_PDSCH_EST: + for (aa=0; aanb_antenna_ports_eNB; aa++) { + +#ifdef DEBUG_FEP + printf("Channel estimation eNB %d, aatx %d, slot %d, symbol %d\n",eNB_id,aa,Ns,l); +#endif +#if UE_TIMING_TRACE + start_meas(&ue->dlsch_channel_estimation_stats); +#endif + nr_pdsch_channel_estimation(ue,eNB_id,0, + Ns, + aa, + l, + symbol, + bwp_start_subcarrier, + nb_rb_pdsch); +#if UE_TIMING_TRACE + stop_meas(&ue->dlsch_channel_estimation_stats); +#endif + } + break; + case NR_SSS_EST: break; diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index 72d5f56029..4ea226ebbe 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -53,8 +53,9 @@ int wt2[12][2] = {{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}; int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdcch[2][20][3][10], + unsigned int nr_gold_pdcch[7][20][3][10], int32_t *output, unsigned short p, int length_dmrs, @@ -87,7 +88,7 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, ind_dword = ind>>4; ind_qpsk_symb = ind&0xf; - output[k] = qpsk[(ue->nr_gold_pdcch[0][Ns][l][ind_dword]>>(2*ind_qpsk_symb))&3]; + output[k] = qpsk[(nr_gold_pdcch[eNB_offset][Ns][l][ind_dword]>>(2*ind_qpsk_symb))&3]; #ifdef DEBUG_DL_DMRS LOG_I(PHY,"Ns %d, p %d, ind_dword %d, ind_qpsk_symbol %d\n", @@ -107,8 +108,9 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, } int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdsch[2][20][2][21], + unsigned int nr_gold_pdsch[7][20][2][21], int32_t *output, unsigned short p, int length_dmrs, @@ -166,7 +168,7 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, ind_dword = ind>>4; ind_qpsk_symb = ind&0xf; - output[k] = qpsk_p[(ue->nr_gold_pdsch[0][Ns][lp][ind_dword]>>(2*ind_qpsk_symb))&3]; + output[k] = qpsk_p[(nr_gold_pdsch[0][Ns][lp][ind_dword]>>(2*ind_qpsk_symb))&3]; #ifdef DEBUG_DL_DMRS diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 1ffa51a029..ce8e0de522 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -64,7 +64,7 @@ void nr_gold_pbch(PHY_VARS_NR_UE* ue) } -void nr_gold_pdcch(PHY_VARS_NR_UE* ue,unsigned int nr_gold_pdcch[20][2][10],unsigned int Nid_cell, unsigned short n_idDMRS, unsigned short length_dmrs) +void nr_gold_pdcch(PHY_VARS_NR_UE* ue,unsigned int Nid_cell, unsigned short n_idDMRS, unsigned short length_dmrs) { unsigned char ns,l; @@ -101,14 +101,14 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue,unsigned int nr_gold_pdcch[20][2][10],unsi x1 = x1 ^ (x1<<31) ^ (x1<<28); x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); - nr_gold_pdcch[ns][l][n] = x1^x2; + ue->nr_gold_pdcch[0][ns][l][n] = x1^x2; //printf("n=%d : c %x\n",n,x1^x2); } } } } -void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int nr_gold_pdsch[2][20][2][21],unsigned int Nid_cell, unsigned short *n_idDMRS, unsigned short length_dmrs) +void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int Nid_cell, unsigned short *n_idDMRS, unsigned short length_dmrs) { unsigned char ns,l; @@ -130,7 +130,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int nr_gold_p for (l=0; l>1) ^ (x2>>2) ^ (x2>>3))<<31); @@ -149,7 +149,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int nr_gold_p x1 = x1 ^ (x1<<31) ^ (x1<<28); x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); - nr_gold_pdsch[nscid][ns][l][n] = x1^x2; + ue->nr_gold_pdsch[nscid][ns][l][n] = x1^x2; //printf("n=%d : c %x\n",n,x1^x2); } diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h index c2f286aacd..d0d6338d44 100644 --- a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h +++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h @@ -35,16 +35,18 @@ int nr_pbch_dmrs_rx(unsigned int *nr_gold_pbch, int32_t *output ); @param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables */ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdcch[2][20][3][10], + unsigned int nr_gold_pdcch[7][20][3][10], int32_t *output, unsigned short p, int length_dmrs, unsigned short nb_rb_corset); int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, + uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdsch[2][20][2][21], + unsigned int nr_gold_pdsch[7][20][2][21], int32_t *output, unsigned short p, int length_dmrs, @@ -52,9 +54,13 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, void nr_gold_pbch(PHY_VARS_NR_UE* ue); +void nr_gold_pdcch(PHY_VARS_NR_UE* ue, + unsigned int Nid_cell, + unsigned short n_idDMRS, + unsigned short length_dmrs); + void nr_gold_pdsch(PHY_VARS_NR_UE* ue, unsigned short lbar, - unsigned int nr_gold_pdsch[2][20][2][21], unsigned int Nid_cell, unsigned short *n_idDMRS, unsigned short length_dmrs); diff --git a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h index a37a591d2f..52356a9438 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h +++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h @@ -84,3 +84,28 @@ short filt16a_2l1[16] = { short filt16a_2r1[16] = { -4096,0,4096,8192,12288,16384,0,0,0,0,0,0,0,0,0,0}; + +/*filter8*/ +short filt8_l0[8] = { +16384,8192,0,0,0,0,0,0}; + +short filt8_mr0[8] = { +0,8192,16384,8192,0,-8192,0,0}; + +short filt8_r0[8] = { +0,8192,16384,24576,0,0,0,0}; + +short filt8_m0[8] = { +0,8192,16384,8192,0,0,0,0}; + +short filt8_l1[8] = { +24576,16384,0,0,0,0,0,0}; + +short filt8_ml1[8] = { +-8192,0,8192,16384,8192,0,0,0}; + +short filt8_r1[8] = { +0,0,8192,16384,0,0,0,0}; + +short filt8_m1[8] = { +0,0,8192,16384,8192,0,0,0}; 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 11a50ca20f..18da8473d3 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -267,7 +267,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, fr = filt16a_r1; // generate pilot - nr_pdcch_dmrs_rx(ue->nr_gold_pdcch[0][Ns][symbol], &pilot[p][0]); + nr_pdcch_dmrs_rx(ue,eNB_offset,Ns,ue->nr_gold_pdcch[eNB_offset][Ns][symbol], &pilot[p][0],2000,symbol, nb_rb_coreset); for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { @@ -392,3 +392,194 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, return(0); } +int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, + uint8_t eNB_id, + uint8_t eNB_offset, + unsigned char Ns, + unsigned char p, + unsigned char l, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pdsch) +{ + int pilot[2][200] __attribute__((aligned(16))); + unsigned char aarx; + unsigned short k; + unsigned int pilot_cnt; + int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr,*fml,*fmr; + 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]; + + uint8_t nushift; + int **dl_ch_estimates =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset]; + int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF; + + nushift = (p>>1)&1; + 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 + ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; + + symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; + + k = bwp_start_subcarrier; + +#ifdef DEBUG_CH + printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d cell_id %d ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns>>1], eNB_offset,Nid_cell,ch_offset,ue->frame_parms.ofdm_symbol_size, + ue->frame_parms.Ncp,l,Ns,k, symbol); +#endif + + switch (nushift) { + case 0: + fl = filt8_l0; + fm = filt8_m0; + fr = filt8_r0; + fml = filt8_m0; + fmr = filt8_mr0; + break; + + case 1: + fl = filt8_l1; + fm = filt8_m1; + fr = filt8_r1; + fml = filt8_ml1; + fmr = filt8_m1; + break; + + default: + msg("pdsch_channel_estimation: nushift=%d -> ERROR\n",nushift); + return(-1); + break; + } + + + // generate pilot + nr_pdsch_dmrs_rx(ue,eNB_offset,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][symbol], &pilot[p][0],1000,1,nb_rb_pdsch); + + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + + pil = (int16_t *)&pilot[p][0]; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; + dl_ch = (int16_t *)&dl_ch_estimates[(p<<1)+aarx][ch_offset]; + + memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); + if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha + multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), + ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), + 1,ue->frame_parms.ofdm_symbol_size); +#ifdef DEBUG_CH + printf("ch est pilot addr %p RB_DL %d\n",&pilot[p][0], ue->frame_parms.N_RB_DL); + printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); + printf("rxF addr %p\n", rxF); + printf("dl_ch addr %p\n",dl_ch); +#endif + if ((ue->frame_parms.N_RB_DL&1)==0) { + + // Treat first 2 pilots specially (left edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fl, + ch, + dl_ch, + 8); + pil+=2; + rxF+=4; + //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); +#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(fml, + ch, + dl_ch, + 8); + pil+=2; + rxF+=4; + dl_ch+=4; + k+=4; + + for (pilot_cnt=2; pilot_cnt<(6*(nb_rb_pdsch-1)+4); pilot_cnt+=2) { + if ((pilot_cnt%6)==0) + dl_ch+=4; + + if (k >= ue->frame_parms.ofdm_symbol_size){ + k-=ue->frame_parms.ofdm_symbol_size; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];} + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fm, + ch, + dl_ch, + 8); + + pil+=2; + rxF+=4; + dl_ch+=4; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fm, + ch, + dl_ch, + 8); + pil+=2; + rxF+=4; + dl_ch+=4; + k+=4; + + } + + // Treat first 2 pilots specially (right edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmr, + ch, + dl_ch, + 8); + pil+=2; + rxF+=4; + //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); +#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, + dl_ch, + 8); + pil+=2; + rxF+=4; + dl_ch+=4; + k+=4; + + } + + } + + return(0); +} + diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index fdc184918d..fb012b03fa 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -59,4 +59,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char p, unsigned char l, unsigned char symbol); + +int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, + uint8_t eNB_id, + uint8_t eNB_offset, + unsigned char Ns, + unsigned char p, + unsigned char l, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pdsch); #endif diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index f3c3e58f1b..8b75de944d 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -995,7 +995,7 @@ typedef struct { uint32_t nr_gold_pdsch[2][20][2][21]; /// PDCCH DMRS - uint32_t nr_gold_pdcch[2][20][3][10]; + uint32_t nr_gold_pdcch[7][20][3][10]; uint32_t X_u[64][839]; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 4d007c766c..a8f1136dce 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -5944,6 +5944,7 @@ int phy_procedures_UE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ LOG_D(PHY," ------ --> FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); + nr_gold_pdcch(ue,ue->frame_parms.Nid_cell, 0, 3); for (; l<=3; l++) { if (abstraction_flag == 0) { @@ -6014,6 +6015,17 @@ int phy_procedures_UE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ #endif LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); + //to update from pdsch config + nr_gold_pdsch(ue,0,ue->frame_parms.Nid_cell, 0, 1); + + nr_slot_fep(ue, + 2, //to be updated from higher layer + (nr_tti_rx<<1), + 0, + 0, + 0, + NR_PDSCH_EST); + #if UE_TIMING_TRACE start_meas(&ue->generic_stat); #endif @@ -6038,7 +6050,6 @@ int phy_procedures_UE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, - proc, eNB_id, SI_PDSCH, From ecc7f66e4e37308a9ceb921ab91ff1f1fddc447b Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 10 Jul 2018 16:41:43 +0200 Subject: [PATCH 4/4] ue remove warnings dmrs --- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 2 +- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 3 +-- openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index 4ea226ebbe..3d70217913 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -110,7 +110,7 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdsch[7][20][2][21], + unsigned int nr_gold_pdsch[2][20][2][21], int32_t *output, unsigned short p, int length_dmrs, diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index ce8e0de522..d43d7235ed 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -69,7 +69,6 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue,unsigned int Nid_cell, unsigned short n_id unsigned char ns,l; unsigned int n,x1,x2,x2tmp0; - int nscid; unsigned int nid; if (n_idDMRS) @@ -112,7 +111,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int Nid_cell, { unsigned char ns,l; - unsigned int n,x1,x2,x2tmp0,x2tmp1, x2tmp2,x2s; + unsigned int n,x1,x2,x2tmp0; int nscid; unsigned int nid; diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h index d0d6338d44..ba2b7e69d9 100644 --- a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h +++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h @@ -46,7 +46,7 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdsch[7][20][2][21], + unsigned int nr_gold_pdsch[2][20][2][21], int32_t *output, unsigned short p, int length_dmrs,