Commit 0c14b5fc authored by Sagar Parsawar's avatar Sagar Parsawar

Added NPRS-ID based PRS sequence generation for OAI gNB and UE

parent c62ddbe2
......@@ -615,20 +615,23 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
nr_init_csi_rs(gNB, cfg->cell_config.phy_cell_id.value);
//PRS init
gNB->nr_gold_prs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **));
uint32_t ***prs = gNB->nr_gold_prs;
gNB->nr_gold_prs = (uint32_t ****)malloc16(gNB->prs_vars.NumPRSResources*sizeof(uint32_t ***));
uint32_t ****prs = gNB->nr_gold_prs;
AssertFatal(prs!=NULL, "NR init: positioning reference signal malloc failed\n");
for (int rsc=0; rsc < gNB->prs_vars.NumPRSResources; rsc++) {
prs[rsc] = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **));
AssertFatal(prs[rsc]!=NULL, "NR init: positioning reference signal for rsc %d - malloc failed\n", rsc);
for (int slot=0; slot<fp->slots_per_frame; slot++) {
prs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *));
AssertFatal(prs[slot]!=NULL, "NR init: positioning reference signal for slot %d - malloc failed\n", slot);
for (int slot=0; slot<fp->slots_per_frame; slot++) {
prs[rsc][slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *));
AssertFatal(prs[rsc][slot]!=NULL, "NR init: positioning reference signal for slot %d - malloc failed\n", slot);
for (int symb=0; symb<fp->symbols_per_slot; symb++) {
prs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PRS_INIT_LENGTH_DWORD*sizeof(uint32_t));
AssertFatal(prs[slot][symb]!=NULL, "NR init: positioning reference signal for slot %d symbol %d - malloc failed\n", slot, symb);
for (int symb=0; symb<fp->symbols_per_slot; symb++) {
prs[rsc][slot][symb] = (uint32_t *)malloc16(NR_MAX_PRS_INIT_LENGTH_DWORD*sizeof(uint32_t));
AssertFatal(prs[rsc][slot][symb]!=NULL, "NR init: positioning reference signal for rsc %d slot %d symbol %d - malloc failed\n", rsc, slot, symb);
}
}
}
nr_init_prs(gNB);
......
......@@ -160,9 +160,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
NR_UE_PBCH **const pbch_vars = ue->pbch_vars;
NR_UE_PRS **const prs_vars = ue->prs_vars;
NR_UE_PRACH **const prach_vars = ue->prach_vars;
int i,slot,symb, gNB_id, th_id;
NR_UE_SRS **const srs_vars = ue->srs_vars;
int i,slot,symb, gNB_id, th_id;
LOG_I(PHY, "Initializing UE vars for gNB TXant %u, UE RXant %u\n", fp->nb_antennas_tx, fp->nb_antennas_rx);
......@@ -207,20 +206,29 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
////////////////////////////////////////////////////////////////////////////////////////////
//PRS init
ue->nr_gold_prs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **));
uint32_t ***prs = ue->nr_gold_prs;
ue->nr_gold_prs = (uint32_t *****)malloc16(ue->prs_active_gNBs*sizeof(uint32_t ****));
uint32_t *****prs = ue->nr_gold_prs;
AssertFatal(prs!=NULL, "NR UE init: positioning reference signal malloc failed\n");
for (int slot=0; slot<fp->slots_per_frame; slot++) {
prs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *));
AssertFatal(prs[slot]!=NULL, "NR UE init: positioning reference signal for slot %d - malloc failed\n", slot);
for (int symb=0; symb<fp->symbols_per_slot; symb++) {
prs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PRS_INIT_LENGTH_DWORD*sizeof(uint32_t));
AssertFatal(prs[slot][symb]!=NULL, "NR UE init: positioning reference signal for slot %d symbol %d - malloc failed\n", slot, symb);
}
}
nr_gold_prs(ue);
for (int gnb = 0; gnb < ue->prs_active_gNBs; gnb++) {
prs[gnb] = (uint32_t ****)malloc16(ue->prs_vars[gnb]->NumPRSResources*sizeof(uint32_t ***));
AssertFatal(prs[gnb]!=NULL, "NR UE init: positioning reference signal for gnb %d - malloc failed\n", gnb);
for (int rsc = 0; rsc < ue->prs_vars[gnb]->NumPRSResources; rsc++) {
prs[gnb][rsc] = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **));
AssertFatal(prs[gnb][rsc]!=NULL, "NR UE init: positioning reference signal for gnb %d rsc %d- malloc failed\n", gnb, rsc);
for (int slot=0; slot<fp->slots_per_frame; slot++) {
prs[gnb][rsc][slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *));
AssertFatal(prs[gnb][rsc][slot]!=NULL, "NR UE init: positioning reference signal for gnb %d rsc %d slot %d - malloc failed\n", gnb, rsc, slot);
for (int symb=0; symb<fp->symbols_per_slot; symb++) {
prs[gnb][rsc][slot][symb] = (uint32_t *)malloc16(NR_MAX_PRS_INIT_LENGTH_DWORD*sizeof(uint32_t));
AssertFatal(prs[gnb][rsc][slot][symb]!=NULL, "NR UE init: positioning reference signal for gnb %d rsc %d slot %d symbol %d - malloc failed\n", gnb, rsc, slot, symb);
} // for symb
} // for slot
} // for rsc
} // for gnb
init_nr_gold_prs(ue);
/////////////////////////PUSCH DMRS init/////////////////////////
///////////
......
......@@ -156,34 +156,32 @@ void nr_init_prs(PHY_VARS_gNB* gNB)
unsigned int x1, x2;
uint16_t Nid;
nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
uint8_t reset;
uint8_t slotNum, symNum;
Nid = cfg->cell_config.phy_cell_id.value;
for (slotNum = 0; slotNum < fp->slots_per_frame; slotNum++) {
for (symNum = 0; symNum < fp->symbols_per_slot ; symNum++) {
reset = 1;
// initial x2 for prs as ts138.211
uint32_t c_init1, c_init2, c_init3;
uint32_t pow22=1<<22;
uint32_t pow10=1<<10;
c_init1 = pow22*ceil(Nid/1024);
c_init2 = pow10*(slotNum+symNum+1)*(2*(Nid%1024)+1);
c_init3 = Nid%1024;
x2 = c_init1 + c_init2 + c_init3;
for (uint8_t n=0; n<NR_MAX_PRS_INIT_LENGTH_DWORD; n++) {
gNB->nr_gold_prs[slotNum][symNum][n] = lte_gold_generic(&x1, &x2, reset);
reset = 0;
//printf("%d \n",gNB->nr_gold_prs[slotNum][symNum][n]);
uint8_t slotNum, symNum, rsc_id;
for (rsc_id = 0; rsc_id < gNB->prs_vars.NumPRSResources; rsc_id++) {
Nid = gNB->prs_vars.prs_cfg[rsc_id].NPRSID; // seed value
LOG_I(PHY, "Initiaized NR-PRS sequence with PRS_ID %d\n", Nid);
for (slotNum = 0; slotNum < fp->slots_per_frame; slotNum++) {
for (symNum = 0; symNum < fp->symbols_per_slot ; symNum++) {
reset = 1;
// initial x2 for prs as ts138.211
uint32_t c_init1, c_init2, c_init3;
uint32_t pow22=1<<22;
uint32_t pow10=1<<10;
c_init1 = pow22*ceil(Nid/1024);
c_init2 = pow10*(slotNum+symNum+1)*(2*(Nid%1024)+1);
c_init3 = Nid%1024;
x2 = c_init1 + c_init2 + c_init3;
for (uint8_t n=0; n<NR_MAX_PRS_INIT_LENGTH_DWORD; n++) {
gNB->nr_gold_prs[rsc_id][slotNum][symNum][n] = lte_gold_generic(&x1, &x2, reset);
reset = 0;
//printf("%d \n",gNB->nr_gold_prs[slotNum][symNum][n]);
}
}
}
}
}
......@@ -125,38 +125,39 @@ void nr_init_pusch_dmrs(PHY_VARS_NR_UE* ue,
}
}
void nr_gold_prs(PHY_VARS_NR_UE* ue)
void init_nr_gold_prs(PHY_VARS_NR_UE* ue)
{
unsigned int x1, x2;
uint16_t Nid;
fapi_nr_config_request_t *cfg = &ue->nrUE_config;
NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
uint8_t reset;
uint8_t slotNum, symNum;
Nid = cfg->cell_config.phy_cell_id;
for (slotNum = 0; slotNum < fp->slots_per_frame; slotNum++) {
for (symNum = 0; symNum < fp->symbols_per_slot ; symNum++) {
reset = 1;
// initial x2 for prs as ts138.211
uint32_t c_init1, c_init2, c_init3;
uint32_t pow22=1<<22;
uint32_t pow10=1<<10;
c_init1 = pow22*ceil(Nid/1024);
c_init2 = pow10*(slotNum+symNum+1)*(2*(Nid%1024)+1);
c_init3 = Nid%1024;
x2 = c_init1 + c_init2 + c_init3;
for (uint8_t n=0; n<NR_MAX_PRS_INIT_LENGTH_DWORD; n++) {
ue->nr_gold_prs[slotNum][symNum][n] = lte_gold_generic(&x1, &x2, reset);
reset = 0;
//printf("%d \n",gNB->nr_gold_prs[slotNum][symNum][n]);
uint8_t slotNum, symNum, gnb, rsc;
for(gnb = 0; gnb < ue->prs_active_gNBs; gnb++) {
for(rsc = 0; rsc < ue->prs_vars[gnb]->NumPRSResources; rsc++) {
Nid = ue->prs_vars[gnb]->prs_resource[rsc].prs_cfg.NPRSID; // seed value
LOG_I(PHY,"Initialised NR-PRS sequence with PRS_ID %d\n",Nid);
for (slotNum = 0; slotNum < fp->slots_per_frame; slotNum++) {
for (symNum = 0; symNum < fp->symbols_per_slot ; symNum++) {
reset = 1;
// initial x2 for prs as ts138.211
uint32_t c_init1, c_init2, c_init3;
uint32_t pow22=1<<22;
uint32_t pow10=1<<10;
c_init1 = pow22*ceil(Nid/1024);
c_init2 = pow10*(slotNum+symNum+1)*(2*(Nid%1024)+1);
c_init3 = Nid%1024;
x2 = c_init1 + c_init2 + c_init3;
for (uint8_t n=0; n<NR_MAX_PRS_INIT_LENGTH_DWORD; n++) {
ue->nr_gold_prs[gnb][rsc][slotNum][symNum][n] = lte_gold_generic(&x1, &x2, reset);
reset = 0;
//printf("%d \n",gNB->nr_gold_prs[slotNum][symNum][n]);
}
}
}
}
}
} // for rsc
} // for gnb
}
......@@ -68,6 +68,6 @@ void nr_init_pusch_dmrs(PHY_VARS_NR_UE* ue,
uint16_t N_n_scid,
uint8_t n_scid);
void nr_gold_prs(PHY_VARS_NR_UE* ue);
void init_nr_gold_prs(PHY_VARS_NR_UE* ue);
#endif
......@@ -8,29 +8,26 @@
//#define DEBUG_PRS_MAP
extern short nr_qpsk_mod_table[8];
int k_prime_table[4][12] = {
{0,1,0,1,0,1,0,1,0,1,0,1},
{0,2,1,3,0,2,1,3,0,2,1,3},
{0,3,1,4,2,5,0,3,1,4,2,5},
{0,6,3,9,1,7,4,10,2,8,5,11}};
int nr_generate_prs(uint32_t **nr_gold_prs,
int32_t *txdataF,
int16_t amp,
prs_data_t *prs_data,
nfapi_nr_config_request_scf_t *config,
NR_DL_FRAME_PARMS *frame_parms) {
NR_DL_FRAME_PARMS *frame_parms)
{
// Get K_Prime from the table for the length of PRS or LPRS
int k_prime_table[4][12] = {
{0,1,0,1,0,1,0,1,0,1,0,1},
{0,2,1,3,0,2,1,3,0,2,1,3},
{0,3,1,4,2,5,0,3,1,4,2,5},
{0,6,3,9,1,7,4,10,2,8,5,11}};
int k_prime = 0;
int k=0;
int k_prime = 0, k = 0;
int16_t mod_prs[NR_MAX_PRS_LENGTH<<1];
uint8_t idx=prs_data->NPRSID;
uint8_t idx;
// PRS resource mapping with combsize=k which means PRS symbols exist in every k-th subcarrier in frequency domain
// According to ts138.211 sec.7.4.1.7.2
// PRS resource mapping with combsize=k which means PRS symbols exist in every k-th subcarrier in frequency domain
// According to ts138.211 sec.7.4.1.7.2
for (int l = prs_data->SymbolStart; l < prs_data->SymbolStart + prs_data->NumPRSSymbols; l++) {
int symInd = l-prs_data->SymbolStart;
......
......@@ -57,13 +57,13 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
NR_DL_FRAME_PARMS *frame_params)
{
int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF;
uint32_t **nr_gold_prs = ue->nr_gold_prs[proc->nr_slot_rx];
uint32_t **nr_gold_prs = ue->nr_gold_prs[gNB_id][rsc_id][proc->nr_slot_rx];
prs_data_t *prs_cfg = &ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_cfg;
prs_meas_t **prs_meas = ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_meas;
int32_t **prs_chestF = ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_ch_estimates;
int32_t **prs_chestT = ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_ch_estimates_time;
uint8_t rxAnt = 0, idx = prs_cfg->NPRSID;
uint8_t rxAnt = 0, idx = 0;
int16_t *rxF, *pil, *fl, *fm, *fmm, *fml, *fmr, *fr, mod_prs[NR_MAX_PRS_LENGTH<<1];
int16_t ch[2] = {0}, noiseFig[2] = {0};
int16_t k_prime = 0, k = 0, re_offset = 0, first_half = 0, second_half = 0;
......@@ -492,7 +492,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
prs_meas[rxAnt]->slot = proc->nr_slot_rx;
prs_meas[rxAnt]->rxAnt_idx = rxAnt;
prs_meas[rxAnt]->dl_aoa = 0;
LOG_I(PHY, "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] DL PRS ToA ==> %d / %d samples, peak channel power %.1f dB, SNR %+2d dB\n", gNB_id, rsc_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, prs_meas[rxAnt]->dl_toa, frame_params->ofdm_symbol_size, 10*log10(ch_pwr), prs_meas[rxAnt]->snr);
LOG_I(PHY, "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] DL PRS ToA ==> %d / %d samples, peak channel power %.1f dBm, SNR %+2d dB\n", gNB_id, rsc_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, prs_meas[rxAnt]->dl_toa, frame_params->ofdm_symbol_size, 10*log10(ch_pwr/frame_params->ofdm_symbol_size)-30, prs_meas[rxAnt]->snr);
#ifdef DEBUG_PRS_CHEST
sprintf(filename, "%s%i%s", "PRSpilot_", rxAnt, ".m");
......
......@@ -817,7 +817,7 @@ typedef struct PHY_VARS_gNB_s {
uint32_t ***nr_gold_csi_rs;
/// PRS sequence
uint32_t ***nr_gold_prs;
uint32_t ****nr_gold_prs;
/// Indicator set to 0 after first SR
uint8_t first_sr[NUMBER_OF_NR_SR_MAX];
......
......@@ -780,8 +780,8 @@ typedef struct {
/// PUSCH DMRS sequence
uint32_t ****nr_gold_pusch_dmrs;
// PRS sequence
uint32_t ***nr_gold_prs;
// PRS sequence per gNB, per resource
uint32_t *****nr_gold_prs;
uint32_t X_u[64][839];
......
......@@ -163,7 +163,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx,
if(is_prs_slot)
{
LOG_D(PHY,"gNB_TX: frame %d, slot %d, PRS Resource ID %d\n",frame, slot, rsc_id);
nr_generate_prs(gNB->nr_gold_prs[slot],&gNB->common_vars.txdataF[0][txdataF_offset], AMP, &gNB->prs_vars.prs_cfg[rsc_id], cfg, fp);
nr_generate_prs(gNB->nr_gold_prs[rsc_id][slot],&gNB->common_vars.txdataF[0][txdataF_offset], AMP, &gNB->prs_vars.prs_cfg[rsc_id], cfg, fp);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_COMMON_TX,1);
......
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