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 5a6f23b2b808d8007df3099a3dfd8149de6b13ad..559e8e3cb1a88257a08792fb1020386ee42750b4 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1094,7 +1094,8 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, for(uint8_t i = *startSymbIndex; i< symbInSlot ;i++) { /* DMRS Symbol has 0 phase so no need to rotate the respective symbol */ - if(!is_dmrs_symbol(i,*dmrsSymbPos)) + /* Skip rotation if the slot processing is wrong */ + if((!is_dmrs_symbol(i,*dmrsSymbPos)) && (ret == 0)) { #ifdef DEBUG_DL_PTRS printf("[PHY][DL][PTRS]: Rotate Symbol %2d with %d + j* %d\n", i, phase_per_symbol[2* i],phase_per_symbol[(2* i) +1]); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 1aea7916bb7d0307b4cc50d8bda7471f229271bd..ad8e4f1111ceb3426a56cacbe94227b1b43a6040 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -481,6 +481,8 @@ int main(int argc, char **argv) logInit(); set_glog(loglvl); T_stdout = 1; + /* initialize the sin table */ + InitSinLUT(); get_softmodem_params()->phy_test = 1; @@ -488,6 +490,7 @@ int main(int argc, char **argv) snr1 = snr0+10; + RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = (PHY_VARS_gNB*) malloc(sizeof(PHY_VARS_gNB )); memset(RC.gNB[0],0,sizeof(PHY_VARS_gNB)); diff --git a/openair1/SIMULATION/TOOLS/phase_noise.c b/openair1/SIMULATION/TOOLS/phase_noise.c index f243a09c59ee1912a31c5609554f0de682ced6cb..f9cf781edbedcebc502e227615040318c14d0005 100644 --- a/openair1/SIMULATION/TOOLS/phase_noise.c +++ b/openair1/SIMULATION/TOOLS/phase_noise.c @@ -29,14 +29,42 @@ /* linear phase noise model */ void phase_noise(double ts, int16_t * InRe, int16_t * InIm) { - double fd = 300;//0.01*30000 static double i=0; - double real, imag,x ,y; + int32_t x=0 ,y=0; + double fd = 300;//0.01*30000 + int16_t SinValue = 0, CosValue= 0; + double IdxDouble = (double)(i*fd * ts * ResolSinCos * 4); + int16_t IdxModulo = ((int32_t)(IdxDouble>0 ? IdxDouble+0.5 : IdxDouble-0.5)) % (ResolSinCos*4); + IdxModulo = IdxModulo<0 ? IdxModulo+ResolSinCos*4 : IdxModulo; + + if ( IdxModulo>=0 && IdxModulo<ResolSinCos ) { + SinValue = LUTSin[IdxModulo]; + CosValue = LUTSin[ResolSinCos-IdxModulo]; + } + else if ( IdxModulo>=ResolSinCos && IdxModulo<2*ResolSinCos ) { + SinValue = LUTSin[2*ResolSinCos-IdxModulo]; + CosValue = -LUTSin[IdxModulo-ResolSinCos]; + } + else if ( IdxModulo>=2*ResolSinCos && IdxModulo<3*ResolSinCos ) { + SinValue = -LUTSin[IdxModulo-2*ResolSinCos]; + CosValue = -LUTSin[3*ResolSinCos-IdxModulo]; + } + else if ( IdxModulo>=3*ResolSinCos && IdxModulo<4*ResolSinCos ) { + SinValue = -LUTSin[4*ResolSinCos-IdxModulo]; + CosValue = LUTSin[IdxModulo-3*ResolSinCos]; + } + else { + AssertFatal(0==1,"Error in look-up table of sine function!\n"); + } + x = ( ((int32_t)InRe[0] * CosValue) - ((int32_t)InIm[0] * SinValue )); + y = ( ((int32_t)InIm[0] * CosValue) + ((int32_t)InRe[0] * SinValue )); + InRe[0]= (int16_t)(x>>14); + InIm[0]= (int16_t)(y>>14); i++; - real = cos(fd * 2 * M_PI * i * ts); - imag = sin (fd * 2 * M_PI * i * ts); - x = ((real * (double)InRe[0]) - (imag * (double)InIm[0])) ; - y= ((real * (double)InIm[0]) + (imag * (double)InRe[0])) ; - InRe[0]= (int16_t)(x); - InIm[0]= (int16_t)(y); +} +/* Initialisation function for SIN table values */ +void InitSinLUT( void ) { + for ( int i=0; i<(ResolSinCos+1); i++ ) { + LUTSin[i] = sin((double)(M_PI*i)/(2*ResolSinCos)) * (1<<14); //Format: Q14 + } } diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index d2684b15c1fd0602e553e9f9dc5d4d0355003a01..55a78e977866ec9ed63a1a73c4e47c4c597352f6 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -466,6 +466,10 @@ double N_RB2channel_bandwidth(uint16_t N_RB); \param ts Sampling time \param *Re *Im Real and Imag part of the signal */ +//look-up table for the sine (cosine) function +#define ResolSinCos 100 +uint16_t LUTSin[ResolSinCos+1]; +void InitSinLUT( void ); void phase_noise(double ts, int16_t * InRe, int16_t * InIm); #include "targets/RT/USER/rfsim.h"