diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.c b/openair1/PHY/NR_REFSIG/ptrs_nr.c index 20a449fdbb..a06799b221 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.c +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.c @@ -277,30 +277,30 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, /* loop over all sub carriers to get compensated RE on ptrs symbols*/ for (int re = 0; re < nb_re_pdsch; re++) + { + is_ptrs_re = is_ptrs_subcarrier(re, + rnti, + 0, + dmrsConfigType, + K_ptrs, + nb_rb, + ptrsReOffset, + 0,// start_re is 0 here + ofdm_symbol_size); + if(is_ptrs_re) { - is_ptrs_re = is_ptrs_subcarrier(re, - rnti, - 0, - dmrsConfigType, - K_ptrs, - nb_rb, - ptrsReOffset, - 0,// start_re is 0 here - ofdm_symbol_size); - if(is_ptrs_re) - { - dmrs_comp_p[re_cnt*2] = rxF_comp[re *2]; - dmrs_comp_p[(re_cnt*2)+1] = rxF_comp[(re *2)+1]; - re_cnt++; - } - else - { - /* Skip PTRS symbols and keep data in a continuous vector */ - rxF_comp[cnt *2]= rxF_comp[re *2]; - rxF_comp[(cnt *2)+1]= rxF_comp[(re *2)+1]; - cnt++; - } - }/* RE loop */ + dmrs_comp_p[re_cnt*2] = rxF_comp[re *2]; + dmrs_comp_p[(re_cnt*2)+1] = rxF_comp[(re *2)+1]; + re_cnt++; + } + else + { + /* Skip PTRS symbols and keep data in a continuous vector */ + rxF_comp[cnt *2]= rxF_comp[re *2]; + rxF_comp[(cnt *2)+1]= rxF_comp[(re *2)+1]; + cnt++; + } + }/* RE loop */ /* update the total ptrs RE in a symbol */ *ptrs_sc = re_cnt; @@ -310,10 +310,10 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, /* loop over all ptrs sub carriers in a symbol */ /* sum the error vector */ for(int i = 0;i < sc_per_symbol; i++) - { - real+= ptrs_ch_p[(2*i)]; - imag+= ptrs_ch_p[(2*i)+1]; - } + { + real+= ptrs_ch_p[(2*i)]; + imag+= ptrs_ch_p[(2*i)+1]; + } #ifdef DEBUG_PTRS alpha = atan(imag/real); printf("[PHY][PTRS]: Symbol %d atan(Im,real):= %f \n",symbol, alpha ); @@ -357,100 +357,100 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos, uint16_t startSymbIdx, uint16_t noSymb) { - int32_t slope = 0; - int16_t *slope_p = (int16_t*)&slope; + double slope[2] = {0,0}; + double *slope_p = &slope[0]; uint8_t symbInSlot = startSymbIdx + noSymb; int8_t rightRef = 0; int8_t leftRef = 0; int8_t tmp = 0; for(uint8_t symb = startSymbIdx; symb %4d %4d from Slope (%4d %4d)\n", start+i,error_est[(start+i)*2],error_est[((start +i)*2)+1], - slope_p[0],slope_p[1]); + printf("[PHY][PTRS]: Estimated Symbol %2d -> %4d %4d from Slope (%4f %4f)\n", start+i,error_est[(start+i)*2],error_est[((start +i)*2)+1], + slope_p[0],slope_p[1]); #endif } } diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.h b/openair1/PHY/NR_REFSIG/ptrs_nr.h index 07df35c020..41acde0d06 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.h +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.h @@ -83,7 +83,7 @@ static inline uint8_t is_ptrs_symbol(uint8_t l, uint16_t ptrs_symbols) { return uint8_t get_ptrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t start_symb, uint16_t nb_symb); int8_t get_next_ptrs_symbol_in_slot(uint16_t ptrsSymbPos, uint8_t counter, uint8_t nb_symb); int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, uint8_t counter,uint8_t nb_symb); -void get_slope_from_estimates(uint8_t leftSide, uint8_t rightSide, int16_t *est_p, int16_t *slope_p); + int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos, uint16_t ptrsSymbPos, int16_t *estPerSymb, @@ -105,6 +105,6 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, int16_t *error_est, int32_t *ptrs_sc); -void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, int16_t *slope_p); -void ptrs_estimate_from_slope(int16_t *error_est, int16_t *slope_p, uint8_t start, uint8_t end); +void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, double *slope_p); +void ptrs_estimate_from_slope(int16_t *error_est, double *slope_p, uint8_t start, uint8_t end); #endif /* PTRS_NR_H */ diff --git a/openair1/SIMULATION/TOOLS/phase_noise.c b/openair1/SIMULATION/TOOLS/phase_noise.c index 4ea63f09ad..5585d445ce 100644 --- a/openair1/SIMULATION/TOOLS/phase_noise.c +++ b/openair1/SIMULATION/TOOLS/phase_noise.c @@ -29,7 +29,7 @@ /* linear phase noise model */ void phase_noise(double ts, int16_t * InRe, int16_t * InIm) { - static double i=0; + static uint64_t i=0; int32_t x=0 ,y=0; double fd = 300;//0.01*30000 int16_t SinValue = 0, CosValue= 0; @@ -39,33 +39,29 @@ void phase_noise(double ts, int16_t * InRe, int16_t * InIm) if(IdxModulo<2*ResolSinCos)//< 2 check for 1st and 2nd { - if(IdxModulo>=ResolSinCos)//>= 1 is 2nd Quadrant - { - SinValue = LUTSin[2*ResolSinCos-IdxModulo]; - CosValue = -LUTSin[IdxModulo-ResolSinCos]; - } - else// 1st Quadrant + if(IdxModulo < ResolSinCos)// 1st Quadrant { SinValue = LUTSin[IdxModulo]; CosValue = LUTSin[ResolSinCos-IdxModulo]; } - } - else if((IdxModulo>2*ResolSinCos))//> 2 check for 3rd and 4th - { - if(IdxModulo>=3*ResolSinCos)//> 3 is 4th Quadrant + else// 2nd Quadrant { - SinValue = -LUTSin[4*ResolSinCos-IdxModulo]; - CosValue = LUTSin[IdxModulo-3*ResolSinCos]; + SinValue = LUTSin[2*ResolSinCos-IdxModulo]; + CosValue = -LUTSin[IdxModulo-ResolSinCos]; } - else//3rd Quadrant + } + else // 3rd and 4th Quadrant + { + if(IdxModulo < 3*ResolSinCos)// 3rd Quadrant { SinValue = -LUTSin[IdxModulo-2*ResolSinCos]; CosValue = -LUTSin[3*ResolSinCos-IdxModulo]; } - } - else - { - AssertFatal(0==1,"Error in look-up table of sine function!\n"); + else//4th Quadrant + { + SinValue = -LUTSin[4*ResolSinCos-IdxModulo]; + CosValue = LUTSin[IdxModulo-3*ResolSinCos]; + } } x = ( ((int32_t)InRe[0] * CosValue) - ((int32_t)InIm[0] * SinValue )); y = ( ((int32_t)InIm[0] * CosValue) + ((int32_t)InRe[0] * SinValue ));