Commit c36c8cca authored by francescomani's avatar francescomani

addressing additional review and some wrong allocation

parent dcbc60df
......@@ -512,7 +512,6 @@ void init_eNB_afterRU(void) {
gNB = RC.gNB[inst];
phy_init_nr_gNB(gNB,0,0);
init_codebook_gNB(gNB);
// map antennas and PRACH signals to gNB RX
if (0) AssertFatal(gNB->num_RU>0,"Number of RU attached to gNB %d is zero\n",gNB->Mod_id);
......
......@@ -144,8 +144,8 @@ int init_codebook_gNB(PHY_VARS_gNB *gNB) {
//Table 5.2.2.2.1-5:
//Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
int pmiq_size = N1*O1*N2*O2*4+1;
mat[0] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
gNB->pmiq_size[0] = N1*O1*N2*O2*4+1;
mat[0] = (int32_t **)malloc16(gNB->pmiq_size[0]*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[0][0] = (int32_t *)calloc(2*N1*N2,sizeof(int32_t));
......@@ -202,19 +202,19 @@ int init_codebook_gNB(PHY_VARS_gNB *gNB) {
//Compute the code book size for generating 2 layers out of Tx antenna ports
//pmi_size is computed as follows
pmiq_size = 1;//1 for unity matrix
gNB->pmiq_size[1] = 1;//1 for unity matrix
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
if((llb != ll) || (mmb != mm) || ((N1 == 1) && (N2 == 1))) pmiq_size += 1;
if((llb != ll) || (mmb != mm) || ((N1 == 1) && (N2 == 1))) gNB->pmiq_size[1] += 1;
}
}
}
}
}
mat[1] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
mat[1] = (int32_t **)malloc16(gNB->pmiq_size[1]*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[1][0] = (int32_t *)calloc((2*N1*N2)*(2),sizeof(int32_t));
......@@ -287,19 +287,19 @@ int init_codebook_gNB(PHY_VARS_gNB *gNB) {
if(max_mimo_layers>=3) {
//pmi_size is computed as follows
pmiq_size = 1;//unity matrix
gNB->pmiq_size[2] = 1;//unity matrix
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
if((llb != ll) || (mmb != mm)) pmiq_size += 1;
if((llb != ll) || (mmb != mm)) gNB->pmiq_size[2] += 1;
}
}
}
}
}
mat[2] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
mat[2] = (int32_t **)malloc16(gNB->pmiq_size[2]*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[2][0] = (int32_t *)calloc((2*N1*N2)*(3),sizeof(int32_t));
for(int j_col=0; j_col<3; j_col++) { //3 layers
......@@ -376,20 +376,20 @@ int init_codebook_gNB(PHY_VARS_gNB *gNB) {
//Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
if(max_mimo_layers>=4) {
//pmi_size is computed as follows
pmiq_size = 1;//unity matrix
gNB->pmiq_size[3] = 1;//unity matrix
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
if((llb != ll) || (mmb != mm)) pmiq_size += 1;
if((llb != ll) || (mmb != mm)) gNB->pmiq_size[3] += 1;
}
}
}
}
}
mat[3] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
mat[3] = (int32_t **)malloc16(gNB->pmiq_size[3]*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[3][0] = (int32_t *)calloc((2*N1*N2)*(4),sizeof(int32_t));
for(int j_col=0; j_col<4; j_col++) { //4 layers
......@@ -509,6 +509,9 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
init_scrambling_luts();
init_pucch2_luts();
load_nrLDPClib(NULL);
init_codebook_gNB(gNB);
// PBCH DMRS gold sequences generation
nr_init_pbch_dmrs(gNB);
//PDCCH DMRS init
......@@ -706,6 +709,15 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
const int max_ul_mimo_layers = 4; // taken from phy_init_nr_gNB()
const int n_buf = Prx * max_ul_mimo_layers;
int max_dl_mimo_layers =(fp->nb_antennas_tx<NR_MAX_NB_LAYERS) ? fp->nb_antennas_tx : NR_MAX_NB_LAYERS;
for (int nl = 0; nl < max_dl_mimo_layers; nl++) {
for(int size = 0; size < gNB->pmiq_size[nl]; size++) {
free_and_zero(gNB->nr_mimo_precoding_matrix[nl][size]);
}
free_and_zero(gNB->nr_mimo_precoding_matrix[nl]);
}
free_and_zero(gNB->nr_mimo_precoding_matrix);
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
......
......@@ -59,7 +59,6 @@ void phy_init_nr_ue_PDSCH(NR_UE_PDSCH *const pdsch,
const NR_DL_FRAME_PARMS *const fp) {
AssertFatal( pdsch, "pdsch==0" );
//pdsch->layer_llr[0] = (int16_t *)malloc16_clear( (8*(3*8*6144))*sizeof(int16_t) );
pdsch->llr128 = (int16_t **)malloc16_clear( sizeof(int16_t *) );
// FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV
// FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there
......@@ -130,8 +129,10 @@ void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp
free_and_zero(pdsch->rho[i]);
}
free_and_zero(pdsch->pmi_ext);
free_and_zero(pdsch->llr[0]);
free_and_zero(pdsch->layer_llr[0]);
for (int i=0; i<NR_MAX_NB_CODEWORDS; i++)
free_and_zero(pdsch->llr[i]);
for (int i=0; i<NR_MAX_NB_LAYERS; i++)
free_and_zero(pdsch->layer_llr[i]);
free_and_zero(pdsch->llr128);
free_and_zero(pdsch->rxdataF_ext);
free_and_zero(pdsch->rxdataF_uespec_pilots);
......@@ -426,13 +427,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
pbch_vars[gNB_id]->decoded_output = (uint8_t *)malloc16_clear(64);
}
// initialization for the last instance of pdsch_vars (used for MU-MIMO)
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id] = malloc16_clear(sizeof(NR_UE_PDSCH));
ue->pdsch_vars[th_id][gNB_id]->llr[1] = malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
}
ue->sinr_CQI_dB = (double *) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
ue->init_averaging = 1;
......@@ -517,8 +511,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr_shifts);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr[1]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->layer_llr[1]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream);
phy_term_nr_ue__PDSCH(ue->pdsch_vars[th_id][gNB_id], fp);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]);
......@@ -594,13 +586,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
free_and_zero(ue->prach_vars[gNB_id]);
}
const int gNB_id = ue->n_connected_gNB;
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr[1]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->layer_llr[1]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]);
}
free_and_zero(ue->sinr_CQI_dB);
}
......
......@@ -807,6 +807,7 @@ typedef struct PHY_VARS_gNB_s {
/// second dimension: PMI [0,...,CodeSize-1[
/// third dimension: [i_rows*noOfLayers+j_col], i_rows=0,...pdsch_AntennaPorts-1 and j_col=0,...,noOfLayers-1
int32_t ***nr_mimo_precoding_matrix;
int pmiq_size[NR_MAX_NB_LAYERS];
/// PUSCH DMRS
uint32_t ****nr_gold_pusch_dmrs;
......
......@@ -785,9 +785,9 @@ int main(int argc, char **argv)
prepare_scd(scd);
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts;
pdsch_AntennaPorts.N1 = n_tx;
pdsch_AntennaPorts.N1 = n_tx>1 ? n_tx>>1 : 1;
pdsch_AntennaPorts.N2 = 1;
pdsch_AntennaPorts.XP = 1;
pdsch_AntennaPorts.XP = n_tx>1 ? 2 : 1;
gNB->ap_N1 = pdsch_AntennaPorts.N1;
gNB->ap_N2 = pdsch_AntennaPorts.N2;
gNB->ap_XP = pdsch_AntennaPorts.XP;
......@@ -819,7 +819,6 @@ int main(int argc, char **argv)
// rrc_mac_config_req_gNB
gNB_mac->pre_processor_dl = nr_dlsim_preprocessor;
phy_init_nr_gNB(gNB,0,1);
init_codebook_gNB(gNB);
N_RB_DL = gNB->frame_parms.N_RB_DL;
NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info;
UE_info->num_UEs=1;
......
......@@ -146,9 +146,9 @@ typedef enum {
{GNB_CONFIG_STRING_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defuintval:50001, TYPE_UINT, 0}, \
{GNB_CONFIG_STRING_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defuintval:50001, TYPE_UINT, 0}, \
{GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET, NULL, 0, iptr:NULL, defintval:31, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N1, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N2, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_XP, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N1, "horiz. log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_N2, "vert. log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PDSCHANTENNAPORTS_XP, "XP log. antenna ports", 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_PUSCHANTENNAPORTS, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_SIB1TDA, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \
{GNB_CONFIG_STRING_DOCSIRS, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 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