Commit 7e009781 authored by francescomani's avatar francescomani

moving out CSI mapping parameters from nr_generate_csi_rs

parent ad96697d
......@@ -26,6 +26,7 @@
#include "PHY/defs_gNB.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,
unsigned int Ns,
......@@ -43,14 +44,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
nr_csi_info_t *nr_csi_info,
const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params,
const int slot,
uint8_t *N_cdm_groups,
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);
const csi_mapping_parms_t *phy_csi_parms);
void init_scrambling_luts(void);
void nr_generate_modulation_table(void);
......
......@@ -21,7 +21,6 @@
#include "PHY/MODULATION/nr_modulation.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
#include "PHY/nr_phy_common/inc/nr_phy_common.h"
//#define NR_CSIRS_DEBUG
......@@ -31,14 +30,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
nr_csi_info_t *nr_csi_info,
const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params,
const int slot,
uint8_t *N_cdm_groups,
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)
const csi_mapping_parms_t *phy_csi_parms)
{
#ifdef NR_CSIRS_DEBUG
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,
uint32_t beta = 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
double rho = 0;
switch (csi_params->freq_density) {
......@@ -89,7 +76,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
}
double alpha = 0;
if (phy_csi_parms.ports == 1)
if (phy_csi_parms->ports == 1)
alpha = rho;
else
alpha = 2 * rho;
......@@ -99,25 +86,9 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
#endif
// CDM group size from CDM type index
int gs = 0;
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 gs = get_cdm_group_size(csi_params->cdm_type);
int kprime = phy_csi_parms.kprime;
int kprime = phy_csi_parms->kprime;
int csi_length;
if (rho < 1) {
if (csi_params->freq_density == 0) {
......@@ -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);
#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
return;
// assuming amp is the amplitude of SSB channels
switch (csi_params->power_control_offset_ss) {
case 0:
beta = (amp*ONE_OVER_SQRT2_Q15)>>15;
beta = (amp * ONE_OVER_SQRT2_Q15) >> 15;
break;
case 1:
beta = amp;
break;
case 2:
beta = (amp*ONE_OVER_SQRT2_Q15)>>14;
beta = (amp * ONE_OVER_SQRT2_Q15) >> 14;
break;
case 3:
beta = amp << 1;
......@@ -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");
}
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;
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);
......@@ -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
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
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
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
// 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
int wf = kp == 0 ? 1 : (-2 * (s % 2) + 1);
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
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];
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];
// wt according to tables 7.4.5.3-2 to 7.4.5.3-5
int wt;
if (s < 2)
wt = 1;
else if (s < 4)
wt = -2*(lp % 2) + 1;
wt = -2 * (lp % 2) + 1;
else if (s < 6)
wt = -2 * (lp / 2) + 1;
else {
......
This diff is collapsed.
......@@ -34,6 +34,7 @@ typedef struct {
int loverline[16];
} csi_mapping_parms_t;
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_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);
......
......@@ -354,6 +354,29 @@ void nr_256qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int
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)
{
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,
if (csirs->active == 1) {
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;
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,
(int32_t **)gNB->common_vars.txdataF,
gNB->TX_AMP,
gNB->nr_csi_info,
csi_params,
slot,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
&mapping_parms);
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