Commit 13645b1b authored by Parminder Singh's avatar Parminder Singh

Updated the sin cos table condition check

- Sin cos table quadrant condition checks are updated
- function are indented properly
- Debug prints are updated for double data type
parent c16e5831
...@@ -357,8 +357,8 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos, ...@@ -357,8 +357,8 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
uint16_t startSymbIdx, uint16_t startSymbIdx,
uint16_t noSymb) uint16_t noSymb)
{ {
int32_t slope = 0; double slope[2] = {0,0};
int16_t *slope_p = (int16_t*)&slope; double *slope_p = &slope[0];
uint8_t symbInSlot = startSymbIdx + noSymb; uint8_t symbInSlot = startSymbIdx + noSymb;
int8_t rightRef = 0; int8_t rightRef = 0;
int8_t leftRef = 0; int8_t leftRef = 0;
...@@ -414,7 +414,7 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos, ...@@ -414,7 +414,7 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
{ {
// in right extrapolation use the last slope // in right extrapolation use the last slope
#ifdef DEBUG_PTRS #ifdef DEBUG_PTRS
printf("[PHY][PTRS]: Last Slop Reused :(%4d %4d)\n", slope_p[0],slope_p[1]); printf("[PHY][PTRS]: Last Slop Reused :(%4f %4f)\n", slope_p[0],slope_p[1]);
#endif #endif
ptrs_estimate_from_slope(estPerSymb,slope_p,symb-1,symbInSlot); ptrs_estimate_from_slope(estPerSymb,slope_p,symb-1,symbInSlot);
symb = symbInSlot; symb = symbInSlot;
...@@ -430,26 +430,26 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos, ...@@ -430,26 +430,26 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
} }
/* Calculate slope from 2 reference points */ /* Calculate slope from 2 reference points */
void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, int16_t *slope_p) void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, double *slope_p)
{ {
uint8_t distance = end - start; uint8_t distance = end - start;
slope_p[0] = (est_p[end*2] - est_p[start*2]) /distance; slope_p[0] = (double)(est_p[end*2] - est_p[start*2]) /distance;
slope_p[1] = (est_p[(end*2)+1] - est_p[(start*2)+1]) /distance; slope_p[1] = (double)(est_p[(end*2)+1] - est_p[(start*2)+1]) /distance;
#ifdef DEBUG_PTRS #ifdef DEBUG_PTRS
printf("[PHY][PTRS]: Slop is :(%4d %4d) between Symbol %2d & Symbol %2d\n", slope_p[0],slope_p[1], start, end); printf("[PHY][PTRS]: Slop is :(%4f %4f) between Symbol %2d & Symbol %2d\n", slope_p[0],slope_p[1], start, end);
//printf("%d %d - %d %d\n",est_p[end*2],est_p[(end*2)+1],est_p[start*2],est_p[(start*2)+1]); //printf("%d %d - %d %d\n",est_p[end*2],est_p[(end*2)+1],est_p[start*2],est_p[(start*2)+1]);
#endif #endif
} }
/* estimate from slope */ /* estimate from slope */
void ptrs_estimate_from_slope(int16_t *error_est, int16_t *slope_p, uint8_t start, uint8_t end) void ptrs_estimate_from_slope(int16_t *error_est, double *slope_p, uint8_t start, uint8_t end)
{ {
for(uint8_t i = 1; i< (end -start);i++) for(uint8_t i = 1; i< (end -start);i++)
{ {
error_est[(start+i)*2] = (error_est[start*2] + (i * slope_p[0]));// real error_est[(start+i)*2] = (error_est[start*2] + (int16_t)(i * slope_p[0]));// real
error_est[((start +i)*2)+1] = (error_est[(start*2)+1] + ( i * slope_p[1])); //imag error_est[((start +i)*2)+1] = (error_est[(start*2)+1] + (int16_t)( i * slope_p[1])); //imag
#ifdef DEBUG_PTRS #ifdef DEBUG_PTRS
printf("[PHY][PTRS]: Estimated Symbol %2d -> %4d %4d from Slope (%4d %4d)\n", start+i,error_est[(start+i)*2],error_est[((start +i)*2)+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]); slope_p[0],slope_p[1]);
#endif #endif
} }
......
...@@ -83,7 +83,7 @@ static inline uint8_t is_ptrs_symbol(uint8_t l, uint16_t ptrs_symbols) { return ...@@ -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); 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_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); 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, int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
uint16_t ptrsSymbPos, uint16_t ptrsSymbPos,
int16_t *estPerSymb, int16_t *estPerSymb,
...@@ -105,6 +105,6 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, ...@@ -105,6 +105,6 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs,
int16_t *error_est, int16_t *error_est,
int32_t *ptrs_sc); int32_t *ptrs_sc);
void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, int16_t *slope_p); 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, int16_t *slope_p, uint8_t start, uint8_t end); void ptrs_estimate_from_slope(int16_t *error_est, double *slope_p, uint8_t start, uint8_t end);
#endif /* PTRS_NR_H */ #endif /* PTRS_NR_H */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/* linear phase noise model */ /* linear phase noise model */
void phase_noise(double ts, int16_t * InRe, int16_t * InIm) 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; int32_t x=0 ,y=0;
double fd = 300;//0.01*30000 double fd = 300;//0.01*30000
int16_t SinValue = 0, CosValue= 0; int16_t SinValue = 0, CosValue= 0;
...@@ -39,33 +39,29 @@ void phase_noise(double ts, int16_t * InRe, int16_t * InIm) ...@@ -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<2*ResolSinCos)//< 2 check for 1st and 2nd
{ {
if(IdxModulo>=ResolSinCos)//>= 1 is 2nd Quadrant if(IdxModulo < ResolSinCos)// 1st Quadrant
{
SinValue = LUTSin[2*ResolSinCos-IdxModulo];
CosValue = -LUTSin[IdxModulo-ResolSinCos];
}
else// 1st Quadrant
{ {
SinValue = LUTSin[IdxModulo]; SinValue = LUTSin[IdxModulo];
CosValue = LUTSin[ResolSinCos-IdxModulo]; CosValue = LUTSin[ResolSinCos-IdxModulo];
} }
} else// 2nd Quadrant
else if((IdxModulo>2*ResolSinCos))//> 2 check for 3rd and 4th
{
if(IdxModulo>=3*ResolSinCos)//> 3 is 4th Quadrant
{ {
SinValue = -LUTSin[4*ResolSinCos-IdxModulo]; SinValue = LUTSin[2*ResolSinCos-IdxModulo];
CosValue = LUTSin[IdxModulo-3*ResolSinCos]; CosValue = -LUTSin[IdxModulo-ResolSinCos];
} }
else//3rd Quadrant }
else // 3rd and 4th Quadrant
{
if(IdxModulo < 3*ResolSinCos)// 3rd Quadrant
{ {
SinValue = -LUTSin[IdxModulo-2*ResolSinCos]; SinValue = -LUTSin[IdxModulo-2*ResolSinCos];
CosValue = -LUTSin[3*ResolSinCos-IdxModulo]; CosValue = -LUTSin[3*ResolSinCos-IdxModulo];
} }
} else//4th Quadrant
else
{ {
AssertFatal(0==1,"Error in look-up table of sine function!\n"); SinValue = -LUTSin[4*ResolSinCos-IdxModulo];
CosValue = LUTSin[IdxModulo-3*ResolSinCos];
}
} }
x = ( ((int32_t)InRe[0] * CosValue) - ((int32_t)InIm[0] * SinValue )); x = ( ((int32_t)InRe[0] * CosValue) - ((int32_t)InIm[0] * SinValue ));
y = ( ((int32_t)InIm[0] * CosValue) + ((int32_t)InRe[0] * SinValue )); y = ( ((int32_t)InIm[0] * CosValue) + ((int32_t)InRe[0] * SinValue ));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment