From 2bf7c2500e387c9afd34dae0e405e6341c575543 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Thu, 18 Sep 2025 16:50:41 +0100 Subject: [PATCH] Simplifying bit shift in the nr_scale_channel() function --- .../PHY/nr_phy_common/src/nr_phy_common.c | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/openair1/PHY/nr_phy_common/src/nr_phy_common.c b/openair1/PHY/nr_phy_common/src/nr_phy_common.c index aacabeed3b..a723780f94 100644 --- a/openair1/PHY/nr_phy_common/src/nr_phy_common.c +++ b/openair1/PHY/nr_phy_common/src/nr_phy_common.c @@ -427,34 +427,18 @@ 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) { - // 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 channel est in OFDM symbol %d by %d\n", symb, ch_amp); - 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_mulhi_epi16(ul_ch128[i], ch_amp128); - ul_ch128[i] = simde_mm_slli_epi16(ul_ch128[i], b); + 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, b); + *temp = c16Shift(*temp, shift_ch_ext); } } }