Commit 765bb64b authored by rmagueta's avatar rmagueta

Fix SNR based on SRS

parent e15fa14c
...@@ -495,7 +495,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) ...@@ -495,7 +495,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB)
gNB->max_nb_pucch = buffer_ul_slots ? MAX_MOBILES_PER_GNB * buffer_ul_slots : 1; gNB->max_nb_pucch = buffer_ul_slots ? MAX_MOBILES_PER_GNB * buffer_ul_slots : 1;
gNB->max_nb_pusch = buffer_ul_slots ? MAX_MOBILES_PER_GNB * buffer_ul_slots : 1; gNB->max_nb_pusch = buffer_ul_slots ? MAX_MOBILES_PER_GNB * buffer_ul_slots : 1;
gNB->max_nb_srs = buffer_ul_slots << 1; // assuming at most 2 SRS per slot gNB->max_nb_srs = buffer_ul_slots ? buffer_ul_slots << 1 : 1; // assuming at most 2 SRS per slot
gNB->pucch = (NR_gNB_PUCCH_t *)malloc16(gNB->max_nb_pucch * sizeof(NR_gNB_PUCCH_t)); gNB->pucch = (NR_gNB_PUCCH_t *)malloc16(gNB->max_nb_pucch * sizeof(NR_gNB_PUCCH_t));
for (int i = 0; i < gNB->max_nb_pucch; i++) { for (int i = 0; i < gNB->max_nb_pucch; i++) {
......
...@@ -596,17 +596,6 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, ...@@ -596,17 +596,6 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
} // Antenna loop } // Antenna loop
} }
uint32_t calc_power(const int16_t *x, const uint32_t size) {
int64_t sum_x = 0;
int64_t sum_x2 = 0;
for(int k = 0; k<size; k++) {
sum_x = sum_x + x[k];
sum_x2 = sum_x2 + x[k]*x[k];
}
return sum_x2/size - (sum_x/size)*(sum_x/size);
}
int nr_srs_channel_estimation( int nr_srs_channel_estimation(
const PHY_VARS_gNB *gNB, const PHY_VARS_gNB *gNB,
const int frame, const int frame,
...@@ -643,27 +632,20 @@ int nr_srs_channel_estimation( ...@@ -643,27 +632,20 @@ int nr_srs_channel_estimation(
const uint32_t arr_len = frame_parms->nb_antennas_rx * N_ap * M_sc_b_SRS; const uint32_t arr_len = frame_parms->nb_antennas_rx * N_ap * M_sc_b_SRS;
int16_t ch_real[arr_len]; c16_t ch[arr_len];
memset(ch_real, 0, arr_len * sizeof(int16_t)); memset(ch, 0, arr_len * sizeof(c16_t));
int16_t ch_imag[arr_len];
memset(ch_imag, 0, arr_len * sizeof(int16_t));
int16_t noise_real[arr_len];
memset(noise_real, 0, arr_len * sizeof(int16_t));
int16_t noise_imag[arr_len];
memset(noise_imag, 0, arr_len * sizeof(int16_t));
int16_t ls_estimated[2]; c16_t noise[arr_len];
memset(noise, 0, arr_len * sizeof(c16_t));
uint8_t mem_offset = ((16 - ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF) >> 2; // >> 2 <=> /sizeof(int32_t) uint8_t mem_offset = ((16 - ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF) >> 2; // >> 2 <=> /sizeof(int32_t)
// filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0} // filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}
// The End of OFDM symbol corresponds to the position of last 16384 in the filter // The End of OFDM symbol corresponds to the position of last 16384 in the filter
// The multadd_real_vector_complex_scalar applies the remaining 8 zeros of filter, therefore, to avoid a buffer overflow, // The c16multaddVectRealComplex applies the remaining 8 zeros of filter, therefore, to avoid a buffer overflow,
// we added 8 in the array size // we added 8 in the array size
int32_t srs_est[frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols) + mem_offset + 8] __attribute__ ((aligned(32))); int32_t srs_est[frame_parms->ofdm_symbol_size * (1 << srs_pdu->num_symbols) + mem_offset + 8] __attribute__((aligned(32)));
c16_t ls_estimated = {0};
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
...@@ -681,14 +663,12 @@ int nr_srs_channel_estimation( ...@@ -681,14 +663,12 @@ int nr_srs_channel_estimation(
subcarrier -= frame_parms->ofdm_symbol_size; subcarrier -= frame_parms->ofdm_symbol_size;
} }
int16_t *srs_estimated_channel16 = (int16_t *)&srs_est[subcarrier + mem_offset]; c16_t *srs_estimated_channel16 = (c16_t *)&srs_est[subcarrier + mem_offset];
for (int k = 0; k < M_sc_b_SRS; k++) { for (int k = 0; k < M_sc_b_SRS; k++) {
if (k%fd_cdm==0) { if (k%fd_cdm==0) {
ls_estimated = (c16_t){0, 0};
ls_estimated[0] = 0;
ls_estimated[1] = 0;
uint16_t subcarrier_cdm = subcarrier; uint16_t subcarrier_cdm = subcarrier;
for (int cdm_idx = 0; cdm_idx < fd_cdm; cdm_idx++) { for (int cdm_idx = 0; cdm_idx < fd_cdm; cdm_idx++) {
...@@ -700,8 +680,8 @@ int nr_srs_channel_estimation( ...@@ -700,8 +680,8 @@ int nr_srs_channel_estimation(
// We know that nr_srs_info->srs_generated_signal_bits bits are enough to represent the generated_real and generated_imag. // We know that nr_srs_info->srs_generated_signal_bits bits are enough to represent the generated_real and generated_imag.
// So we only need a nr_srs_info->srs_generated_signal_bits shift to ensure that the result fits into 16 bits. // So we only need a nr_srs_info->srs_generated_signal_bits shift to ensure that the result fits into 16 bits.
ls_estimated[0] += (int16_t)(((int32_t)generated_real*received_real + (int32_t)generated_imag*received_imag)>>nr_srs_info->srs_generated_signal_bits); ls_estimated.r += (int16_t)(((int32_t)generated_real*received_real + (int32_t)generated_imag*received_imag)>>nr_srs_info->srs_generated_signal_bits);
ls_estimated[1] += (int16_t)(((int32_t)generated_real*received_imag - (int32_t)generated_imag*received_real)>>nr_srs_info->srs_generated_signal_bits); ls_estimated.i += (int16_t)(((int32_t)generated_real*received_imag - (int32_t)generated_imag*received_real)>>nr_srs_info->srs_generated_signal_bits);
// Subcarrier increment // Subcarrier increment
subcarrier_cdm += K_TC; subcarrier_cdm += K_TC;
...@@ -711,8 +691,7 @@ int nr_srs_channel_estimation( ...@@ -711,8 +691,7 @@ int nr_srs_channel_estimation(
} }
} }
srs_ls_estimated_channel[subcarrier].r = ls_estimated[0]; srs_ls_estimated_channel[subcarrier] = ls_estimated;
srs_ls_estimated_channel[subcarrier].i = ls_estimated[1];
#ifdef SRS_DEBUG #ifdef SRS_DEBUG
int subcarrier_log = subcarrier-subcarrier_offset; int subcarrier_log = subcarrier-subcarrier_offset;
...@@ -727,48 +706,48 @@ int nr_srs_channel_estimation( ...@@ -727,48 +706,48 @@ int nr_srs_channel_estimation(
subcarrier_log, subcarrier_log,
((c16_t*)srs_generated_signal[p_index])[subcarrier].r, ((c16_t*)srs_generated_signal[p_index])[subcarrier].i, ((c16_t*)srs_generated_signal[p_index])[subcarrier].r, ((c16_t*)srs_generated_signal[p_index])[subcarrier].i,
((c16_t*)srs_received_signal[ant])[subcarrier].r, ((c16_t*)srs_received_signal[ant])[subcarrier].i, ((c16_t*)srs_received_signal[ant])[subcarrier].r, ((c16_t*)srs_received_signal[ant])[subcarrier].i,
ls_estimated[0], ls_estimated[1]); ls_estimated.r, ls_estimated.i);
#endif #endif
const uint16_t sc_offset = subcarrier + mem_offset; const uint16_t sc_offset = subcarrier + mem_offset;
// Channel interpolation // Channel interpolation
if(srs_pdu->comb_size == 0) { if (srs_pdu->comb_size == 0) {
if(k == 0) { // First subcarrier case if (k == 0) { // First subcarrier case
// filt8_start is {12288,8192,4096,0,0,0,0,0} // filt8_start is {12288,8192,4096,0,0,0,0,0}
multadd_real_vector_complex_scalar(filt8_start, ls_estimated, srs_estimated_channel16, 8); c16multaddVectRealComplex(filt8_start, &ls_estimated, srs_estimated_channel16, 8);
} else if(subcarrier < K_TC) { // Start of OFDM symbol case } else if (subcarrier < K_TC) { // Start of OFDM symbol case
// filt8_start is {12288,8192,4096,0,0,0,0,0} // filt8_start is {12288,8192,4096,0,0,0,0,0}
srs_estimated_channel16 = (int16_t *)&srs_est[subcarrier]; srs_estimated_channel16 = (c16_t *)&srs_est[subcarrier];
const short *filter = mem_offset == 0 ? filt8_start : filt8_start_shift2; const short *filter = mem_offset == 0 ? filt8_start : filt8_start_shift2;
multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); c16multaddVectRealComplex(filter, &ls_estimated, srs_estimated_channel16, 8);
} else if((subcarrier+K_TC)>=frame_parms->ofdm_symbol_size || k == (M_sc_b_SRS-1)) { // End of OFDM symbol or last subcarrier cases } else if ((subcarrier + K_TC) >= frame_parms->ofdm_symbol_size || k == (M_sc_b_SRS - 1)) { // End of OFDM symbol or last subcarrier cases
// filt8_end is {4096,8192,12288,16384,0,0,0,0} // filt8_end is {4096,8192,12288,16384,0,0,0,0}
const short *filter = mem_offset == 0 || k == (M_sc_b_SRS - 1) ? filt8_end : filt8_end_shift2; const short *filter = mem_offset == 0 || k == (M_sc_b_SRS - 1) ? filt8_end : filt8_end_shift2;
multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); c16multaddVectRealComplex(filter, &ls_estimated, srs_estimated_channel16, 8);
} else if(k%2 == 1) { // 1st middle case } else if (k % 2 == 1) { // 1st middle case
// filt8_middle2 is {4096,8192,8192,8192,4096,0,0,0} // filt8_middle2 is {4096,8192,8192,8192,4096,0,0,0}
multadd_real_vector_complex_scalar(filt8_middle2, ls_estimated, srs_estimated_channel16, 8); c16multaddVectRealComplex(filt8_middle2, &ls_estimated, srs_estimated_channel16, 8);
} else if(k%2 == 0) { // 2nd middle case } else if (k % 2 == 0) { // 2nd middle case
// filt8_middle4 is {0,0,4096,8192,8192,8192,4096,0} // filt8_middle4 is {0,0,4096,8192,8192,8192,4096,0}
multadd_real_vector_complex_scalar(filt8_middle4, ls_estimated, srs_estimated_channel16, 8); c16multaddVectRealComplex(filt8_middle4, &ls_estimated, srs_estimated_channel16, 8);
srs_estimated_channel16 = (int16_t *)&srs_est[sc_offset]; srs_estimated_channel16 = (c16_t *)&srs_est[sc_offset];
} }
} else { } else {
if(k == 0) { // First subcarrier case if (k == 0) { // First subcarrier case
// filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0}
multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); c16multaddVectRealComplex(filt16_start, &ls_estimated, srs_estimated_channel16, 16);
} else if(subcarrier < K_TC) { // Start of OFDM symbol case } else if (subcarrier < K_TC) { // Start of OFDM symbol case
srs_estimated_channel16 = (int16_t *)&srs_est[sc_offset]; srs_estimated_channel16 = (c16_t *)&srs_est[sc_offset];
// filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0}
multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); c16multaddVectRealComplex(filt16_start, &ls_estimated, srs_estimated_channel16, 16);
} else if((subcarrier+K_TC)>=frame_parms->ofdm_symbol_size || k == (M_sc_b_SRS-1)) { // End of OFDM symbol or last subcarrier cases } else if ((subcarrier + K_TC) >= frame_parms->ofdm_symbol_size || k == (M_sc_b_SRS - 1)) { // End of OFDM symbol or last subcarrier cases
// filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0} // filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0}
multadd_real_vector_complex_scalar(filt16_end, ls_estimated, srs_estimated_channel16, 16); c16multaddVectRealComplex(filt16_end, &ls_estimated, srs_estimated_channel16, 16);
} else { // Middle case } else { // Middle case
// filt16_middle4 is {4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0} // filt16_middle4 is {4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0}
multadd_real_vector_complex_scalar(filt16_middle4, ls_estimated, srs_estimated_channel16, 16); c16multaddVectRealComplex(filt16_middle4, &ls_estimated, srs_estimated_channel16, 16);
srs_estimated_channel16 = (int16_t *)&srs_est[sc_offset]; srs_estimated_channel16 = (c16_t *)&srs_est[sc_offset];
} }
} }
...@@ -789,15 +768,14 @@ int nr_srs_channel_estimation( ...@@ -789,15 +768,14 @@ int nr_srs_channel_estimation(
if (subcarrier>frame_parms->ofdm_symbol_size) { if (subcarrier>frame_parms->ofdm_symbol_size) {
subcarrier -= frame_parms->ofdm_symbol_size; subcarrier -= frame_parms->ofdm_symbol_size;
} }
uint16_t base_idx = ant*N_ap*M_sc_b_SRS + p_index*M_sc_b_SRS; uint16_t base_idx = ant * N_ap * M_sc_b_SRS + p_index * M_sc_b_SRS;
for (int k = 0; k < M_sc_b_SRS; k++) { for (int k = 0; k < M_sc_b_SRS; k++) {
ch_real[base_idx+k] = ((c16_t*)srs_estimated_channel_freq[ant][p_index])[subcarrier].r; ch[base_idx + k] = ((c16_t *)srs_estimated_channel_freq[ant][p_index])[subcarrier];
ch_imag[base_idx+k] = ((c16_t*)srs_estimated_channel_freq[ant][p_index])[subcarrier].i; noise[base_idx + k].r = abs(srs_ls_estimated_channel[subcarrier].r - ch[base_idx + k].r);
noise_real[base_idx+k] = abs(srs_ls_estimated_channel[subcarrier].r - ch_real[base_idx+k]); noise[base_idx + k].i = abs(srs_ls_estimated_channel[subcarrier].i - ch[base_idx + k].i);
noise_imag[base_idx+k] = abs(srs_ls_estimated_channel[subcarrier].i - ch_imag[base_idx+k]);
subcarrier += K_TC; subcarrier += K_TC;
if (subcarrier >= frame_parms->ofdm_symbol_size) { if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier=subcarrier-frame_parms->ofdm_symbol_size; subcarrier = subcarrier - frame_parms->ofdm_symbol_size;
} }
} }
...@@ -823,9 +801,10 @@ int nr_srs_channel_estimation( ...@@ -823,9 +801,10 @@ int nr_srs_channel_estimation(
subcarrier_log, subcarrier_log,
srs_ls_estimated_channel[subcarrier].r, srs_ls_estimated_channel[subcarrier].r,
srs_ls_estimated_channel[subcarrier].i, srs_ls_estimated_channel[subcarrier].i,
((c16_t*)srs_estimated_channel_freq[ant][p_index])[subcarrier].r, ((c16_t *)srs_estimated_channel_freq[ant][p_index])[subcarrier].r,
((c16_t*)srs_estimated_channel_freq[ant][p_index])[subcarrier].i, ((c16_t *)srs_estimated_channel_freq[ant][p_index])[subcarrier].i,
noise_real[base_idx+(k/K_TC)], noise_imag[base_idx+(k/K_TC)]); noise[base_idx + (k / K_TC)].r,
noise[base_idx + (k / K_TC)].i);
// Subcarrier increment // Subcarrier increment
subcarrier++; subcarrier++;
...@@ -852,7 +831,7 @@ int nr_srs_channel_estimation( ...@@ -852,7 +831,7 @@ int nr_srs_channel_estimation(
} // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) } // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++)
// Compute signal power // Compute signal power
uint32_t signal_power = calc_power(ch_real, arr_len) + calc_power(ch_imag, arr_len); uint32_t signal_power = max(signal_energy_nodc(ch, arr_len), 1);
#ifdef SRS_DEBUG #ifdef SRS_DEBUG
LOG_I(NR_PHY,"signal_power = %u\n", signal_power); LOG_I(NR_PHY,"signal_power = %u\n", signal_power);
...@@ -864,11 +843,6 @@ int nr_srs_channel_estimation( ...@@ -864,11 +843,6 @@ int nr_srs_channel_estimation(
} }
// Compute noise power // Compute noise power
const uint8_t signal_power_bits = log2_approx(signal_power);
const uint8_t factor_bits = signal_power_bits < 32 ? 32 - signal_power_bits : 0; // 32 due to input of dB_fixed(uint32_t x)
const int32_t factor_dB = dB_fixed(1<<factor_bits);
const uint8_t srs_symbols_per_rb = srs_pdu->comb_size == 0 ? 6 : 3; const uint8_t srs_symbols_per_rb = srs_pdu->comb_size == 0 ? 6 : 3;
const uint8_t n_noise_est = frame_parms->nb_antennas_rx*N_ap*srs_symbols_per_rb; const uint8_t n_noise_est = frame_parms->nb_antennas_rx*N_ap*srs_symbols_per_rb;
uint64_t sum_re = 0; uint64_t sum_re = 0;
...@@ -885,19 +859,19 @@ int nr_srs_channel_estimation( ...@@ -885,19 +859,19 @@ int nr_srs_channel_estimation(
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
for (int p_index = 0; p_index < N_ap; p_index++) { for (int p_index = 0; p_index < N_ap; p_index++) {
uint16_t base_idx = ant*N_ap*M_sc_b_SRS + p_index*M_sc_b_SRS + rb*srs_symbols_per_rb; uint16_t base_idx = ant * N_ap * M_sc_b_SRS + p_index * M_sc_b_SRS + rb * srs_symbols_per_rb;
for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++) { for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++) {
sum_re = sum_re + noise_real[base_idx+srs_symb]; sum_re = sum_re + noise[base_idx + srs_symb].r;
sum_re2 = sum_re2 + noise_real[base_idx+srs_symb]*noise_real[base_idx+srs_symb]; sum_re2 = sum_re2 + noise[base_idx + srs_symb].r * noise[base_idx + srs_symb].r;
sum_im = sum_im + noise_imag[base_idx+srs_symb]; sum_im = sum_im + noise[base_idx + srs_symb].i;
sum_im2 = sum_im2 + noise_imag[base_idx+srs_symb]*noise_imag[base_idx+srs_symb]; sum_im2 = sum_im2 + noise[base_idx + srs_symb].i * noise[base_idx + srs_symb].i;
} // for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++) } // for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++)
} // for (int p_index = 0; p_index < N_ap; p_index++) } // for (int p_index = 0; p_index < N_ap; p_index++)
} // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) } // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++)
noise_power_per_rb[rb] = max(sum_re2 / n_noise_est - (sum_re / n_noise_est) * (sum_re / n_noise_est) + noise_power_per_rb[rb] = max(sum_re2 / n_noise_est - (sum_re / n_noise_est) * (sum_re / n_noise_est) +
sum_im2 / n_noise_est - (sum_im / n_noise_est) * (sum_im / n_noise_est), 1); sum_im2 / n_noise_est - (sum_im / n_noise_est) * (sum_im / n_noise_est), 1);
snr_per_rb[rb] = dB_fixed((int32_t)((signal_power<<factor_bits)/noise_power_per_rb[rb])) - factor_dB; snr_per_rb[rb] = dB_fixed(signal_power) - dB_fixed(noise_power_per_rb[rb]);
#ifdef SRS_DEBUG #ifdef SRS_DEBUG
LOG_I(NR_PHY,"noise_power_per_rb[%i] = %i, snr_per_rb[%i] = %i dB\n", rb, noise_power_per_rb[rb], rb, snr_per_rb[rb]); LOG_I(NR_PHY,"noise_power_per_rb[%i] = %i, snr_per_rb[%i] = %i dB\n", rb, noise_power_per_rb[rb], rb, snr_per_rb[rb]);
...@@ -905,9 +879,9 @@ int nr_srs_channel_estimation( ...@@ -905,9 +879,9 @@ int nr_srs_channel_estimation(
} // for (int rb = 0; rb < m_SRS_b; rb++) } // for (int rb = 0; rb < m_SRS_b; rb++)
const uint32_t noise_power = max(calc_power(noise_real, arr_len) + calc_power(noise_imag, arr_len), 1); const uint32_t noise_power = max(signal_energy_nodc(noise, arr_len), 1);
*snr = dB_fixed((int32_t)((signal_power<<factor_bits)/(noise_power))) - factor_dB; *snr = dB_fixed(signal_power) - dB_fixed(noise_power);
#ifdef SRS_DEBUG #ifdef SRS_DEBUG
LOG_I(NR_PHY,"noise_power = %u, SNR = %i dB\n", noise_power, *snr); LOG_I(NR_PHY,"noise_power = %u, SNR = %i dB\n", noise_power, *snr);
......
...@@ -111,7 +111,7 @@ int32_t signal_energy_amp_shift(int32_t *input,uint32_t length) ...@@ -111,7 +111,7 @@ int32_t signal_energy_amp_shift(int32_t *input,uint32_t length)
return((temp>0)?temp:1); return((temp>0)?temp:1);
} }
int32_t signal_energy_nodc(const c16_t *input, uint32_t length) uint32_t signal_energy_nodc(const c16_t *input, uint32_t length)
{ {
// init // init
simde__m128 mm0 = simde_mm_setzero_ps(); simde__m128 mm0 = simde_mm_setzero_ps();
...@@ -134,7 +134,7 @@ int32_t signal_energy_nodc(const c16_t *input, uint32_t length) ...@@ -134,7 +134,7 @@ int32_t signal_energy_nodc(const c16_t *input, uint32_t length)
// Ave // Ave
float sums[4]; float sums[4];
simde_mm_store_ps(sums, mm0); simde_mm_store_ps(sums, mm0);
return (int)((sums[0] + sums[1] + sums[2] + sums[3] + leftover_sum) / (float)length); return (uint32_t)((sums[0] + sums[1] + sums[2] + sums[3] + leftover_sum) / (float)length);
} }
double signal_energy_fp(double *s_re[2],double *s_im[2],uint32_t nb_antennas,uint32_t length,uint32_t offset) double signal_energy_fp(double *s_re[2],double *s_im[2],uint32_t nb_antennas,uint32_t length,uint32_t offset)
......
#include <gtest/gtest.h> #include <gtest/gtest.h>
extern "C" { extern "C" {
#include "openair1/PHY/TOOLS/tools_defs.h" #include "openair1/PHY/TOOLS/tools_defs.h"
extern int32_t signal_energy_nodc(const c16_t *input, uint32_t length); extern uint32_t signal_energy_nodc(const c16_t *input, uint32_t length);
} }
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
......
...@@ -758,10 +758,10 @@ int32_t signal_energy_amp_shift(int32_t *input, uint32_t length); ...@@ -758,10 +758,10 @@ int32_t signal_energy_amp_shift(int32_t *input, uint32_t length);
int32_t subcarrier_energy(int32_t *,uint32_t, int32_t *subcarrier_energy, uint16_t rx_power_correction); int32_t subcarrier_energy(int32_t *,uint32_t, int32_t *subcarrier_energy, uint16_t rx_power_correction);
#endif #endif
/*!\fn int32_t signal_energy_nodc(int32_t *,uint32_t); /*!\fn uint32_t signal_energy_nodc(c16_t *,uint32_t);
\brief Computes the signal energy per subcarrier, without DC removal \brief Computes the signal energy per subcarrier, without DC removal
*/ */
int32_t signal_energy_nodc(const c16_t *input, uint32_t length); uint32_t signal_energy_nodc(const c16_t *input, uint32_t length);
int32_t signal_power(int32_t *,uint32_t); int32_t signal_power(int32_t *,uint32_t);
int32_t interference_power(int32_t *,uint32_t); int32_t interference_power(int32_t *,uint32_t);
......
...@@ -729,8 +729,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) ...@@ -729,8 +729,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
const int soffset = (slot_rx & 3) * gNB->frame_parms.symbols_per_slot * gNB->frame_parms.ofdm_symbol_size; const int soffset = (slot_rx & 3) * gNB->frame_parms.symbols_per_slot * gNB->frame_parms.ofdm_symbol_size;
int offset = 10 * gNB->frame_parms.ofdm_symbol_size + gNB->frame_parms.first_carrier_offset; int offset = 10 * gNB->frame_parms.ofdm_symbol_size + gNB->frame_parms.first_carrier_offset;
LOG_D(PHY, LOG_D(NR_PHY,
"frame %d, slot %d: UL signal energy %d\n", "frame %d, slot %d: UL signal energy %u\n",
frame_rx, frame_rx,
slot_rx, slot_rx,
signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset + offset + (47 * 12)], 12 * 18)); signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset + offset + (47 * 12)], 12 * 18));
...@@ -761,8 +761,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) ...@@ -761,8 +761,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_0_1; nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_0_1;
offset = pucch_pdu->start_symbol_index*gNB->frame_parms.ofdm_symbol_size + (gNB->frame_parms.first_carrier_offset+pucch_pdu->prb_start*12); offset = pucch_pdu->start_symbol_index*gNB->frame_parms.ofdm_symbol_size + (gNB->frame_parms.first_carrier_offset+pucch_pdu->prb_start*12);
LOG_D(PHY, LOG_D(NR_PHY,
"frame %d, slot %d: PUCCH signal energy %d\n", "frame %d, slot %d: PUCCH signal energy %u\n",
frame_rx, frame_rx,
slot_rx, slot_rx,
signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset + offset], 12)); signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset + offset], 12));
......
...@@ -723,7 +723,7 @@ int main(int argc, char *argv[]) ...@@ -723,7 +723,7 @@ int main(int argc, char *argv[])
NR_gNB_ULSCH_t *ulsch_gNB = &gNB->ulsch[UE_id]; NR_gNB_ULSCH_t *ulsch_gNB = &gNB->ulsch[UE_id];
NR_Sched_Rsp_t *Sched_INFO = malloc(sizeof(*Sched_INFO)); NR_Sched_Rsp_t *Sched_INFO = malloc16_clear(sizeof(*Sched_INFO));
memset((void*)Sched_INFO,0,sizeof(*Sched_INFO)); memset((void*)Sched_INFO,0,sizeof(*Sched_INFO));
nfapi_nr_ul_tti_request_t *UL_tti_req = &Sched_INFO->UL_tti_req; nfapi_nr_ul_tti_request_t *UL_tti_req = &Sched_INFO->UL_tti_req;
Sched_INFO->sched_response_id = -1; Sched_INFO->sched_response_id = -1;
...@@ -1070,6 +1070,7 @@ int main(int argc, char *argv[]) ...@@ -1070,6 +1070,7 @@ int main(int argc, char *argv[])
srs_pdu->subcarrier_spacing = frame_parms->subcarrier_spacing; srs_pdu->subcarrier_spacing = frame_parms->subcarrier_spacing;
srs_pdu->num_ant_ports = n_tx == 4 ? 2 : n_tx == 2 ? 1 : 0; srs_pdu->num_ant_ports = n_tx == 4 ? 2 : n_tx == 2 ? 1 : 0;
srs_pdu->sequence_id = 40; srs_pdu->sequence_id = 40;
srs_pdu->time_start_position = frame_parms->symbols_per_slot - 1;
srs_pdu->config_index = rrc_get_max_nr_csrs(srs_pdu->bwp_size, srs_pdu->bandwidth_index); srs_pdu->config_index = rrc_get_max_nr_csrs(srs_pdu->bwp_size, srs_pdu->bandwidth_index);
srs_pdu->resource_type = NR_SRS_Resource__resourceType_PR_periodic; srs_pdu->resource_type = NR_SRS_Resource__resourceType_PR_periodic;
srs_pdu->t_srs = 1; srs_pdu->t_srs = 1;
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
{CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=100, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=100, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=150, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=150, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=50, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=50, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_SRS_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=50, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_SRS_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=30, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_MAX_LDPC_ITERATIONS, NULL, 0, .uptr=NULL, .defintval=8, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_MAX_LDPC_ITERATIONS, NULL, 0, .uptr=NULL, .defintval=8, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_RX_THREAD_CORE, NULL, 0, .uptr=NULL, .defintval=-1, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_RX_THREAD_CORE, NULL, 0, .uptr=NULL, .defintval=-1, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_TX_THREAD_CORE, NULL, 0, .uptr=NULL, .defintval=-1, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_TX_THREAD_CORE, NULL, 0, .uptr=NULL, .defintval=-1, TYPE_UINT, 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