Commit 0bdb1b9f authored by Robert Schmidt's avatar Robert Schmidt

Implement term_nr_ue_signal(), remove abstraction_flag from init_nr_ue_signal()

term_nr_ue_signal() frees all memory, except for dfts lib load
parent a7183bc5
......@@ -166,7 +166,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
}
// initialize all signal buffers
init_nr_ue_signal(ue, nb_connected_gNB, abstraction_flag);
init_nr_ue_signal(ue, nb_connected_gNB);
// intialize transport
init_nr_ue_transport(ue, abstraction_flag);
......
......@@ -111,6 +111,49 @@ void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch,
}
}
void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp)
{
for (int i = 0; i < fp->nb_antennas_rx; i++) {
for (int j = 0; j < NR_MAX_NB_LAYERS; j++) {
const int idx = j * fp->nb_antennas_rx + i;
for (int k = 0; k < NR_MAX_NB_LAYERS; k++)
free_and_zero(pdsch->rho[i][j*NR_MAX_NB_LAYERS+k]);
free_and_zero(pdsch->rxdataF_comp0[idx]);
free_and_zero(pdsch->dl_ch_estimates[idx]);
free_and_zero(pdsch->dl_ch_estimates_ext[idx]);
free_and_zero(pdsch->dl_bf_ch_estimates[idx]);
free_and_zero(pdsch->dl_bf_ch_estimates_ext[idx]);
free_and_zero(pdsch->dl_ch_mag0[idx]);
free_and_zero(pdsch->dl_ch_magb0[idx]);
free_and_zero(pdsch->dl_ch_magr0[idx]);
}
free_and_zero(pdsch->rxdataF_ext[i]);
free_and_zero(pdsch->rxdataF_uespec_pilots[i]);
free_and_zero(pdsch->ptrs_phase_per_slot[i]);
free_and_zero(pdsch->ptrs_re_per_slot[i]);
free_and_zero(pdsch->dl_ch_ptrs_estimates_ext[i]);
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]);
free_and_zero(pdsch->llr128);
free_and_zero(pdsch->rxdataF_ext);
free_and_zero(pdsch->rxdataF_uespec_pilots);
free_and_zero(pdsch->rxdataF_comp0);
free_and_zero(pdsch->rho);
free_and_zero(pdsch->dl_ch_estimates);
free_and_zero(pdsch->dl_ch_estimates_ext);
free_and_zero(pdsch->dl_bf_ch_estimates);
free_and_zero(pdsch->dl_bf_ch_estimates_ext);
free_and_zero(pdsch->dl_ch_mag0);
free_and_zero(pdsch->dl_ch_magb0);
free_and_zero(pdsch->dl_ch_magr0);
free_and_zero(pdsch->ptrs_phase_per_slot);
free_and_zero(pdsch->ptrs_re_per_slot);
free_and_zero(pdsch->dl_ch_ptrs_estimates_ext);
}
void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch,
const NR_DL_FRAME_PARMS *const fp) {
AssertFatal( pusch, "pusch==0" );
......@@ -120,9 +163,14 @@ void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch,
}
}
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
int nb_connected_gNB,
uint8_t abstraction_flag) {
void phy_term_nr_ue_PUSCH(NR_UE_PUSCH *pusch)
{
for (int i = 0; i < NR_MAX_NB_LAYERS; i++)
free_and_zero(pusch->txdataF_layers[i]);
}
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
{
// create shortcuts
NR_DL_FRAME_PARMS *const fp = &ue->frame_parms;
NR_UE_COMMON *const common_vars = &ue->common_vars;
......@@ -136,8 +184,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
uint32_t ****pusch_dmrs;
uint16_t N_n_scid[2] = {0,1}; // [HOTFIX] This is a temporary implementation of scramblingID0 and scramblingID1 which are given by DMRS-UplinkConfig
int n_scid;
abstraction_flag = 0;
LOG_I(PHY, "Initializing UE vars (abstraction %u) for gNB TXant %u, UE RXant %u\n", abstraction_flag, fp->nb_antennas_tx, fp->nb_antennas_rx);
LOG_I(PHY, "Initializing UE vars for gNB TXant %u, UE RXant %u\n", fp->nb_antennas_tx, fp->nb_antennas_rx);
//LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_gNB_INST);
phy_init_nr_top(ue);
// many memory allocation sizes are hard coded
......@@ -231,29 +278,27 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
for (i=0; i<10; i++)
ue->tx_power_dBm[i]=-127;
if (abstraction_flag == 0) {
// init TX buffers
common_vars->txdata = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
// init TX buffers
common_vars->txdata = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
for (i=0; i<fp->nb_antennas_tx; i++) {
common_vars->txdata[i] = (int32_t *)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) );
common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->samples_per_slot_wCP*sizeof(int32_t) );
}
for (i=0; i<fp->nb_antennas_tx; i++) {
common_vars->txdata[i] = (int32_t *)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) );
common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->samples_per_slot_wCP*sizeof(int32_t) );
}
// init RX buffers
common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
// init RX buffers
common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
}
for (i=0; i<fp->nb_antennas_rx; i++) {
common_vars->rxdata[i] = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) );
for (i=0; i<fp->nb_antennas_rx; i++) {
common_vars->rxdata[i] = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) );
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->samples_per_slot_wCP) );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->samples_per_slot_wCP) );
}
}
......@@ -331,129 +376,121 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
ue->nr_srs_info->srs_estimated_channel_time_shifted[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
}
if (abstraction_flag == 0) {
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
phy_init_nr_ue__PDSCH( ue->pdsch_vars[th_id][gNB_id], fp );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
phy_init_nr_ue__PDSCH( ue->pdsch_vars[th_id][gNB_id], fp );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->llr_shifts = (uint8_t *)malloc16_clear(7*2*fp->N_RB_DL*12);
ue->pdsch_vars[th_id][gNB_id]->llr_shifts_p = ue->pdsch_vars[0][gNB_id]->llr_shifts;
ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream = (int16_t **)malloc16_clear( sizeof(int16_t *) );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->llr_shifts = (uint8_t *)malloc16_clear(7*2*fp->N_RB_DL*12);
ue->pdsch_vars[th_id][gNB_id]->llr_shifts_p = ue->pdsch_vars[0][gNB_id]->llr_shifts;
ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream = (int16_t **)malloc16_clear( sizeof(int16_t *) );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
}
for (i=0; i<fp->nb_antennas_rx; i++)
for (j=0; j<4; j++) {
const int idx = (j*fp->nb_antennas_rx)+i;
const size_t num = 7*2*fp->N_RB_DL*12+4;
for (i=0; i<fp->nb_antennas_rx; i++)
for (j=0; j<4; j++) {
const int idx = (j*fp->nb_antennas_rx)+i;
const size_t num = 7*2*fp->N_RB_DL*12+4;
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num );
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num );
}
}
//const size_t num = 7*2*fp->N_RB_DL*12+4;
for (k=0; k<8; k++) { //harq_pid
for (l=0; l<8; l++) { //round
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
}
//const size_t num = 7*2*fp->N_RB_DL*12+4;
for (k=0; k<8; k++) { //harq_pid
for (l=0; l<8; l++) { //round
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
}
for (int i=0; i<fp->nb_antennas_rx; i++)
for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++)
const int idx = (j*fp->nb_antennas_rx)+i;
for (int i=0; i<fp->nb_antennas_rx; i++)
for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++)
const int idx = (j*fp->nb_antennas_rx)+i;
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
}
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
}
}
}
// 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdcch_vars[th_id][gNB_id]->llr = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
ue->pdcch_vars[th_id][gNB_id]->llr16 = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
ue->pdcch_vars[th_id][gNB_id]->wbar = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
ue->pdcch_vars[th_id][gNB_id]->e_rx = (int16_t *)malloc16_clear( 4*2*100*12 );
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
// Channel estimates
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
for (i=0; i<fp->nb_antennas_rx; i++) {
ue->pdcch_vars[th_id][gNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4));
for (j=0; j<4; j++) {
int idx = (j*fp->nb_antennas_rx)+i;
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
// size_t num = 7*2*fp->N_RB_DL*12;
size_t num = 4*273*12; // 4 symbols, 100 PRBs, 12 REs per PRB
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
}
}
}
}
// PBCH
pbch_vars[gNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); //
prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
// 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
ue->pdcch_vars[th_id][gNB_id]->llr = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
ue->pdcch_vars[th_id][gNB_id]->llr16 = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
ue->pdcch_vars[th_id][gNB_id]->wbar = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
ue->pdcch_vars[th_id][gNB_id]->e_rx = (int16_t *)malloc16_clear( 4*2*100*12 );
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
// Channel estimates
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
for (i=0; i<fp->nb_antennas_rx; i++) {
pbch_vars[gNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
ue->pdcch_vars[th_id][gNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4));
for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) {
for (j=0; j<4; j++) {
int idx = (j*fp->nb_antennas_rx)+i;
pbch_vars[gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
pbch_vars[gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
pbch_vars[gNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
pbch_vars[gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) );
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
// size_t num = 7*2*fp->N_RB_DL*12;
size_t num = 4*273*12; // 4 symbols, 100 PRBs, 12 REs per PRB
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
}
}
}
// PBCH
pbch_vars[gNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); //
prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
for (i=0; i<fp->nb_antennas_rx; i++) {
pbch_vars[gNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) {
int idx = (j*fp->nb_antennas_rx)+i;
pbch_vars[gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
pbch_vars[gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
pbch_vars[gNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
pbch_vars[gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
}
}
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] = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
}
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));
if (abstraction_flag == 0) {
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
//phy_init_lte_ue__PDSCH( ue->pdsch_vars[th_id][gNB_id], fp );
ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
}
} else { //abstraction == 1
ue->sinr_dB = (double *) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
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) );
......@@ -474,6 +511,180 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
return 0;
}
void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
{
const NR_DL_FRAME_PARMS* fp = &ue->frame_parms;
phy_term_nr_top();
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
phy_term_nr_ue_PUSCH(ue->pusch_vars[th_id][gNB_id]);
free_and_zero(ue->pusch_vars[th_id][gNB_id]);
free_and_zero(ue->pucch_vars[th_id][gNB_id]);
}
}
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++) {
for (int q = 0; q < NR_MAX_NB_CODEWORDS; q++)
free_and_zero(ue->nr_gold_pusch_dmrs[slot][symb][q]);
free_and_zero(ue->nr_gold_pusch_dmrs[slot][symb]);
}
free_and_zero(ue->nr_gold_pusch_dmrs[slot]);
}
free_and_zero(ue->nr_gold_pusch_dmrs);
NR_UE_COMMON* common_vars = &ue->common_vars;
for (int i = 0; i < fp->nb_antennas_tx; i++) {
free_and_zero(common_vars->txdata[i]);
free_and_zero(common_vars->txdataF[i]);
}
free_and_zero(common_vars->txdata);
free_and_zero(common_vars->txdataF);
for (int i = 0; i < fp->nb_antennas_rx; i++) {
free_and_zero(common_vars->rxdata[i]);
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++)
free_and_zero(common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i]);
}
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
free_and_zero(common_vars->common_vars_rx_data_per_thread[th_id].rxdataF);
}
free_and_zero(common_vars->rxdata);
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
free_and_zero(ue->nr_gold_pdcch[0][slot][symb]);
free_and_zero(ue->nr_gold_pdcch[0][slot]);
}
free_and_zero(ue->nr_gold_pdcch[0]);
for (int slot=0; slot<fp->slots_per_frame; slot++) {
for (int symb=0; symb<fp->symbols_per_slot; symb++) {
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
free_and_zero(ue->nr_gold_pdsch[0][slot][symb][q]);
free_and_zero(ue->nr_gold_pdsch[0][slot][symb]);
}
free_and_zero(ue->nr_gold_pdsch[0][slot]);
}
free_and_zero(ue->nr_gold_pdsch[0]);
for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
// PDSCH
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
for (int k = 0; k < 8; k++) { //harq_pid
for (int l = 0; l < 8; l++) { //round
for (int i = 0; i < fp->nb_antennas_rx; i++) {
for (int j = 0; j < 4; j++) { //frame_parms->nb_antennas_tx; j++)
const int idx = j * fp->nb_antennas_rx + i;
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx]);
}
}
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l]);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l]);
}
}
for (int i = 0; i < fp->nb_antennas_rx; i++) {
for (int j = 0; j < 4; j++) {
const int idx = (j*fp->nb_antennas_rx)+i;
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx]);
}
}
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);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext);
phy_term_nr_ue__PDSCH(ue->pdsch_vars[th_id][gNB_id], fp);
free_and_zero(ue->pdsch_vars[th_id][gNB_id]);
}
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
for (int i = 0; i < fp->nb_antennas_rx; i++) {
for (int j = 0; j < 4; j++) {
int idx = j * fp->nb_antennas_rx + i;
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx]);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx]);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx]);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx]);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx]);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx]);
}
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho[i]);
}
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr16);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->wbar);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->e_rx);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time);
free_and_zero(ue->pdcch_vars[th_id][gNB_id]);
}
for (int i = 0; i < fp->nb_antennas_rx; i++) {
free_and_zero(ue->nr_srs_info->srs_received_signal[i]);
free_and_zero(ue->nr_srs_info->srs_ls_estimated_channel[i]);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_freq[i]);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time[i]);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted[i]);
}
free_and_zero(ue->nr_srs_info->srs_generated_signal);
free_and_zero(ue->nr_srs_info->noise_power);
free_and_zero(ue->nr_srs_info->srs_received_signal);
free_and_zero(ue->nr_srs_info->srs_ls_estimated_channel);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_freq);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time);
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted);
free_and_zero(ue->nr_srs_info);
free_and_zero(ue->srs_vars[gNB_id]);
for (int i = 0; i < fp->nb_antennas_rx; i++) {
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext[i]);
for (int j = 0; j < 4; j++) {
int idx = (j*fp->nb_antennas_rx)+i;
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp[idx]);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates[idx]);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time[idx]);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext[idx]);
}
}
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext);
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time);
free_and_zero(ue->pbch_vars[gNB_id]->llr);
free_and_zero(ue->pbch_vars[gNB_id]->decoded_output);
free_and_zero(ue->pbch_vars[gNB_id]);
free_and_zero(ue->prach_vars[gNB_id]->prachF);
free_and_zero(ue->prach_vars[gNB_id]->prach);
free_and_zero(ue->prach_vars[gNB_id]);
}
free_and_zero(ue->sinr_CQI_dB);
}
void init_nr_ue_transport(PHY_VARS_NR_UE *ue,
int abstraction_flag) {
for (int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) {
......@@ -556,3 +767,9 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) {
//init_unscrambling_lut();
//set_taus_seed(1328);
}
void phy_term_nr_top(void)
{
free_ul_reference_signal_sequences();
free_context_synchro_nr();
}
......@@ -57,6 +57,7 @@ int l1_north_init_eNB(void);
int phy_init_top(LTE_DL_FRAME_PARMS *frame_parms);
void phy_init_nr_top(PHY_VARS_NR_UE *ue);
void phy_term_nr_top(void);
/*!
......@@ -395,7 +396,8 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp,uint8_t i_ssb);
int nr_init_frame_parms(nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS *frame_parms);
int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms, fapi_nr_config_request_t *config, uint16_t nr_band);
void nr_init_frame_parms_ue_sa(NR_DL_FRAME_PARMS *frame_parms, uint64_t downlink_frequency, int32_t uplink_frequency_offset, uint8_t mu, uint16_t nr_band);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB);
void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB);
void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag);
void init_N_TA_offset(PHY_VARS_NR_UE *ue);
void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms);
......
......@@ -439,33 +439,10 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
void free_context_pss_nr(void)
{
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
if (primary_synchro_time_nr[i] != NULL) {
free(primary_synchro_time_nr[i]);
primary_synchro_time_nr[i] = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
if (primary_synchro_nr[i] != NULL) {
free(primary_synchro_nr[i]);
primary_synchro_nr[i] = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
if (pss_corr_ue[i] != NULL) {
free(pss_corr_ue[i]);
pss_corr_ue[i] = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
free_and_zero(primary_synchro_nr[i]);
free_and_zero(primary_synchro_nr2[i]);
free_and_zero(primary_synchro_time_nr[i]);
free_and_zero(pss_corr_ue[i]);
}
}
......
......@@ -413,7 +413,7 @@ int main(int argc, char **argv)
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(UE, 1, 0) != 0) {
if (init_nr_ue_signal(UE, 1) != 0) {
printf("Error at UE NR initialisation\n");
exit(-1);
}
......@@ -642,6 +642,8 @@ int main(int argc, char **argv)
phy_free_nr_gNB(gNB);
term_nr_ue_signal(UE, 1);
for (i = 0; i < 2; i++) {
free(s_re[i]);
free(s_im[i]);
......
......@@ -915,7 +915,7 @@ int main(int argc, char **argv)
UE->perfect_ce = 0;
if (init_nr_ue_signal(UE, 1, 0) != 0)
if (init_nr_ue_signal(UE, 1) != 0)
{
printf("Error at UE NR initialisation\n");
exit(-1);
......
......@@ -553,7 +553,7 @@ int main(int argc, char **argv)
if(eps!=0.0)
UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation
if (init_nr_ue_signal(UE, 1, 0) != 0) {
if (init_nr_ue_signal(UE, 1) != 0) {
printf("Error at UE NR initialisation\n");
exit(-1);
}
......
......@@ -671,7 +671,7 @@ int main(int argc, char **argv){
memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS));
UE->nrUE_config.prach_config.num_prach_fd_occasions_list = (fapi_nr_num_prach_fd_occasions_t *) malloc(num_prach_fd_occasions*sizeof(fapi_nr_num_prach_fd_occasions_t));
if (init_nr_ue_signal(UE, 1, 0) != 0){
if (init_nr_ue_signal(UE, 1) != 0){
printf("Error at UE NR initialisation\n");
exit(-1);
}
......
......@@ -490,7 +490,7 @@ int main(int argc, char **argv)
if(eps!=0.0)
UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation
if (init_nr_ue_signal(UE, 1, 0) != 0)
if (init_nr_ue_signal(UE, 1) != 0)
{
printf("Error at UE NR initialisation\n");
exit(-1);
......
......@@ -756,7 +756,7 @@ int main(int argc, char **argv)
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(UE, 1, 0) != 0) {
if (init_nr_ue_signal(UE, 1) != 0) {
printf("Error at UE NR initialisation\n");
exit(-1);
}
......
......@@ -71,7 +71,7 @@ static nfapi_config_request_t *config =&config_t;
/*************** FUNCTIONS ****************************************/
//void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_eNB, uint8_t abstraction_flag);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_eNB);
/*******************************************************************
*
......@@ -248,7 +248,7 @@ int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(PHY_vars_UE, 1, 0) != 0) {
if (init_nr_ue_signal(PHY_vars_UE, 1) != 0) {
LOG_E(PHY,"Error at UE NR initialisation : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
return (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