From 64ae2d5de7bfe721b47b3a8749a228f6ec012220 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Wed, 10 Oct 2018 09:12:06 +0200 Subject: [PATCH] update pdsch dmrs --- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 132 +++++------------------- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 2 +- openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 9 +- 3 files changed, 31 insertions(+), 112 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index 2ee6614c5e..435598c9d2 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -30,7 +30,6 @@ * \warning */ -//#define DEBUG_DL_DMRS //#define NR_PBCH_DMRS_LENGTH_DWORD 5 //#define NR_PBCH_DMRS_LENGTH 144 @@ -50,101 +49,27 @@ int wf2[12][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1},{1,1},{1,-1 int wt2[12][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1}}; -short nr_rx_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,23170,-23170,-23170,-23170,23170}; +short nr_rx_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,23170,-23170,-23170,-23170,23170}; +short nr_rx_nmod_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[7][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; - 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) { - for (n=0; n>4; - ind_qpsk_symb = ind&0xf; - - 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", - 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, - uint8_t eNB_offset, unsigned int Ns, - unsigned int nr_gold_pdsch[2][20][2][21], + unsigned int *nr_gold_pdsch, int32_t *output, - unsigned short p, - int length_dmrs, - unsigned short nb_rb_pdsch) + unsigned char p, + unsigned char lp, + unsigned short nb_pdsch_rb) { - int32_t qpsk[4],nqpsk[4],*qpsk_p, n; - int w,mprime,ind,l,ind_dword,ind_qpsk_symb,kp,lp, config_type, k; - short pamp; + int8_t w,config_type; + short *mod_table; + unsigned char idx=0; typedef int array_of_w[2]; array_of_w *wf; array_of_w *wt; - config_type = 1; - printf("dmrs config type %d port %d\n", config_type, p); - - // 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; - - ((short *)&nqpsk[0])[0] = -pamp; - ((short *)&nqpsk[0])[1] = pamp; - ((short *)&nqpsk[1])[0] = pamp; - ((short *)&nqpsk[1])[1] = pamp; - ((short *)&nqpsk[2])[0] = -pamp; - ((short *)&nqpsk[2])[1] = -pamp; - ((short *)&nqpsk[3])[0] = pamp; - ((short *)&nqpsk[3])[1] = -pamp; + config_type = 0; //to be updated by higher layer wf = (config_type==0) ? wf1 : wf2; wt = (config_type==0) ? wt1 : wt2; @@ -153,31 +78,26 @@ 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) { - // r_n from 38.211 7.4.1.1 - for (n=0; n>4; - ind_qpsk_symb = ind&0xf; + w = (wf[p-1000][i&1])*(wt[p-1000][lp]); + mod_table = (w==1) ? nr_rx_mod_table : nr_rx_nmod_table; - output[k] = qpsk_p[(nr_gold_pdsch[0][Ns][lp][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); + idx = ((((nr_gold_pdsch[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((nr_gold_pdsch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); + ((int16_t*)output)[i<<1] = mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + ((int16_t*)output)[(i<<1)+1] = mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; +#ifdef DEBUG_PDSCH + printf("nr_pdsch_dmrs_rx dmrs config type %d port %d nb_pdsch_rb %d\n", config_type, p, nb_pdsch_rb); + printf("wf[%d] = %d wt[%d]= %d\n", i&1, wf[p-1000][i&1], lp, wt[p-1000][lp]); + printf("i %d idx %d pdsch gold %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, nr_gold_pdsch[(i<<1)>>5], (((nr_gold_pdsch[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((nr_gold_pdsch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[i<<1], ((int16_t*)output)[(i<<1)+1]); #endif - - k++; - } - } - } + } + } else { + LOG_E(PHY,"extended cp not supported for PDSCH DMRS yet\n"); + } } else { LOG_E(PHY,"Illegal p %d PDSCH DMRS port\n",p); } diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 59e14a1e76..c856d43df3 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -143,7 +143,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned short *n_idDM //printf("x1 : %x, x2 : %x\n",x1,x2); } - for (n=0; n<14; n++) { + for (n=0; n<52; n++) { x1 = (x1>>1) ^ (x1>>4); x1 = x1 ^ (x1<<31) ^ (x1<<28); x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h index 0da7bb154f..d54f69b87e 100644 --- a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h +++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h @@ -43,13 +43,12 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, 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, int32_t *output, - unsigned short p, - int length_dmrs, - unsigned short nb_rb_pdsch); + unsigned char p, + unsigned char lp, + unsigned short nb_pdsch_rb); void nr_gold_pbch(PHY_VARS_NR_UE* ue);