Merge remote-tracking branch 'origin/common_scale_function' into integration_2025_w42 (!3608)

use common scale channel functions for DLSCH and ULSCH

Follow up of !3035
This commit is contained in:
Robert Schmidt
2025-10-15 08:34:37 +02:00
5 changed files with 28 additions and 103 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ populates UL_INFO.uci_ind, actual uci data is in gNB->pucch
{: .func4}
* nr_ulsch_extract_rbs_single()
{: .func4}
* nr_ulsch_scale_channel()
* nr_scale_channel()
{: .func4}
* nr_ulsch_channel_level()
{: .func4}
@@ -159,42 +159,6 @@ static void nr_ulsch_extract_rbs(c16_t* const rxdataF,
}
}
static void nr_ulsch_scale_channel(int size_est,
int ul_ch_estimates_ext[][size_est],
NR_DL_FRAME_PARMS *frame_parms,
uint8_t symbol,
uint8_t is_dmrs_symbol,
uint32_t len,
uint8_t nrOfLayers,
unsigned short nb_rb,
int shift_ch_ext)
{
// Determine scaling amplitude based the symbol
int b = 3;
short ch_amp = 1024 * 8;
if (shift_ch_ext > 3) {
b = 0;
ch_amp >>= (shift_ch_ext - 3);
if (ch_amp == 0) {
ch_amp = 1;
}
} else {
b -= shift_ch_ext;
}
simde__m128i ch_amp128 = simde_mm_set1_epi16(ch_amp); // Q3.13
LOG_D(PHY, "Scaling PUSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n", symbol, ch_amp, is_dmrs_symbol, nb_rb, frame_parms->Ncp, symbol);
for (int aatx = 0; aatx < nrOfLayers; aatx++) {
for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
simde__m128i *ul_ch128 = (simde__m128i *)&ul_ch_estimates_ext[aatx * frame_parms->nb_antennas_rx + aarx][symbol * len];
for (int i = 0; i < len >> 2; i++) {
ul_ch128[i] = simde_mm_mulhi_epi16(ul_ch128[i], ch_amp128);
ul_ch128[i] = simde_mm_slli_epi16(ul_ch128[i], b);
}
}
}
}
static int get_nb_re_pusch (NR_DL_FRAME_PARMS *frame_parms, nfapi_nr_pusch_pdu_t *rel15_ul,int symbol)
{
uint8_t dmrs_symbol_flag = (rel15_ul->ul_dmrs_symb_pos >> symbol) & 0x01;
@@ -1375,14 +1339,12 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB,
//----------------------------------------------------------
//--------------------- Channel Scaling --------------------
//----------------------------------------------------------
nr_ulsch_scale_channel(size_est,
nr_scale_channel(size_est,
ul_ch_estimates_ext,
frame_parms,
meas_symbol,
(rel15_ul->ul_dmrs_symb_pos >> meas_symbol) & 0x01,
nb_re_pusch,
rel15_ul->nrOfLayers,
rel15_ul->rb_size,
frame_parms->nb_antennas_rx,
shift_ch_ext);
int avg[frame_parms->nb_antennas_rx*rel15_ul->nrOfLayers];
@@ -193,15 +193,6 @@ static void nr_dlsch_channel_compensation(uint32_t rx_size_symbol,
unsigned char output_shift,
PHY_NR_MEASUREMENTS *measurements);
void nr_dlsch_scale_channel(uint32_t rx_size_symbol,
int32_t dl_ch_estimates_ext[][rx_size_symbol],
NR_DL_FRAME_PARMS *frame_parms,
uint8_t n_tx,
uint8_t n_rx,
uint8_t symbol,
uint8_t pilots,
uint32_t len,
unsigned short nb_rb);
static void nr_dlsch_detection_mrc(uint32_t rx_size_symbol,
short nl,
short n_rx,
@@ -508,7 +499,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
//--------------------- Channel Scaling --------------------
//----------------------------------------------------------
start_meas_nr_ue_phy(ue, DLSCH_CHANNEL_SCALE_STATS);
nr_dlsch_scale_channel(rx_size_symbol, dl_ch_estimates_ext, fp, nl, n_rx, symbol, pilots, nb_re_pdsch, nb_rb_pdsch);
nr_scale_channel(rx_size_symbol, dl_ch_estimates_ext, 0, nb_re_pdsch, nl, n_rx, 0);
stop_meas_nr_ue_phy(ue, DLSCH_CHANNEL_SCALE_STATS);
if (meas_enabled) {
LOG_D(PHY,
@@ -921,53 +912,6 @@ static void nr_dlsch_channel_compensation(uint32_t rx_size_symbol,
}
}
void nr_dlsch_scale_channel(uint32_t rx_size_symbol,
int32_t dl_ch_estimates_ext[][rx_size_symbol],
NR_DL_FRAME_PARMS *fp,
uint8_t n_tx,
uint8_t n_rx,
uint8_t symbol,
uint8_t pilots,
uint32_t len,
unsigned short nb_rb)
{
short rb, ch_amp;
unsigned char aatx,aarx;
simde__m128i *dl_ch128, ch_amp128;
uint32_t nb_rb_0 = len/12 + ((len%12)?1:0);
// Determine scaling amplitude based the symbol
ch_amp = 1024 * 8; //((pilots) ? (dlsch_ue[0]->sqrt_rho_b) : (dlsch_ue[0]->sqrt_rho_a));
LOG_D(PHY,
"Scaling PDSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n",
symbol,
ch_amp,
pilots,
nb_rb,
fp->Ncp,
symbol);
// printf("Scaling PDSCH Chest in OFDM symbol %d by %d\n",symbol_mod,ch_amp);
ch_amp128 = simde_mm_set1_epi16(ch_amp); // Q3.13
for (aatx=0; aatx<n_tx; aatx++) {
for (aarx=0; aarx<n_rx; aarx++) {
dl_ch128=(simde__m128i *)dl_ch_estimates_ext[(aatx*n_rx)+aarx];
for (rb=0;rb<nb_rb_0;rb++) {
dl_ch128[0] = simde_mm_mulhi_epi16(dl_ch128[0], ch_amp128);
dl_ch128[0] = simde_mm_slli_epi16(dl_ch128[0], 3);
dl_ch128[1] = simde_mm_mulhi_epi16(dl_ch128[1], ch_amp128);
dl_ch128[1] = simde_mm_slli_epi16(dl_ch128[1], 3);
dl_ch128[2] = simde_mm_mulhi_epi16(dl_ch128[2], ch_amp128);
dl_ch128[2] = simde_mm_slli_epi16(dl_ch128[2], 3);
dl_ch128+=3;
}
}
}
}
static void nr_dlsch_channel_level_median(uint32_t rx_size_symbol,
int32_t dl_ch_estimates_ext[][rx_size_symbol],
int32_t median[MAX_ANT][MAX_ANT],
@@ -364,6 +364,7 @@ void nr_channel_level(const int symbol,
const int Nl,
int32_t avg[nb_rx * Nl],
const uint32_t len);
void nr_scale_channel(int size, int ch_estimates_ext[][size], int symb, uint32_t len, int nrOfLayers, int nb_rx, int shift_ch_ext);
bool generate_srs_nr(NR_DL_FRAME_PARMS *frame_parms,
c16_t **txdataF,
uint16_t symbol_offset,
@@ -425,6 +425,24 @@ void nr_channel_level(const int symbol,
}
}
void nr_scale_channel(int size, int ch_estimates_ext[][size], int symb, uint32_t len, int nrOfLayers, int nb_rx, int shift_ch_ext)
{
for (int l = 0; l < nrOfLayers; l++) {
for (int aarx = 0; aarx < nb_rx; aarx++) {
simde__m128i *ul_ch128 = (simde__m128i *)&ch_estimates_ext[l * nb_rx + aarx][symb * len];
int loop_end = len >> 2;
for (int i = 0; i < loop_end; i++) {
ul_ch128[i] = simde_mm_srai_epi16(ul_ch128[i], shift_ch_ext);
}
// loop for the remaining elements
int start_index = loop_end * 4;
for (int j = start_index; j < len; j++) {
c16_t *temp = ((c16_t *)ul_ch128) + j;
*temp = c16Shift(*temp, shift_ch_ext);
}
}
}
}
void nr_fo_compensation(double fo_Hz, int samples_per_ms, int sample_offset, const c16_t *rxdata_in, c16_t *rxdata_out, int size)
{