Commit 7e009781 authored by francescomani's avatar francescomani

moving out CSI mapping parameters from nr_generate_csi_rs

parent ad96697d
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "PHY/defs_gNB.h" #include "PHY/defs_gNB.h"
#include "openair1/PHY/NR_REFSIG/nr_refsig_common.h" #include "openair1/PHY/NR_REFSIG/nr_refsig_common.h"
#include "PHY/nr_phy_common/inc/nr_phy_common.h"
int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB,
unsigned int Ns, unsigned int Ns,
...@@ -43,14 +44,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -43,14 +44,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
nr_csi_info_t *nr_csi_info, nr_csi_info_t *nr_csi_info,
const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params,
const int slot, const int slot,
uint8_t *N_cdm_groups, const csi_mapping_parms_t *phy_csi_parms);
uint8_t *CDM_group_size,
uint8_t *k_prime,
uint8_t *l_prime,
uint8_t *N_ports,
uint8_t *j_cdm,
uint8_t *k_overline,
uint8_t *l_overline);
void init_scrambling_luts(void); void init_scrambling_luts(void);
void nr_generate_modulation_table(void); void nr_generate_modulation_table(void);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "PHY/MODULATION/nr_modulation.h" #include "PHY/MODULATION/nr_modulation.h"
#include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/NR_REFSIG/nr_refsig.h"
#include "PHY/nr_phy_common/inc/nr_phy_common.h"
//#define NR_CSIRS_DEBUG //#define NR_CSIRS_DEBUG
...@@ -31,14 +30,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -31,14 +30,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
nr_csi_info_t *nr_csi_info, nr_csi_info_t *nr_csi_info,
const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params, const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params,
const int slot, const int slot,
uint8_t *N_cdm_groups, const csi_mapping_parms_t *phy_csi_parms)
uint8_t *CDM_group_size,
uint8_t *k_prime,
uint8_t *l_prime,
uint8_t *N_ports,
uint8_t *j_cdm,
uint8_t *k_overline,
uint8_t *l_overline)
{ {
#ifdef NR_CSIRS_DEBUG #ifdef NR_CSIRS_DEBUG
LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing); LOG_I(NR_PHY, "csi_params->subcarrier_spacing = %i\n", csi_params->subcarrier_spacing);
...@@ -64,11 +56,6 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -64,11 +56,6 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
uint32_t beta = amp; uint32_t beta = amp;
nr_csi_info->csi_rs_generated_signal_bits = log2_approx(amp); nr_csi_info->csi_rs_generated_signal_bits = log2_approx(amp);
csi_mapping_parms_t phy_csi_parms = get_csi_mapping_parms(csi_params->row,
csi_params->freq_domain,
csi_params->symb_l0,
csi_params->symb_l1);
// setting the frequency density from its index // setting the frequency density from its index
double rho = 0; double rho = 0;
switch (csi_params->freq_density) { switch (csi_params->freq_density) {
...@@ -89,7 +76,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -89,7 +76,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
} }
double alpha = 0; double alpha = 0;
if (phy_csi_parms.ports == 1) if (phy_csi_parms->ports == 1)
alpha = rho; alpha = rho;
else else
alpha = 2 * rho; alpha = 2 * rho;
...@@ -99,25 +86,9 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -99,25 +86,9 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
#endif #endif
// CDM group size from CDM type index // CDM group size from CDM type index
int gs = 0; int gs = get_cdm_group_size(csi_params->cdm_type);
switch (csi_params->cdm_type) {
case 0:
gs = 1;
break;
case 1:
gs = 2;
break;
case 2:
gs = 4;
break;
case 3:
gs = 8;
break;
default:
AssertFatal(false, "Invalid cdm type index for CSI\n");
}
int kprime = phy_csi_parms.kprime; int kprime = phy_csi_parms->kprime;
int csi_length; int csi_length;
if (rho < 1) { if (rho < 1) {
if (csi_params->freq_density == 0) { if (csi_params->freq_density == 0) {
...@@ -133,59 +104,19 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -133,59 +104,19 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
printf(" start rb %d, nr of rbs %d, csi length %d\n", csi_params->start_rb, csi_params->nr_of_rbs, csi_length); printf(" start rb %d, nr of rbs %d, csi length %d\n", csi_params->start_rb, csi_params->nr_of_rbs, csi_length);
#endif #endif
if (N_cdm_groups)
*N_cdm_groups = phy_csi_parms.size;
if (CDM_group_size)
*CDM_group_size = gs;
if (k_prime)
*k_prime = kprime;
if (l_prime)
*l_prime = phy_csi_parms.lprime;
if (N_ports)
*N_ports = phy_csi_parms.ports;
if (j_cdm)
memcpy(j_cdm, phy_csi_parms.j, 16 * sizeof(uint8_t));
if (k_overline)
memcpy(k_overline, phy_csi_parms.koverline, 16 * sizeof(uint8_t));
if (l_overline)
memcpy(l_overline, phy_csi_parms.loverline, 16 * sizeof(uint8_t));
#ifdef NR_CSIRS_DEBUG
if (N_ports)
LOG_I(NR_PHY, "nr_csi_info->N_ports = %d\n", *N_ports);
if (N_cdm_groups)
LOG_I(NR_PHY, "nr_csi_info->N_cdm_groups = %d\n", *N_cdm_groups);
if (CDM_group_size)
LOG_I(NR_PHY, "nr_csi_info->CDM_group_size = %d\n", *CDM_group_size);
if (k_prime)
LOG_I(NR_PHY, "nr_csi_info->kprime = %d\n", *k_prime);
if (l_prime)
LOG_I(NR_PHY, "nr_csi_info->lprime = %d\n", *l_prime);
if (N_cdm_groups) {
for(int ji = 0; ji < *N_cdm_groups; ji++) {
LOG_I(NR_PHY,
"(CDM group %d) j = %d, koverline = %d, loverline = %d\n",
ji,
phy_csi_parms.j[ji],
phy_csi_parms.koverline[ji],
phy_csi_parms.loverline[ji]);
}
}
#endif
if (csi_params->csi_type == 2) // ZP-CSI if (csi_params->csi_type == 2) // ZP-CSI
return; return;
// assuming amp is the amplitude of SSB channels // assuming amp is the amplitude of SSB channels
switch (csi_params->power_control_offset_ss) { switch (csi_params->power_control_offset_ss) {
case 0: case 0:
beta = (amp*ONE_OVER_SQRT2_Q15)>>15; beta = (amp * ONE_OVER_SQRT2_Q15) >> 15;
break; break;
case 1: case 1:
beta = amp; beta = amp;
break; break;
case 2: case 2:
beta = (amp*ONE_OVER_SQRT2_Q15)>>14; beta = (amp * ONE_OVER_SQRT2_Q15) >> 14;
break; break;
case 3: case 3:
beta = amp << 1; beta = amp << 1;
...@@ -194,7 +125,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -194,7 +125,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
AssertFatal(false, "Invalid SS power offset density index for CSI\n"); AssertFatal(false, "Invalid SS power offset density index for CSI\n");
} }
for (int lp = 0; lp <= phy_csi_parms.lprime; lp++) { for (int lp = 0; lp <= phy_csi_parms->lprime; lp++) {
int symb = csi_params->symb_l0; int symb = csi_params->symb_l0;
const uint32_t *gold = const uint32_t *gold =
nr_gold_csi_rs(frame_parms->N_RB_DL, frame_parms->symbols_per_slot, slot, symb + lp, csi_params->scramb_id); nr_gold_csi_rs(frame_parms->N_RB_DL, frame_parms->symbols_per_slot, slot, symb + lp, csi_params->scramb_id);
...@@ -222,25 +153,25 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, ...@@ -222,25 +153,25 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
// resource mapping according to 38.211 7.4.1.5.3 // resource mapping according to 38.211 7.4.1.5.3
for (int n = csi_params->start_rb; n < (csi_params->start_rb + csi_params->nr_of_rbs); n++) { for (int n = csi_params->start_rb; n < (csi_params->start_rb + csi_params->nr_of_rbs); n++) {
if ((csi_params->freq_density > 1) || (csi_params->freq_density == (n % 2))) { // for freq density 0.5 checks if even or odd RB if ((csi_params->freq_density > 1) || (csi_params->freq_density == (n % 2))) { // for freq density 0.5 checks if even or odd RB
for (int ji = 0; ji < phy_csi_parms.size; ji++) { // loop over CDM groups for (int ji = 0; ji < phy_csi_parms->size; ji++) { // loop over CDM groups
for (int s = 0 ; s < gs; s++) { // loop over each CDM group size for (int s = 0 ; s < gs; s++) { // loop over each CDM group size
int p = s + phy_csi_parms.j[ji] * gs; // port index int p = s + phy_csi_parms->j[ji] * gs; // port index
for (int kp = 0; kp <= kprime; kp++) { // loop over frequency resource elements within a group for (int kp = 0; kp <= kprime; kp++) { // loop over frequency resource elements within a group
// frequency index of current resource element // frequency index of current resource element
int k = (start_sc + (n * NR_NB_SC_PER_RB) + phy_csi_parms.koverline[ji] + kp) % (frame_parms->ofdm_symbol_size); int k = (start_sc + (n * NR_NB_SC_PER_RB) + phy_csi_parms->koverline[ji] + kp) % (frame_parms->ofdm_symbol_size);
// wf according to tables 7.4.5.3-2 to 7.4.5.3-5 // wf according to tables 7.4.5.3-2 to 7.4.5.3-5
int wf = kp == 0 ? 1 : (-2 * (s % 2) + 1); int wf = kp == 0 ? 1 : (-2 * (s % 2) + 1);
int na = n * alpha; int na = n * alpha;
int kpn = (rho * phy_csi_parms.koverline[ji]) / NR_NB_SC_PER_RB; int kpn = (rho * phy_csi_parms->koverline[ji]) / NR_NB_SC_PER_RB;
int mprime = na + kp + kpn; // sequence index int mprime = na + kp + kpn; // sequence index
for (int lp = 0; lp <= phy_csi_parms.lprime; lp++) { // loop over frequency resource elements within a group for (int lp = 0; lp <= phy_csi_parms->lprime; lp++) { // loop over frequency resource elements within a group
int l = lp + phy_csi_parms.loverline[ji]; int l = lp + phy_csi_parms->loverline[ji];
// wt according to tables 7.4.5.3-2 to 7.4.5.3-5 // wt according to tables 7.4.5.3-2 to 7.4.5.3-5
int wt; int wt;
if (s < 2) if (s < 2)
wt = 1; wt = 1;
else if (s < 4) else if (s < 4)
wt = -2*(lp % 2) + 1; wt = -2 * (lp % 2) + 1;
else if (s < 6) else if (s < 6)
wt = -2 * (lp / 2) + 1; wt = -2 * (lp / 2) + 1;
else { else {
......
...@@ -177,21 +177,16 @@ bool is_csi_rs_in_symbol(const fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_ ...@@ -177,21 +177,16 @@ bool is_csi_rs_in_symbol(const fapi_nr_dl_config_csirs_pdu_rel15_t csirs_config_
return ret; return ret;
} }
int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, static int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue,
const UE_nr_rxtx_proc_t *proc, const UE_nr_rxtx_proc_t *proc,
const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu,
const nr_csi_info_t *nr_csi_info, const nr_csi_info_t *nr_csi_info,
const uint8_t N_cdm_groups, const csi_mapping_parms_t *csi_mapping,
const uint8_t CDM_group_size, const int CDM_group_size,
const uint8_t k_prime, int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP],
const uint8_t l_prime, uint32_t *rsrp,
const uint8_t *j_cdm, int *rsrp_dBm,
const uint8_t *k_overline, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
const uint8_t *l_overline,
int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP],
uint32_t *rsrp,
int *rsrp_dBm,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
{ {
const NR_DL_FRAME_PARMS *fp = &ue->frame_parms; const NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
uint16_t meas_count = 0; uint16_t meas_count = 0;
...@@ -206,17 +201,17 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, ...@@ -206,17 +201,17 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue,
continue; continue;
} }
for (int cdm_id = 0; cdm_id < N_cdm_groups; cdm_id++) { for (int cdm_id = 0; cdm_id < csi_mapping->size; cdm_id++) {
for (int s = 0; s < CDM_group_size; s++) { for (int s = 0; s < CDM_group_size; s++) {
// loop over frequency resource elements within a group // loop over frequency resource elements within a group
for (int kp = 0; kp <= k_prime; kp++) { for (int kp = 0; kp <= csi_mapping->kprime; kp++) {
uint16_t k = (fp->first_carrier_offset + (rb * NR_NB_SC_PER_RB) + k_overline[cdm_id] + kp) % fp->ofdm_symbol_size; uint16_t k = (fp->first_carrier_offset + (rb * NR_NB_SC_PER_RB) + csi_mapping->koverline[cdm_id] + kp) % fp->ofdm_symbol_size;
// loop over time resource elements within a group // loop over time resource elements within a group
for (int lp = 0; lp <= l_prime; lp++) { for (int lp = 0; lp <= csi_mapping->lprime; lp++) {
uint16_t symb = lp + l_overline[cdm_id]; uint16_t symb = lp + csi_mapping->loverline[cdm_id];
uint64_t symbol_offset = symb * fp->ofdm_symbol_size; uint64_t symbol_offset = symb * fp->ofdm_symbol_size;
c16_t *rx_signal = &rxdataF[ant_rx][symbol_offset]; c16_t *rx_signal = &rxdataF[ant_rx][symbol_offset];
c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset];
...@@ -230,7 +225,7 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, ...@@ -230,7 +225,7 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue,
#ifdef NR_CSIRS_DEBUG #ifdef NR_CSIRS_DEBUG
int dataF_offset = proc->nr_slot_rx * fp->samples_per_slot_wCP; int dataF_offset = proc->nr_slot_rx * fp->samples_per_slot_wCP;
uint16_t port_tx = s+j_cdm[cdm_id]*CDM_group_size; uint16_t port_tx = s + csi_mapping->j[cdm_id] * CDM_group_size;
c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_info->csi_rs_generated_signal[port_tx][symbol_offset + dataF_offset]; c16_t *tx_csi_rs_signal = (c16_t*)&nr_csi_info->csi_rs_generated_signal[port_tx][symbol_offset + dataF_offset];
LOG_I(NR_PHY, LOG_I(NR_PHY,
"l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n", "l,k (%2d,%4d) |\tport_tx %d (%4d,%4d)\tant_rx %d (%4d,%4d)\n",
...@@ -278,39 +273,32 @@ uint32_t calc_power_csirs(const uint16_t *x, const fapi_nr_dl_config_csirs_pdu_r ...@@ -278,39 +273,32 @@ uint32_t calc_power_csirs(const uint16_t *x, const fapi_nr_dl_config_csirs_pdu_r
return sum_x2 / size - (sum_x / size) * (sum_x / size); return sum_x2 / size - (sum_x / size) * (sum_x / size);
} }
int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, static int nr_csi_rs_channel_estimation(const NR_DL_FRAME_PARMS *fp,
const UE_nr_rxtx_proc_t *proc, const UE_nr_rxtx_proc_t *proc,
const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu,
const nr_csi_info_t *nr_csi_info, const nr_csi_info_t *nr_csi_info,
const int32_t **csi_rs_generated_signal, const int32_t **csi_rs_generated_signal,
const int32_t csi_rs_received_signal[][ue->frame_parms.samples_per_slot_wCP], const int32_t csi_rs_received_signal[][fp->samples_per_slot_wCP],
const uint8_t N_cdm_groups, const csi_mapping_parms_t *csi_mapping,
const uint8_t CDM_group_size, const int CDM_group_size,
const uint8_t k_prime, uint8_t mem_offset,
const uint8_t l_prime, int32_t csi_rs_ls_estimated_channel[][csi_mapping->ports][fp->ofdm_symbol_size],
const uint8_t N_ports, int32_t csi_rs_estimated_channel_freq[][csi_mapping->ports][fp->ofdm_symbol_size + FILTER_MARGIN],
const uint8_t *j_cdm, int16_t *log2_re,
const uint8_t *k_overline, int16_t *log2_maxh,
const uint8_t *l_overline, uint32_t *noise_power)
uint8_t mem_offset, {
int32_t csi_rs_ls_estimated_channel[][N_ports][ue->frame_parms.ofdm_symbol_size], const int dataF_offset = proc->nr_slot_rx * fp->samples_per_slot_wCP;
int32_t csi_rs_estimated_channel_freq[][N_ports][ue->frame_parms.ofdm_symbol_size + FILTER_MARGIN],
int16_t *log2_re,
int16_t *log2_maxh,
uint32_t *noise_power) {
const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
const int dataF_offset = proc->nr_slot_rx*ue->frame_parms.samples_per_slot_wCP;
*noise_power = 0; *noise_power = 0;
int maxh = 0; int maxh = 0;
int count = 0; int count = 0;
for (int ant_rx = 0; ant_rx < frame_parms->nb_antennas_rx; ant_rx++) { for (int ant_rx = 0; ant_rx < fp->nb_antennas_rx; ant_rx++) {
/// LS channel estimation /// LS channel estimation
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
memset(csi_rs_ls_estimated_channel[ant_rx][port_tx], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); memset(csi_rs_ls_estimated_channel[ant_rx][port_tx], 0, fp->ofdm_symbol_size*sizeof(int32_t));
} }
for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) {
...@@ -320,21 +308,21 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -320,21 +308,21 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
continue; continue;
} }
for (int cdm_id = 0; cdm_id < N_cdm_groups; cdm_id++) { for (int cdm_id = 0; cdm_id < csi_mapping->size; cdm_id++) {
for (int s = 0; s < CDM_group_size; s++) { for (int s = 0; s < CDM_group_size; s++) {
uint16_t port_tx = s+j_cdm[cdm_id]*CDM_group_size; uint16_t port_tx = s + csi_mapping->j[cdm_id] * CDM_group_size;
// loop over frequency resource elements within a group // loop over frequency resource elements within a group
for (int kp = 0; kp <= k_prime; kp++) { for (int kp = 0; kp <= csi_mapping->kprime; kp++) {
uint16_t kinit = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; uint16_t kinit = (fp->first_carrier_offset + rb*NR_NB_SC_PER_RB) % fp->ofdm_symbol_size;
uint16_t k = kinit + k_overline[cdm_id] + kp; uint16_t k = kinit + csi_mapping->koverline[cdm_id] + kp;
// loop over time resource elements within a group // loop over time resource elements within a group
for (int lp = 0; lp <= l_prime; lp++) { for (int lp = 0; lp <= csi_mapping->lprime; lp++) {
uint16_t symb = lp + l_overline[cdm_id]; uint16_t symb = lp + csi_mapping->loverline[cdm_id];
uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; uint64_t symbol_offset = symb * fp->ofdm_symbol_size;
c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset];
c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset];
c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0];
...@@ -357,10 +345,10 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -357,10 +345,10 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
if(!is_csi_rs_in_symbol(*csirs_config_pdu,symb)) { if(!is_csi_rs_in_symbol(*csirs_config_pdu,symb)) {
continue; continue;
} }
for(int k = 0; k<frame_parms->ofdm_symbol_size; k++) { for(int k = 0; k < fp->ofdm_symbol_size; k++) {
LOG_I(NR_PHY, "l,k (%2d,%4d) | ", symb, k); LOG_I(NR_PHY, "l,k (%2d,%4d) | ", symb, k);
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
uint64_t symbol_offset = symb*frame_parms->ofdm_symbol_size; uint64_t symbol_offset = symb * fp->ofdm_symbol_size;
c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset]; c16_t *tx_csi_rs_signal = (c16_t*)&csi_rs_generated_signal[port_tx][symbol_offset+dataF_offset];
c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset]; c16_t *rx_csi_rs_signal = (c16_t*)&csi_rs_received_signal[ant_rx][symbol_offset];
c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0];
...@@ -377,8 +365,8 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -377,8 +365,8 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
/// Channel interpolation /// Channel interpolation
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
memset(csi_rs_estimated_channel_freq[ant_rx][port_tx], 0, (frame_parms->ofdm_symbol_size + FILTER_MARGIN) * sizeof(int32_t)); memset(csi_rs_estimated_channel_freq[ant_rx][port_tx], 0, (fp->ofdm_symbol_size + FILTER_MARGIN) * sizeof(int32_t));
} }
for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) {
...@@ -390,15 +378,15 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -390,15 +378,15 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
count++; count++;
uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; uint16_t k = (fp->first_carrier_offset + rb * NR_NB_SC_PER_RB) % fp->ofdm_symbol_size;
uint16_t k_offset = k + mem_offset; uint16_t k_offset = k + mem_offset;
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
int16_t *csi_rs_ls_estimated_channel16 = (int16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; int16_t *csi_rs_ls_estimated_channel16 = (int16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][k];
int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k_offset]; int16_t *csi_rs_estimated_channel16 = (int16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k_offset];
if( (k == 0) || (k == frame_parms->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case if( (k == 0) || (k == fp->first_carrier_offset) ) { // Start of OFDM symbol case or first occupied subcarrier case
multadd_real_vector_complex_scalar(filt24_start, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16, 24); multadd_real_vector_complex_scalar(filt24_start, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16, 24);
} else if( ( (k + NR_NB_SC_PER_RB) >= frame_parms->ofdm_symbol_size) || } else if(((k + NR_NB_SC_PER_RB) >= fp->ofdm_symbol_size) ||
(rb == (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs-1)) ) { // End of OFDM symbol case or Last occupied subcarrier case (rb == (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs-1))) { // End of OFDM symbol case or Last occupied subcarrier case
multadd_real_vector_complex_scalar(filt24_end, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); multadd_real_vector_complex_scalar(filt24_end, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24);
} else { // Middle case } else { // Middle case
multadd_real_vector_complex_scalar(filt24_middle, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24); multadd_real_vector_complex_scalar(filt24_middle, csi_rs_ls_estimated_channel16, csi_rs_estimated_channel16 - 3*sizeof(uint64_t), 24);
...@@ -408,15 +396,15 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -408,15 +396,15 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
/// Power noise estimation /// Power noise estimation
AssertFatal(csirs_config_pdu->nr_of_rbs > 0, " nr_of_rbs needs to be greater than 0\n"); AssertFatal(csirs_config_pdu->nr_of_rbs > 0, " nr_of_rbs needs to be greater than 0\n");
uint16_t noise_real[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs]; uint16_t noise_real[fp->nb_antennas_rx][csi_mapping->ports][csirs_config_pdu->nr_of_rbs];
uint16_t noise_imag[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs]; uint16_t noise_imag[fp->nb_antennas_rx][csi_mapping->ports][csirs_config_pdu->nr_of_rbs];
for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) {
if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) {
continue; continue;
} }
uint16_t k = (frame_parms->first_carrier_offset + rb*NR_NB_SC_PER_RB) % frame_parms->ofdm_symbol_size; uint16_t k = (fp->first_carrier_offset + rb*NR_NB_SC_PER_RB) % fp->ofdm_symbol_size;
uint16_t k_offset = k + mem_offset; uint16_t k_offset = k + mem_offset;
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][k]; c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][k];
c16_t *csi_rs_estimated_channel16 = (c16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k_offset]; c16_t *csi_rs_estimated_channel16 = (c16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][k_offset];
noise_real[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel16->r-csi_rs_estimated_channel16->r); noise_real[ant_rx][port_tx][rb-csirs_config_pdu->start_rb] = abs(csi_rs_ls_estimated_channel16->r-csi_rs_estimated_channel16->r);
...@@ -424,17 +412,17 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -424,17 +412,17 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
maxh = cmax3(maxh, abs(csi_rs_estimated_channel16->r), abs(csi_rs_estimated_channel16->i)); maxh = cmax3(maxh, abs(csi_rs_estimated_channel16->r), abs(csi_rs_estimated_channel16->i));
} }
} }
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
*noise_power += (calc_power_csirs(noise_real[ant_rx][port_tx], csirs_config_pdu) + calc_power_csirs(noise_imag[ant_rx][port_tx],csirs_config_pdu)); *noise_power += (calc_power_csirs(noise_real[ant_rx][port_tx], csirs_config_pdu) + calc_power_csirs(noise_imag[ant_rx][port_tx],csirs_config_pdu));
} }
#ifdef NR_CSIRS_DEBUG #ifdef NR_CSIRS_DEBUG
for(int k = 0; k<frame_parms->ofdm_symbol_size; k++) { for(int k = 0; k < fp->ofdm_symbol_size; k++) {
int rb = k >= frame_parms->first_carrier_offset ? int rb = k >= fp->first_carrier_offset ?
(k - frame_parms->first_carrier_offset)/NR_NB_SC_PER_RB : (k - fp->first_carrier_offset)/NR_NB_SC_PER_RB :
(k + frame_parms->ofdm_symbol_size - frame_parms->first_carrier_offset)/NR_NB_SC_PER_RB; (k + fp->ofdm_symbol_size - fp->first_carrier_offset)/NR_NB_SC_PER_RB;
LOG_I(NR_PHY, "(k = %4d) |\t", k); LOG_I(NR_PHY, "(k = %4d) |\t", k);
for(uint16_t port_tx = 0; port_tx<N_ports; port_tx++) { for(uint16_t port_tx = 0; port_tx < csi_mapping->ports; port_tx++) {
c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0]; c16_t *csi_rs_ls_estimated_channel16 = (c16_t*)&csi_rs_ls_estimated_channel[ant_rx][port_tx][0];
c16_t *csi_rs_estimated_channel16 = (c16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][mem_offset]; c16_t *csi_rs_estimated_channel16 = (c16_t *)&csi_rs_estimated_channel_freq[ant_rx][port_tx][mem_offset];
printf("Channel port_tx %d --> ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) | ", printf("Channel port_tx %d --> ant_rx %d : ls (%4d,%4d), int (%4d,%4d), noise (%4d,%4d) | ",
...@@ -450,14 +438,13 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -450,14 +438,13 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
} }
*noise_power /= (frame_parms->nb_antennas_rx*N_ports); *noise_power /= (fp->nb_antennas_rx * csi_mapping->ports);
*log2_maxh = log2_approx(maxh-1); *log2_maxh = log2_approx(maxh - 1);
*log2_re = log2_approx(count-1); *log2_re = log2_approx(count - 1);
#ifdef NR_CSIRS_DEBUG #ifdef NR_CSIRS_DEBUG
LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power); LOG_I(NR_PHY, "Noise power estimation based on CSI-RS: %i\n", *noise_power);
#endif #endif
return 0; return 0;
} }
...@@ -884,14 +871,6 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, ...@@ -884,14 +871,6 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; const NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
int32_t csi_rs_received_signal[frame_parms->nb_antennas_rx][frame_parms->samples_per_slot_wCP]; int32_t csi_rs_received_signal[frame_parms->nb_antennas_rx][frame_parms->samples_per_slot_wCP];
uint8_t N_cdm_groups = 0;
uint8_t CDM_group_size = 0;
uint8_t k_prime = 0;
uint8_t l_prime = 0;
uint8_t N_ports = 0;
uint8_t j_cdm[16];
uint8_t k_overline[16];
uint8_t l_overline[16];
int16_t log2_re = 0; int16_t log2_re = 0;
int16_t log2_maxh = 0; int16_t log2_maxh = 0;
uint32_t rsrp = 0; uint32_t rsrp = 0;
...@@ -903,40 +882,33 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, ...@@ -903,40 +882,33 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
uint8_t i1[3] = {0}; uint8_t i1[3] = {0};
uint8_t i2[1] = {0}; uint8_t i2[1] = {0};
nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = convert_csirs_pdu(csirs_config_pdu); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = convert_csirs_pdu(csirs_config_pdu);
csi_mapping_parms_t mapping_parms = get_csi_mapping_parms(csirs_config_pdu->row,
csirs_config_pdu->freq_domain,
csirs_config_pdu->symb_l0,
csirs_config_pdu->symb_l1);
nr_generate_csi_rs(frame_parms, nr_generate_csi_rs(frame_parms,
ue->nr_csi_info->csi_rs_generated_signal, ue->nr_csi_info->csi_rs_generated_signal,
AMP, AMP,
ue->nr_csi_info, ue->nr_csi_info,
&csi_params, &csi_params,
proc->nr_slot_rx, proc->nr_slot_rx,
&N_cdm_groups, &mapping_parms);
&CDM_group_size,
&k_prime, int32_t csi_rs_ls_estimated_channel[frame_parms->nb_antennas_rx][mapping_parms.ports][frame_parms->ofdm_symbol_size];
&l_prime, int32_t csi_rs_estimated_channel_freq[frame_parms->nb_antennas_rx][mapping_parms.ports][frame_parms->ofdm_symbol_size + FILTER_MARGIN];
&N_ports,
j_cdm, // (long)&csi_rs_estimated_channel_freq[0][0][frame_parms->first_carrier_offset] & 0x1F
k_overline, // gives us the remainder of the integer division by 32 of the memory address
l_overline);
int32_t csi_rs_ls_estimated_channel[frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size];
int32_t csi_rs_estimated_channel_freq[frame_parms->nb_antennas_rx][N_ports][frame_parms->ofdm_symbol_size + FILTER_MARGIN];
// (long)&csi_rs_estimated_channel_freq[0][0][frame_parms->first_carrier_offset] & 0x1F gives us the remainder of the integer division by 32 of the memory address
// By subtracting the previous value of 32, we know how much is left to have a multiple of 32. // By subtracting the previous value of 32, we know how much is left to have a multiple of 32.
// Doing >> 2 <=> /sizeof(int32_t), we know what is the index offset of the array. // Doing >> 2 <=> /sizeof(int32_t), we know what is the index offset of the array.
uint8_t mem_offset = (((32 - ((long)&csi_rs_estimated_channel_freq[0][0][frame_parms->first_carrier_offset])) & 0x1F) >> 2); uint8_t mem_offset = (((32 - ((long)&csi_rs_estimated_channel_freq[0][0][frame_parms->first_carrier_offset])) & 0x1F) >> 2);
int CDM_group_size = get_cdm_group_size(csirs_config_pdu->cdm_type);
nr_get_csi_rs_signal(ue, nr_get_csi_rs_signal(ue,
proc, proc,
csirs_config_pdu, csirs_config_pdu,
ue->nr_csi_info, ue->nr_csi_info,
N_cdm_groups, &mapping_parms,
CDM_group_size, CDM_group_size,
k_prime,
l_prime,
j_cdm,
k_overline,
l_overline,
csi_rs_received_signal, csi_rs_received_signal,
&rsrp, &rsrp,
&rsrp_dBm, &rsrp_dBm,
...@@ -945,20 +917,14 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, ...@@ -945,20 +917,14 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
// if we need to measure only RSRP no need to do channel estimation // if we need to measure only RSRP no need to do channel estimation
if (csirs_config_pdu->measurement_bitmap > 1) if (csirs_config_pdu->measurement_bitmap > 1)
nr_csi_rs_channel_estimation(ue, nr_csi_rs_channel_estimation(frame_parms,
proc, proc,
csirs_config_pdu, csirs_config_pdu,
ue->nr_csi_info, ue->nr_csi_info,
(const int32_t **) ue->nr_csi_info->csi_rs_generated_signal, (const int32_t **) ue->nr_csi_info->csi_rs_generated_signal,
csi_rs_received_signal, csi_rs_received_signal,
N_cdm_groups, &mapping_parms,
CDM_group_size, CDM_group_size,
k_prime,
l_prime,
N_ports,
j_cdm,
k_overline,
l_overline,
mem_offset, mem_offset,
csi_rs_ls_estimated_channel, csi_rs_ls_estimated_channel,
csi_rs_estimated_channel_freq, csi_rs_estimated_channel_freq,
...@@ -971,7 +937,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, ...@@ -971,7 +937,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
nr_csi_rs_ri_estimation(ue, nr_csi_rs_ri_estimation(ue,
csirs_config_pdu, csirs_config_pdu,
ue->nr_csi_info, ue->nr_csi_info,
N_ports, mapping_parms.ports,
mem_offset, mem_offset,
csi_rs_estimated_channel_freq, csi_rs_estimated_channel_freq,
log2_maxh, log2_maxh,
...@@ -983,7 +949,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, ...@@ -983,7 +949,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
nr_csi_rs_pmi_estimation(ue, nr_csi_rs_pmi_estimation(ue,
csirs_config_pdu, csirs_config_pdu,
ue->nr_csi_info, ue->nr_csi_info,
N_ports, mapping_parms.ports,
mem_offset, mem_offset,
csi_rs_estimated_channel_freq, csi_rs_estimated_channel_freq,
ue->nr_csi_info->csi_im_meas_computed ? ue->nr_csi_info->interference_plus_noise_power : noise_power, ue->nr_csi_info->csi_im_meas_computed ? ue->nr_csi_info->interference_plus_noise_power : noise_power,
......
...@@ -34,6 +34,7 @@ typedef struct { ...@@ -34,6 +34,7 @@ typedef struct {
int loverline[16]; int loverline[16];
} csi_mapping_parms_t; } csi_mapping_parms_t;
csi_mapping_parms_t get_csi_mapping_parms(int row, int b, int l0, int l1); csi_mapping_parms_t get_csi_mapping_parms(int row, int b, int l0, int l1);
int get_cdm_group_size(int cdm_type);
void nr_qpsk_llr(int32_t *rxdataF_comp, int16_t *llr, uint32_t nb_re); void nr_qpsk_llr(int32_t *rxdataF_comp, int16_t *llr, uint32_t nb_re);
void nr_16qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag_in, int16_t *llr, uint32_t nb_re); void nr_16qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag_in, int16_t *llr, uint32_t nb_re);
void nr_64qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int16_t *llr, uint32_t nb_re); void nr_64qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int16_t *llr, uint32_t nb_re);
......
...@@ -354,6 +354,29 @@ void nr_256qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int ...@@ -354,6 +354,29 @@ void nr_256qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int
simde_mm_empty(); simde_mm_empty();
} }
int get_cdm_group_size(int cdm_type)
{
// CDM group size from CDM type index
int gs = 0;
switch (cdm_type) {
case 0:
gs = 1;
break;
case 1:
gs = 2;
break;
case 2:
gs = 4;
break;
case 3:
gs = 8;
break;
default:
AssertFatal(false, "Invalid cdm type index for CSI\n");
}
return gs;
}
csi_mapping_parms_t get_csi_mapping_parms(int row, int b, int l0, int l1) csi_mapping_parms_t get_csi_mapping_parms(int row, int b, int l0, int l1)
{ {
AssertFatal(b != 0, "Invalid CSI frequency domain mapping: no bit selected in bitmap\n"); AssertFatal(b != 0, "Invalid CSI frequency domain mapping: no bit selected in bitmap\n");
......
...@@ -220,20 +220,17 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, ...@@ -220,20 +220,17 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx,
if (csirs->active == 1) { if (csirs->active == 1) {
LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot);
nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15; nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15;
csi_mapping_parms_t mapping_parms = get_csi_mapping_parms(csi_params->row,
csi_params->freq_domain,
csi_params->symb_l0,
csi_params->symb_l1);
nr_generate_csi_rs(&gNB->frame_parms, nr_generate_csi_rs(&gNB->frame_parms,
(int32_t **)gNB->common_vars.txdataF, (int32_t **)gNB->common_vars.txdataF,
gNB->TX_AMP, gNB->TX_AMP,
gNB->nr_csi_info, gNB->nr_csi_info,
csi_params, csi_params,
slot, slot,
NULL, &mapping_parms);
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
csirs->active = 0; csirs->active = 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