Commit 9542e8a8 authored by Florian Kaltenberger's avatar Florian Kaltenberger

alternative version of dlsch_channel_level not needing floating point

parent 3c56a7ed
...@@ -3389,11 +3389,9 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, ...@@ -3389,11 +3389,9 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
nre=12; nre=12;
//nb_rb*nre = y * 2^x //nb_rb*nre = y * 2^x
int16_t x = log2_approx(nb_rb*nre)-1; int16_t x = factor2(nb_rb*nre);
//int16_t one_over_y_q15 = (int16_t)((1<<((int32_t)x+15))/((int32_t)nb_rb*(int32_t)nre)); int16_t y = (nb_rb*nre)/(1<<x);
float y = (float)(nb_rb*nre)/(float)(1<<x); printf("nb_rb*nre = %d = %d * 2^(%d)\n",nb_rb*nre,y,x);
//printf("1/(nb_rb*nre) = 1/%d = %d*2^(-15) * 2^(-%d)\n",nb_rb*nre,one_over_y_q15,x);
printf("nb_rb*nre = %d = %f * 2^(%d)\n",nb_rb*nre,y,x);
for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
...@@ -3432,8 +3430,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, ...@@ -3432,8 +3430,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
avg[(aatx<<1)+aarx] = (((int32_t*)&avg128D)[0] + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128D)[0] +
((int32_t*)&avg128D)[1] + ((int32_t*)&avg128D)[1] +
((int32_t*)&avg128D)[2] + ((int32_t*)&avg128D)[2] +
((int32_t*)&avg128D)[3]); ((int32_t*)&avg128D)[3])/y;
avg[(aatx<<1)+aarx] = (int32_t) ((float) avg[(aatx<<1)+aarx]/y);
printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
} }
......
...@@ -338,6 +338,9 @@ uint8_t log2_approx64(unsigned long long int x); ...@@ -338,6 +338,9 @@ uint8_t log2_approx64(unsigned long long int x);
int16_t invSqrt(int16_t x); int16_t invSqrt(int16_t x);
uint32_t angle(struct complex16 perrror); uint32_t angle(struct complex16 perrror);
/// computes the number of factors 2 in x
unsigned char factor2(unsigned int x);
/*!\fn int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot, /*!\fn int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot,
uint32_t last_pilot, int32_t ignore_prefix); uint32_t last_pilot, int32_t ignore_prefix);
Compensate the phase rotation of the RF. WARNING: This function is currently unused. It has not been tested! Compensate the phase rotation of the RF. WARNING: This function is currently unused. It has not been tested!
......
...@@ -37,6 +37,26 @@ unsigned char log2_approx(unsigned int x) ...@@ -37,6 +37,26 @@ unsigned char log2_approx(unsigned int x)
return(l2); return(l2);
} }
unsigned char factor2(unsigned int x)
{
int i;
unsigned char l2;
l2=0;
for (i=0; i<31; i++)
if ((x&(1<<i)) != 0)
break;
l2 = i;
//printf("factor2(%d) = %d\n",x,l2);
return(l2);
}
unsigned char log2_approx64(unsigned long long int x) unsigned char log2_approx64(unsigned long long int x)
{ {
......
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