Merge remote-tracking branch 'origin/fix-noise-calc' into integration_2026_w06 (!3873)
Ensure noise power is non-zero
Prior to this commit, noise power estimation could be zero because of a
call to clearArray() in gNB_I0_measurements(). This is problematic, as
this can lead to a noise power of 0 if all symbols in a RB are used,
which in turn leads to a spike in SNR.
To avoid this, use an intermediate array to store noise power, and only
update n0_subband_power if not all RBs are used (i.e., we can detect
noise power). Further, use an exponential moving average to smoothen
noise estimation.
Fixes: fb4235fd ("changes in PUCCH0 SNR measurement, testing for
PUCCH power control")
This commit is contained in:
@@ -228,7 +228,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
|
|||||||
|
|
||||||
PHY_MEASUREMENTS_gNB *meas = &gNB->measurements;
|
PHY_MEASUREMENTS_gNB *meas = &gNB->measurements;
|
||||||
free_and_zero(meas->n0_subband_power);
|
free_and_zero(meas->n0_subband_power);
|
||||||
free_and_zero(meas->n0_subband_power_dB);
|
|
||||||
|
|
||||||
for (int id = 0; id < gNB->max_nb_srs; id++) {
|
for (int id = 0; id < gNB->max_nb_srs; id++) {
|
||||||
for(int i=0; i<MAX_NUM_NR_SRS_AP; i++) {
|
for(int i=0; i<MAX_NUM_NR_SRS_AP; i++) {
|
||||||
|
|||||||
@@ -105,36 +105,47 @@ void nr_est_srs_timing_advance_offset(uint16_t ofdm_symbol_size,
|
|||||||
max_idx);
|
max_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB) {
|
void dump_nr_I0_stats(FILE *fd, PHY_VARS_gNB *gNB)
|
||||||
|
{
|
||||||
|
int min_I0 = 1000, max_I0 = 0;
|
||||||
int min_I0=1000,max_I0=0;
|
int amin = 0, amax = 0;
|
||||||
int amin=0,amax=0;
|
fprintf(fd, "Blacklisted PRBs %d/%d\n", gNB->num_ulprbbl, gNB->frame_parms.N_RB_UL);
|
||||||
fprintf(fd,"Blacklisted PRBs %d/%d\n",gNB->num_ulprbbl,gNB->frame_parms.N_RB_UL);
|
for (int i = 0; i < gNB->frame_parms.N_RB_UL; i++) {
|
||||||
for (int i=0; i<gNB->frame_parms.N_RB_UL; i++) {
|
if (gNB->ulprbbl[i] > 0)
|
||||||
if (gNB->ulprbbl[i] > 0) continue;
|
continue;
|
||||||
|
if (gNB->measurements.n0_subband_power_tot_dB[i] < min_I0) {
|
||||||
if (gNB->measurements.n0_subband_power_tot_dB[i]<min_I0) {min_I0 = gNB->measurements.n0_subband_power_tot_dB[i]; amin=i;}
|
min_I0 = gNB->measurements.n0_subband_power_tot_dB[i];
|
||||||
|
amin = i;
|
||||||
if (gNB->measurements.n0_subband_power_tot_dB[i]>max_I0) {max_I0 = gNB->measurements.n0_subband_power_tot_dB[i]; amax=i;}
|
|
||||||
}
|
}
|
||||||
|
if (gNB->measurements.n0_subband_power_tot_dB[i] > max_I0) {
|
||||||
for (int i=0; i<gNB->frame_parms.N_RB_UL; i++) {
|
max_I0 = gNB->measurements.n0_subband_power_tot_dB[i];
|
||||||
if (gNB->ulprbbl[i] ==0) fprintf(fd,"%2d.",gNB->measurements.n0_subband_power_tot_dB[i]-gNB->measurements.n0_subband_power_avg_dB);
|
amax = i;
|
||||||
else fprintf(fd," X.");
|
|
||||||
if (i%25 == 24) fprintf(fd,"\n");
|
|
||||||
}
|
}
|
||||||
fprintf(fd,"\n");
|
}
|
||||||
fprintf(fd,"max_IO = %d (%d), min_I0 = %d (%d), avg_I0 = %d dB",max_I0,amax,min_I0,amin,gNB->measurements.n0_subband_power_avg_dB);
|
|
||||||
if (gNB->frame_parms.nb_antennas_rx>1) {
|
|
||||||
fprintf(fd,"(");
|
|
||||||
for (int aarx=0;aarx<gNB->frame_parms.nb_antennas_rx;aarx++)
|
|
||||||
fprintf(fd,"%d.",gNB->measurements.n0_subband_power_avg_perANT_dB[aarx]);
|
|
||||||
fprintf(fd,")");
|
|
||||||
}
|
|
||||||
fprintf(fd,"\nPRACH I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10);
|
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < gNB->frame_parms.N_RB_UL; i++) {
|
||||||
|
if (gNB->ulprbbl[i] == 0)
|
||||||
|
fprintf(fd, "%2d.", gNB->measurements.n0_subband_power_tot_dB[i] - gNB->measurements.n0_subband_power_avg_dB);
|
||||||
|
else
|
||||||
|
fprintf(fd, " X.");
|
||||||
|
if (i % 25 == 24)
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
fprintf(fd,
|
||||||
|
"max_IO = %d (%d), min_I0 = %d (%d), avg_I0 = %d dB",
|
||||||
|
max_I0,
|
||||||
|
amax,
|
||||||
|
min_I0,
|
||||||
|
amin,
|
||||||
|
gNB->measurements.n0_subband_power_avg_dB);
|
||||||
|
if (gNB->frame_parms.nb_antennas_rx > 1) {
|
||||||
|
fprintf(fd, "(");
|
||||||
|
for (int aarx = 0; aarx < gNB->frame_parms.nb_antennas_rx; aarx++)
|
||||||
|
fprintf(fd, "%d.", gNB->measurements.n0_subband_power_avg_perANT_dB[aarx]);
|
||||||
|
fprintf(fd, ")");
|
||||||
|
}
|
||||||
|
fprintf(fd, "\nPRACH I0 = %d.%d dB\n", gNB->measurements.prach_I0 / 10, gNB->measurements.prach_I0 % 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_symb, uint32_t rb_mask_ul[14][9])
|
void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_symb, uint32_t rb_mask_ul[14][9])
|
||||||
@@ -144,19 +155,8 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_sy
|
|||||||
PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements;
|
PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements;
|
||||||
int nb_symb[275]={0};
|
int nb_symb[275]={0};
|
||||||
|
|
||||||
allocCast2D(n0_subband_power,
|
unsigned int tmp_n0_subband[frame_parms->nb_antennas_rx][frame_parms->N_RB_UL];
|
||||||
unsigned int,
|
memset(tmp_n0_subband, 0, sizeof(tmp_n0_subband));
|
||||||
gNB->measurements.n0_subband_power,
|
|
||||||
frame_parms->nb_antennas_rx,
|
|
||||||
frame_parms->N_RB_UL,
|
|
||||||
false);
|
|
||||||
clearArray(gNB->measurements.n0_subband_power, unsigned int);
|
|
||||||
allocCast2D(n0_subband_power_dB,
|
|
||||||
unsigned int,
|
|
||||||
gNB->measurements.n0_subband_power_dB,
|
|
||||||
frame_parms->nb_antennas_rx,
|
|
||||||
frame_parms->N_RB_UL,
|
|
||||||
false);
|
|
||||||
|
|
||||||
// TODO modify the measurements to take into account concurrent beams
|
// TODO modify the measurements to take into account concurrent beams
|
||||||
for (int s = first_symb; s < first_symb + num_symb; s++) {
|
for (int s = first_symb; s < first_symb + num_symb; s++) {
|
||||||
@@ -176,39 +176,46 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_sy
|
|||||||
} else {
|
} else {
|
||||||
signal_energy = signal_energy_nodc(ul_ch, 12);
|
signal_energy = signal_energy_nodc(ul_ch, 12);
|
||||||
}
|
}
|
||||||
n0_subband_power[aarx][rb] += signal_energy;
|
// noise power per antenna/RB, symbols summed up
|
||||||
|
tmp_n0_subband[aarx][rb] += signal_energy;
|
||||||
LOG_D(NR_PHY,"slot %d symbol %d RB %d aarx %d n0_subband_power %d\n", slot, s, rb, aarx, signal_energy);
|
LOG_D(NR_PHY,"slot %d symbol %d RB %d aarx %d n0_subband_power %d\n", slot, s, rb, aarx, signal_energy);
|
||||||
} //antenna
|
} //antenna
|
||||||
}
|
}
|
||||||
} //rb
|
} //rb
|
||||||
} // symb
|
} // symb
|
||||||
int nb_rb=0;
|
int nb_rb=0;
|
||||||
int64_t n0_subband_tot=0;
|
|
||||||
int32_t n0_subband_tot_perANT[frame_parms->nb_antennas_rx];
|
int32_t n0_subband_tot_perANT[frame_parms->nb_antennas_rx];
|
||||||
|
|
||||||
memset(n0_subband_tot_perANT, 0, sizeof(n0_subband_tot_perANT));
|
memset(n0_subband_tot_perANT, 0, sizeof(n0_subband_tot_perANT));
|
||||||
|
|
||||||
|
allocCast2D(n0_subband_power,
|
||||||
|
unsigned int,
|
||||||
|
measurements->n0_subband_power,
|
||||||
|
frame_parms->nb_antennas_rx,
|
||||||
|
frame_parms->N_RB_UL,
|
||||||
|
false);
|
||||||
|
|
||||||
for (int rb = 0 ; rb<frame_parms->N_RB_UL;rb++) {
|
for (int rb = 0 ; rb<frame_parms->N_RB_UL;rb++) {
|
||||||
int32_t n0_subband_tot_perPRB=0;
|
int32_t n0_subband_tot_perPRB=0;
|
||||||
if (nb_symb[rb] > 0) {
|
if (nb_symb[rb] > 0) {
|
||||||
for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
|
for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
|
||||||
n0_subband_power[aarx][rb] /= nb_symb[rb];
|
tmp_n0_subband[aarx][rb] /= nb_symb[rb];
|
||||||
n0_subband_power_dB[aarx][rb] = dB_fixed(n0_subband_power[aarx][rb]);
|
// apply exponential moving average to smooth noise measurements
|
||||||
|
n0_subband_power[aarx][rb] = 0.9 * n0_subband_power[aarx][rb] + 0.1 * tmp_n0_subband[aarx][rb];
|
||||||
n0_subband_tot_perPRB += n0_subband_power[aarx][rb];
|
n0_subband_tot_perPRB += n0_subband_power[aarx][rb];
|
||||||
n0_subband_tot_perANT[aarx] += n0_subband_power[aarx][rb];
|
n0_subband_tot_perANT[aarx] += n0_subband_power[aarx][rb];
|
||||||
}
|
}
|
||||||
n0_subband_tot_perPRB/=frame_parms->nb_antennas_rx;
|
n0_subband_tot_perPRB /= frame_parms->nb_antennas_rx;
|
||||||
measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_subband_tot_perPRB);
|
measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_subband_tot_perPRB);
|
||||||
measurements->n0_subband_power_tot_dBm[rb] = measurements->n0_subband_power_tot_dB[rb] - gNB->rx_total_gain_dB - dB_fixed(frame_parms->N_RB_UL);
|
|
||||||
LOG_D(NR_PHY,"n0_subband_power_tot_dB[%d] => %d, over %d symbols\n",rb,measurements->n0_subband_power_tot_dB[rb],nb_symb[rb]);
|
LOG_D(NR_PHY,"n0_subband_power_tot_dB[%d] => %d, over %d symbols\n",rb,measurements->n0_subband_power_tot_dB[rb],nb_symb[rb]);
|
||||||
n0_subband_tot += n0_subband_tot_perPRB;
|
|
||||||
nb_rb++;
|
nb_rb++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nb_rb>0) {
|
if (nb_rb>0) {
|
||||||
measurements->n0_subband_power_avg_dB = dB_fixed(n0_subband_tot/nb_rb);
|
int64_t n0_subband_tot = 0;
|
||||||
for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
|
for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
|
||||||
measurements->n0_subband_power_avg_perANT_dB[aarx] = dB_fixed(n0_subband_tot_perANT[aarx]/nb_rb);
|
measurements->n0_subband_power_avg_perANT_dB[aarx] = dB_fixed(n0_subband_tot_perANT[aarx] / nb_rb);
|
||||||
}
|
n0_subband_tot += n0_subband_tot_perANT[aarx];
|
||||||
|
}
|
||||||
|
measurements->n0_subband_power_avg_dB = dB_fixed(n0_subband_tot / nb_rb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ void nr_ulsch_layer_demapping(int16_t *llr_cw, uint8_t Nl, uint8_t mod_order, ui
|
|||||||
|
|
||||||
void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB);
|
void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB);
|
||||||
|
|
||||||
void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB);
|
|
||||||
|
|
||||||
NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch);
|
NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch);
|
||||||
|
|
||||||
#endif /* NR_ULSCH_H_ */
|
#endif /* NR_ULSCH_H_ */
|
||||||
|
|||||||
@@ -340,16 +340,12 @@ typedef struct {
|
|||||||
unsigned int n0_power_tot_dB;
|
unsigned int n0_power_tot_dB;
|
||||||
//! estimated avg noise power per RB per RX ant (lin)
|
//! estimated avg noise power per RB per RX ant (lin)
|
||||||
fourDimArray_t *n0_subband_power;
|
fourDimArray_t *n0_subband_power;
|
||||||
//! estimated avg noise power per RB per RX ant (dB)
|
|
||||||
fourDimArray_t *n0_subband_power_dB;
|
|
||||||
//! estimated avg subband noise power (dB)
|
//! estimated avg subband noise power (dB)
|
||||||
unsigned int n0_subband_power_avg_dB;
|
unsigned int n0_subband_power_avg_dB;
|
||||||
//! estimated avg subband noise power per antenna (dB)
|
//! estimated avg subband noise power per antenna (dB)
|
||||||
unsigned int n0_subband_power_avg_perANT_dB[MAX_ANT];
|
unsigned int n0_subband_power_avg_perANT_dB[MAX_ANT];
|
||||||
//! estimated avg noise power per RB (dB)
|
//! estimated avg noise power per RB (dB)
|
||||||
int n0_subband_power_tot_dB[275];
|
int n0_subband_power_tot_dB[275];
|
||||||
//! estimated avg noise power per RB (dBm)
|
|
||||||
int n0_subband_power_tot_dBm[275];
|
|
||||||
/// PRACH background noise level
|
/// PRACH background noise level
|
||||||
int prach_I0;
|
int prach_I0;
|
||||||
} PHY_MEASUREMENTS_gNB;
|
} PHY_MEASUREMENTS_gNB;
|
||||||
|
|||||||
Reference in New Issue
Block a user