|
|
|
@@ -1096,7 +1096,7 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
|
|
|
|
|
int32_t **srs_estimated_channel_time_shifted,
|
|
|
|
|
uint32_t *noise_power) {
|
|
|
|
|
|
|
|
|
|
if(nr_srs_info->n_symbs==0) {
|
|
|
|
|
if(nr_srs_info->sc_list_length == 0) {
|
|
|
|
|
LOG_E(NR_PHY, "(%d.%d) nr_srs_info was not generated yet!\n", frame, slot);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@@ -1104,8 +1104,8 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
|
|
|
|
|
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
|
|
|
|
|
int32_t **srs_ls_estimated_channel = nr_srs_info->srs_ls_estimated_channel;
|
|
|
|
|
|
|
|
|
|
uint16_t noise_real[frame_parms->nb_antennas_rx*nr_srs_info->n_symbs];
|
|
|
|
|
uint16_t noise_imag[frame_parms->nb_antennas_rx*nr_srs_info->n_symbs];
|
|
|
|
|
uint16_t noise_real[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length];
|
|
|
|
|
uint16_t noise_imag[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length];
|
|
|
|
|
|
|
|
|
|
int16_t prev_ls_estimated[2];
|
|
|
|
|
int16_t ls_estimated[2];
|
|
|
|
@@ -1115,23 +1115,23 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
|
|
|
|
|
memset(srs_ls_estimated_channel[ant], 0, frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols)*sizeof(int32_t));
|
|
|
|
|
memset(srs_estimated_channel_freq[ant], 0, frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols)*sizeof(int32_t));
|
|
|
|
|
|
|
|
|
|
int16_t *srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[0]];
|
|
|
|
|
int16_t *srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[0]];
|
|
|
|
|
|
|
|
|
|
for(int sc_idx = 0; sc_idx < nr_srs_info->n_symbs; sc_idx++) {
|
|
|
|
|
for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) {
|
|
|
|
|
|
|
|
|
|
int16_t generated_real = srs_generated_signal[nr_srs_info->subcarrier_idx[sc_idx]]&0xFFFF;
|
|
|
|
|
int16_t generated_imag = (srs_generated_signal[nr_srs_info->subcarrier_idx[sc_idx]]>>16)&0xFFFF;
|
|
|
|
|
int16_t generated_real = srs_generated_signal[nr_srs_info->sc_list[sc_idx]] & 0xFFFF;
|
|
|
|
|
int16_t generated_imag = (srs_generated_signal[nr_srs_info->sc_list[sc_idx]] >> 16) & 0xFFFF;
|
|
|
|
|
|
|
|
|
|
int16_t received_real = srs_received_signal[ant][nr_srs_info->subcarrier_idx[sc_idx]]&0xFFFF;
|
|
|
|
|
int16_t received_imag = (srs_received_signal[ant][nr_srs_info->subcarrier_idx[sc_idx]]>>16)&0xFFFF;
|
|
|
|
|
int16_t received_real = srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]] & 0xFFFF;
|
|
|
|
|
int16_t received_imag = (srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]] >> 16) & 0xFFFF;
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
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[1] = (int16_t)(((int32_t)generated_real*received_imag - (int32_t)generated_imag*received_real)>>nr_srs_info->srs_generated_signal_bits);
|
|
|
|
|
srs_ls_estimated_channel[ant][nr_srs_info->subcarrier_idx[sc_idx]] = ls_estimated[0] + (((int32_t)ls_estimated[1]<<16)&0xFFFF0000);
|
|
|
|
|
srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]] = ls_estimated[0] + (((int32_t)ls_estimated[1] << 16) & 0xFFFF0000);
|
|
|
|
|
|
|
|
|
|
if(sc_idx>0 && nr_srs_info->subcarrier_idx[sc_idx]>nr_srs_info->subcarrier_idx[sc_idx-1]) {
|
|
|
|
|
if(sc_idx>0 && nr_srs_info->sc_list[sc_idx] > nr_srs_info->sc_list[sc_idx - 1]) {
|
|
|
|
|
ls_estimated[0] = (ls_estimated[0] + prev_ls_estimated[0])>>1;
|
|
|
|
|
ls_estimated[1] = (ls_estimated[1] + prev_ls_estimated[1])>>1;
|
|
|
|
|
}
|
|
|
|
@@ -1142,43 +1142,43 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
|
|
|
|
|
if(srs_pdu->comb_size == 0) {
|
|
|
|
|
if(sc_idx == 0) {
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_l0, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
} else if(nr_srs_info->subcarrier_idx[sc_idx]<nr_srs_info->subcarrier_idx[sc_idx-1]) {
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx+2]] - 8;
|
|
|
|
|
} else if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) {
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx + 2]] - 8;
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_l0, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
} else if( (sc_idx < (nr_srs_info->n_symbs-1) && nr_srs_info->subcarrier_idx[sc_idx+1]<nr_srs_info->subcarrier_idx[sc_idx]) || (sc_idx == (nr_srs_info->n_symbs-1))) {
|
|
|
|
|
} else if((sc_idx < (nr_srs_info->sc_list_length - 1) && nr_srs_info->sc_list[sc_idx + 1] < nr_srs_info->sc_list[sc_idx]) || (sc_idx == (nr_srs_info->sc_list_length - 1))) {
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_m0, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]+1] = srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]];
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx] + 1] = srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]];
|
|
|
|
|
} else if(sc_idx%2 == 1) {
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_m0, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
} else if(sc_idx%2 == 0) {
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_mm0, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]];
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(sc_idx>0) {
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_dcr0_h, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
if(nr_srs_info->subcarrier_idx[sc_idx]<nr_srs_info->subcarrier_idx[sc_idx-1]) {
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx+1]] - 8;
|
|
|
|
|
if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) {
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx + 1]] - 8;
|
|
|
|
|
} else {
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]];
|
|
|
|
|
srs_estimated_channel16 = (int16_t *)&srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]];
|
|
|
|
|
}
|
|
|
|
|
srs_estimated_channel16[0] = 0;
|
|
|
|
|
srs_estimated_channel16[1] = 0;
|
|
|
|
|
}
|
|
|
|
|
multadd_real_vector_complex_scalar(filt8_dcl0_h, ls_estimated, srs_estimated_channel16, 8);
|
|
|
|
|
if(sc_idx == (nr_srs_info->n_symbs-1)) {
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]+1] = srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]];
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]+2] = srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]];
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]+3] = srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]];
|
|
|
|
|
if(sc_idx == (nr_srs_info->sc_list_length - 1)) {
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx] + 1] = srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]];
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx] + 2] = srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]];
|
|
|
|
|
srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx] + 3] = srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
noise_real[ant*nr_srs_info->n_symbs+sc_idx] = abs(prev_ls_estimated[0] - (int16_t)(srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]]&0xFFFF));
|
|
|
|
|
noise_imag[ant*nr_srs_info->n_symbs+sc_idx] = abs(prev_ls_estimated[1] - (int16_t)((srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]]>>16)&0xFFFF));
|
|
|
|
|
noise_real[ant*nr_srs_info->sc_list_length + sc_idx] = abs(prev_ls_estimated[0] - (int16_t)(srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]] & 0xFFFF));
|
|
|
|
|
noise_imag[ant*nr_srs_info->sc_list_length + sc_idx] = abs(prev_ls_estimated[1] - (int16_t)((srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]] >> 16) & 0xFFFF));
|
|
|
|
|
|
|
|
|
|
#ifdef SRS_DEBUG
|
|
|
|
|
uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12;
|
|
|
|
|
int subcarrier_log = nr_srs_info->subcarrier_idx[sc_idx]-subcarrier_offset;
|
|
|
|
|
int subcarrier_log = nr_srs_info->sc_list[sc_idx]-subcarrier_offset;
|
|
|
|
|
if(subcarrier_log < 0) {
|
|
|
|
|
subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size;
|
|
|
|
|
}
|
|
|
|
@@ -1211,15 +1211,15 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
|
|
|
|
|
(gNB->frame_parms.ofdm_symbol_size>>1)*sizeof(int32_t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*noise_power = calc_power(noise_real,frame_parms->nb_antennas_rx*nr_srs_info->n_symbs)
|
|
|
|
|
+ calc_power(noise_imag,frame_parms->nb_antennas_rx*nr_srs_info->n_symbs);
|
|
|
|
|
*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);
|
|
|
|
|
|
|
|
|
|
#ifdef SRS_DEBUG
|
|
|
|
|
uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12;
|
|
|
|
|
uint8_t R = srs_pdu->comb_size == 0 ? 2 : 4;
|
|
|
|
|
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
|
|
|
|
|
for(int sc_idx = 0; sc_idx < nr_srs_info->n_symbs; sc_idx++) {
|
|
|
|
|
int subcarrier_log = nr_srs_info->subcarrier_idx[sc_idx]-subcarrier_offset;
|
|
|
|
|
for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) {
|
|
|
|
|
int subcarrier_log = nr_srs_info->sc_list[sc_idx]-subcarrier_offset;
|
|
|
|
|
if(subcarrier_log < 0) {
|
|
|
|
|
subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size;
|
|
|
|
|
}
|
|
|
|
@@ -1233,12 +1233,12 @@ int nr_srs_channel_estimation(PHY_VARS_gNB *gNB,
|
|
|
|
|
for(int r = 0; r<R; r++) {
|
|
|
|
|
LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n",
|
|
|
|
|
subcarrier_log+r,
|
|
|
|
|
(int16_t)(srs_ls_estimated_channel[ant][nr_srs_info->subcarrier_idx[sc_idx]+r]&0xFFFF),
|
|
|
|
|
(int16_t)((srs_ls_estimated_channel[ant][nr_srs_info->subcarrier_idx[sc_idx]+r]>>16)&0xFFFF),
|
|
|
|
|
(int16_t)(srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]+r]&0xFFFF),
|
|
|
|
|
(int16_t)((srs_estimated_channel_freq[ant][nr_srs_info->subcarrier_idx[sc_idx]+r]>>16)&0xFFFF),
|
|
|
|
|
noise_real[ant*nr_srs_info->n_symbs+sc_idx],
|
|
|
|
|
noise_imag[ant*nr_srs_info->n_symbs+sc_idx]);
|
|
|
|
|
(int16_t)(srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]+r]&0xFFFF),
|
|
|
|
|
(int16_t)((srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]+r]>>16)&0xFFFF),
|
|
|
|
|
(int16_t)(srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]+r]&0xFFFF),
|
|
|
|
|
(int16_t)((srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]+r]>>16)&0xFFFF),
|
|
|
|
|
noise_real[ant*nr_srs_info->sc_list_length+sc_idx],
|
|
|
|
|
noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|