Commit ce405789 authored by Haruki NAOI's avatar Haruki NAOI Committed by shono.takafumi

Fix: interference power measurement on DRS.

parent 2529c20b
......@@ -1072,10 +1072,22 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
}
for (i=0; i<frame_parms->nb_antennas_rx; i++) {
pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[i],
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor;
LOG_D(PHY,"%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d) power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid,
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_100Ks,correction_factor,dB_fixed_times10(pusch_vars->ulsch_power[i]));
pusch_vars->ulsch_interference_power[i] = interference_power(pusch_vars->drs_ch_estimates[i],ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor;
pusch_vars->ulsch_power[i] = signal_power(pusch_vars->drs_ch_estimates[i],ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor;
if(pusch_vars->ulsch_power[i]>0x20000000){
pusch_vars->ulsch_power[i] = 0x20000000;
pusch_vars->ulsch_interference_power[i] = 1;
}else{
pusch_vars->ulsch_power[i] -= pusch_vars->ulsch_interference_power[i];
if(pusch_vars->ulsch_power[i]<1) pusch_vars->ulsch_power[i] = 1;
if(pusch_vars->ulsch_interference_power[i]<1)pusch_vars->ulsch_interference_power[i] = 1;
}
LOG_D(PHY,"%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d) power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_100Ks,correction_factor,dB_fixed_times10(pusch_vars->ulsch_power[i]));
}
ulsch_channel_level(pusch_vars->drs_ch_estimates,
......
......@@ -364,3 +364,66 @@ main(int argc,char **argv)
}
#endif
#define SHRT_MIN -32768
int32_t signal_power(int32_t *input, uint32_t length)
{
uint32_t i;
int32_t temp;
__m128i in, in_clp, i16_min;
__m128 num0, num1;
__m128 recp1;
//init
num0 = _mm_setzero_ps();
i16_min = _mm_set1_epi16(SHRT_MIN);
recp1 = _mm_rcp_ps(_mm_cvtepi32_ps(_mm_set1_epi32(length)));
//Acc
for (i = 0; i < (length >> 2); i++) {
in = _mm_loadu_si128((__m128i *)input);
in_clp = _mm_subs_epi16(in, _mm_cmpeq_epi16(in, i16_min));//if in=SHRT_MIN in+1, else in
num0 = _mm_add_ps(num0, _mm_cvtepi32_ps(_mm_madd_epi16(in_clp, in_clp)));
input += 4;
}
//Ave
num1 = _mm_dp_ps(num0, recp1, 0xFF);
temp = _mm_cvtsi128_si32(_mm_cvttps_epi32(num1));
return temp;
}
int32_t interference_power(int32_t *input, uint32_t length)
{
uint32_t i;
int32_t temp;
__m128i in, in_clp, i16_min;
__m128i num0, num1, num2, num3;
__m128 num4, num5, num6;
__m128 recp1;
//init
i16_min = _mm_set1_epi16(SHRT_MIN);
num5 = _mm_setzero_ps();
recp1 = _mm_rcp_ps(_mm_cvtepi32_ps(_mm_set1_epi32(length>>2)));// 1/n, n= length/4
//Acc
for (i = 0; i < (length >> 2); i++) {
in = _mm_loadu_si128((__m128i *)input);
in_clp = _mm_subs_epi16(in, _mm_cmpeq_epi16(in, i16_min)); //if in=SHRT_MIN, in+1, else in
num0 = _mm_cvtepi16_epi32(in_clp); //lower 2 complex [0], [1]
num1 = _mm_cvtepi16_epi32(_mm_shuffle_epi32(in_clp, 0x4E)); //upper 2 complex [2], [3]
num2 = _mm_srai_epi32(_mm_add_epi32(num0, num1), 0x01); //average A=complex( [0] + [2] ) / 2, B=complex( [1] + [3] ) / 2
num3 = _mm_sub_epi32(num2, _mm_shuffle_epi32(num2, 0x4E)); //complexA-complexB, B-A
num4 = _mm_dp_ps(_mm_cvtepi32_ps(num3), _mm_cvtepi32_ps(num3), 0x3F);//C = num3 lower complex power, C, C, C
num5 = _mm_add_ps(num5, num4); //Acc Cn, Cn, Cn, Cn,
input += 4;
}
//Interference ve
num6 = _mm_mul_ps(num5, recp1); //Cn / n
temp = _mm_cvtsi128_si32(_mm_cvttps_epi32(num6));
return temp;
}
......@@ -431,6 +431,9 @@ int32_t subcarrier_energy(int32_t *,uint32_t, int32_t* subcarrier_energy, uint16
*/
int32_t signal_energy_nodc(int32_t *,uint32_t);
int32_t signal_power(int32_t *,uint32_t);
int32_t interference_power(int32_t *,uint32_t);
/*!\fn double signal_energy_fp(double *s_re[2], double *s_im[2],uint32_t, uint32_t,uint32_t);
\brief Computes the signal energy per subcarrier
*/
......
......@@ -166,6 +166,8 @@ typedef struct {
int32_t **ul_ch_magb;
/// measured RX power based on DRS
int ulsch_power[2];
/// measured Interference power based on DRS
int ulsch_interference_power[2];
/// \brief llr values.
/// - first index: ? [0..1179743] (hard coded)
int16_t *llr;
......
......@@ -1605,7 +1605,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,
pdu->rx_indication_rel8.timing_advance = timing_advance_update;
// estimate UL_CQI for MAC (from antenna port 0 only)
int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 10 * eNB->measurements.n0_subband_power_dB[0][0];
int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_interference_power[0]);
if (SNRtimes10 < -640)
pdu->rx_indication_rel8.ul_cqi = 0;
......
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