Commit dcf4fd1d authored by Roberto Louro Magueta's avatar Roberto Louro Magueta

Compute the noise power per RB

parent 05fffa49
......@@ -618,6 +618,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
gNB->nr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t));
gNB->nr_srs_info[id]->sc_list = (uint16_t *) malloc16_clear(6*fp->N_RB_UL*sizeof(uint16_t));
gNB->nr_srs_info[id]->srs_generated_signal = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
gNB->nr_srs_info[id]->noise_power_per_rb = (uint32_t*)malloc16_clear(fp->N_RB_UL*sizeof(uint32_t));
gNB->nr_srs_info[id]->noise_power = (uint32_t*)malloc16_clear(sizeof(uint32_t));
gNB->nr_srs_info[id]->srs_received_signal = (int32_t **)malloc16(Prx*sizeof(int32_t*));
gNB->nr_srs_info[id]->srs_ls_estimated_channel = (int32_t **)malloc16(Prx*sizeof(int32_t*));
......
......@@ -1099,6 +1099,7 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
int32_t **srs_estimated_channel_freq,
int32_t **srs_estimated_channel_time,
int32_t **srs_estimated_channel_time_shifted,
uint32_t *noise_power_per_rb,
uint32_t *noise_power) {
if(nr_srs_info->sc_list_length == 0) {
......@@ -1216,6 +1217,50 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
(gNB->frame_parms.ofdm_symbol_size>>1)*sizeof(int32_t));
}
// Compute noise power
uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12;
uint8_t srs_symbols_per_rb = srs_pdu->comb_size == 0 ? 6 : 3;
uint8_t n_noise_estimates = frame_parms->nb_antennas_rx*srs_symbols_per_rb;
uint8_t count_estimates = 0;
uint64_t sum_re = 0;
uint64_t sum_re2 = 0;
uint64_t sum_im = 0;
uint64_t sum_im2 = 0;
for (int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) {
int subcarrier0 = nr_srs_info->sc_list[sc_idx]-subcarrier_offset;
if(subcarrier0 < 0) {
subcarrier0 = subcarrier0 + frame_parms->ofdm_symbol_size;
}
int rb = subcarrier0/NR_NB_SC_PER_RB;
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
sum_re = sum_re + noise_real[ant*nr_srs_info->sc_list_length+sc_idx];
sum_re2 = sum_re2 + noise_real[ant*nr_srs_info->sc_list_length+sc_idx]*noise_real[ant*nr_srs_info->sc_list_length+sc_idx];
sum_im = sum_im + noise_imag[ant*nr_srs_info->sc_list_length+sc_idx];
sum_im2 = sum_im2 + noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]*noise_imag[ant*nr_srs_info->sc_list_length+sc_idx];
count_estimates++;
if (count_estimates == n_noise_estimates) {
noise_power_per_rb[rb] = sum_re2/n_noise_estimates - (sum_re/n_noise_estimates)*(sum_re/n_noise_estimates) +
sum_im2/n_noise_estimates - (sum_im/n_noise_estimates)*(sum_im/n_noise_estimates);
count_estimates = 0;
sum_re = 0;
sum_re2 = 0;
sum_im = 0;
sum_im2 = 0;
#ifdef SRS_DEBUG
LOG_I(NR_PHY,"noise_power_per_rb[%i] = %i\n", rb, noise_power_per_rb[rb]);
#endif
}
}
}
*noise_power = calc_power(noise_real,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length)
+ calc_power(noise_imag,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length);
......
......@@ -73,5 +73,6 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
int32_t **srs_estimated_channel_freq,
int32_t **srs_estimated_channel_time,
int32_t **srs_estimated_channel_time_shifted,
uint32_t *noise_power_per_rb,
uint32_t *noise_power);
#endif
......@@ -244,6 +244,7 @@ typedef struct {
int32_t **srs_estimated_channel_freq;
int32_t **srs_estimated_channel_time;
int32_t **srs_estimated_channel_time_shifted;
uint32_t *noise_power_per_rb;
uint32_t *noise_power;
} nr_srs_info_t;
......
......@@ -834,6 +834,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
gNB->nr_srs_info[i]->srs_estimated_channel_freq,
gNB->nr_srs_info[i]->srs_estimated_channel_time,
gNB->nr_srs_info[i]->srs_estimated_channel_time_shifted,
gNB->nr_srs_info[i]->noise_power_per_rb,
gNB->nr_srs_info[i]->noise_power);
T(T_GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE, T_INT(0), T_INT(srs_pdu->rnti), T_INT(frame_rx), T_INT(0), T_INT(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