Commit fbef1099 authored by Sagar Parsawar's avatar Sagar Parsawar

OAI UE: PRS support for multiple Rx antenna and multiple gNB IDs

parent 51df6625
......@@ -136,6 +136,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
NR_DL_FRAME_PARMS *const fp = &ue->frame_parms;
NR_UE_COMMON *const common_vars = &ue->common_vars;
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,j,k,l,slot,symb,q;
int gNB_id;
......@@ -334,17 +335,18 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
}
prach_vars[gNB_id] = (NR_UE_PRACH *)malloc16_clear(sizeof(NR_UE_PRACH));
pbch_vars[gNB_id] = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH));
pbch_vars[gNB_id] = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH));
prs_vars[gNB_id] = (NR_UE_PRS *)malloc16_clear(sizeof(NR_UE_PRS));
// PRS channel estimates
ue->prs_ch_estimates = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
ue->prs_ch_estimates_time = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
AssertFatal(((ue->prs_ch_estimates!=NULL) || (ue->prs_ch_estimates_time!=NULL)), "NR UE init: PRS channel estimates malloc failed\n");
prs_vars[gNB_id]->prs_ch_estimates = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) );
prs_vars[gNB_id]->prs_ch_estimates_time = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) );
AssertFatal(((prs_vars[gNB_id]->prs_ch_estimates!=NULL) || (prs_vars[gNB_id]->prs_ch_estimates_time!=NULL)), "NR UE init: PRS channel estimates malloc failed\n");
for (i=0; i<fp->nb_antennas_rx; i++) {
ue->prs_ch_estimates[i] = (int32_t *)malloc16(2*fp->ofdm_symbol_size*NR_MAX_NUM_PRS_SYMB);
ue->prs_ch_estimates_time[i] = (int32_t *)malloc16(2*fp->ofdm_symbol_size*NR_MAX_NUM_PRS_SYMB);
AssertFatal(((ue->prs_ch_estimates[i]!=NULL) || (ue->prs_ch_estimates_time[i]!=NULL)), "NR UE init: PRS channel estimates malloc failed %d\n", i);
prs_vars[gNB_id]->prs_ch_estimates[i] = (int32_t *)malloc16_clear(2*fp->ofdm_symbol_size*NR_MAX_NUM_PRS_SYMB);
prs_vars[gNB_id]->prs_ch_estimates_time[i] = (int32_t *)malloc16_clear(2*fp->ofdm_symbol_size*NR_MAX_NUM_PRS_SYMB);
AssertFatal(((prs_vars[gNB_id]->prs_ch_estimates[i]!=NULL) || (prs_vars[gNB_id]->prs_ch_estimates_time[i]!=NULL)), "NR UE init: PRS channel estimates malloc failed %d\n", i);
}
......
......@@ -38,7 +38,8 @@
//#define DEBUG_PRS_CHEST
extern short nr_qpsk_mod_table[8];
int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue,
int nr_prs_channel_estimation(uint8_t gNB_id,
PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
NR_DL_FRAME_PARMS *frame_params)
{
......@@ -51,12 +52,13 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue,
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];
prs_data_t *prs_cfg = &ue->prs_cfg;
prs_data_t *prs_cfg = &ue->prs_vars[gNB_id]->prs_cfg;
int32_t **prs_chestF = ue->prs_vars[gNB_id]->prs_ch_estimates;
int32_t **prs_chestT = ue->prs_vars[gNB_id]->prs_ch_estimates_time;
uint8_t rxAnt = 0; // ant 0 rxdataF for now
int16_t *prs_chest, ch[2] = {0}, *rxF, *pil, *fl,*fm, *fmm, *fml, *fmr, *fr, mod_prs[NR_MAX_PRS_LENGTH<<1];
int16_t k_prime = 0, k = 0, re_offset;
uint8_t idx = prs_cfg->NPRSID;
uint8_t rxAnt = 0, idx = prs_cfg->NPRSID;
int16_t ch[2] = {0}, *rxF, *pil, *fl,*fm, *fmm, *fml, *fmr, *fr, mod_prs[NR_MAX_PRS_LENGTH<<1];
int16_t k_prime = 0, k = 0, re_offset = 0, second_half = 0;
int16_t *ch_freq = (int16_t *)malloc16(frame_params->ofdm_symbol_size*sizeof(int32_t));
int32_t *ch_time = (int32_t *)malloc16(frame_params->ofdm_symbol_size*sizeof(int32_t));
AssertFatal(((ch_freq != NULL) || (ch_time != NULL)), "nr_prs_channel_estimation: channel estimate buffer initialization failed!!");
......@@ -85,7 +87,7 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue,
k = re_offset = (prs_cfg->REOffset+k_prime) % prs_cfg->CombSize + prs_cfg->RBOffset*12 + frame_params->first_carrier_offset;
#ifdef DEBUG_PRS_CHEST
printf("PRS config l %d k_prime %d, re_offset %d k %d :\nprs_cfg->SymbolStart %d\nprs_cfg->NumPRSSymbols %d\nprs_cfg->NumRB %d\nprs_cfg->CombSize %d\n", l, k_prime, re_offset, k, prs_cfg->SymbolStart, prs_cfg->NumPRSSymbols, prs_cfg->NumRB, prs_cfg->CombSize);
printf("[gNB %d] PRS config l %d k_prime %d, re_offset %d k %d :\nprs_cfg->SymbolStart %d\nprs_cfg->NumPRSSymbols %d\nprs_cfg->NumRB %d\nprs_cfg->CombSize %d\n", gNB_id,l, k_prime, re_offset, k, prs_cfg->SymbolStart, prs_cfg->NumPRSSymbols, prs_cfg->NumRB, prs_cfg->CombSize);
#endif
// Pilots generation and modulation
for (int m = 0; m < (12/prs_cfg->CombSize)*prs_cfg->NumRB; m++)
......@@ -95,332 +97,334 @@ int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue,
mod_prs[(m<<1)+1] = nr_qpsk_mod_table[(idx<<1) + 1];
}
// Channel estimation and interpolation
pil = (int16_t *)&mod_prs[0];
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
prs_chest = (int16_t *)&ue->prs_ch_estimates[rxAnt][l*frame_params->ofdm_symbol_size];
memset(prs_chest,0,sizeof(int32_t)*(ue->frame_parms.ofdm_symbol_size));
memset(ch_freq,0,sizeof(int32_t)*(ue->frame_parms.ofdm_symbol_size));
if(prs_cfg->CombSize == 2)
for (rxAnt=0; rxAnt < frame_params->nb_antennas_rx; rxAnt++)
{
// Choose the interpolation filters
switch (k_prime) {
case 0:
fl = filt8_l0;
fml = filt8_m0;
fmm = filt8_mm0;
fmr = filt8_mr0;
fm = filt8_m0;
fr = filt8_r0;
break;
case 1:
fl = filt8_l1;
fmm = filt8_mm1;
fml = filt8_ml1;
fmr = fmm;
fm = filt8_m1;
fr = filt8_r1;
break;
default:
LOG_I(PHY, "nr=prs channel_estimation: k_prime=%d -> ERROR\n",k_prime);
return(-1);
break;
}
//Start pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fl,
ch,
ch_freq,
8);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
// Channel estimation and interpolation
pil = (int16_t *)&mod_prs[0];
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
memset(ch_freq,0,sizeof(int32_t)*(ue->frame_parms.ofdm_symbol_size));
//Middle pilots
for(int pIdx = 1; pIdx < prs_cfg->NumRB*(12/prs_cfg->CombSize)-1; pIdx+=2)
if(prs_cfg->CombSize == 2)
{
// Choose the interpolation filters
switch (k_prime) {
case 0:
fl = filt8_l0;
fml = filt8_m0;
fmm = filt8_mm0;
fmr = filt8_mr0;
fm = filt8_m0;
fr = filt8_r0;
break;
case 1:
fl = filt8_l1;
fmm = filt8_mm1;
fml = filt8_ml1;
fmr = fmm;
fm = filt8_m1;
fr = filt8_r1;
break;
default:
LOG_I(PHY, "nr=prs channel_estimation: k_prime=%d -> ERROR\n",k_prime);
return(-1);
break;
}
//Start pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
if(pIdx == 1) // 2nd pilot
{
multadd_real_vector_complex_scalar(fml,
ch,
ch_freq,
8);
}
else
{
multadd_real_vector_complex_scalar(fm,
ch,
ch_freq,
8);
}
multadd_real_vector_complex_scalar(fl,
ch,
ch_freq,
8);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
//Middle pilots
for(int pIdx = 1; pIdx < prs_cfg->NumRB*(12/prs_cfg->CombSize)-1; pIdx+=2)
{
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx+1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
if(pIdx == (prs_cfg->NumRB*(12/prs_cfg->CombSize)-3)) // 2nd last pilot
{
multadd_real_vector_complex_scalar(fmr,
ch,
ch_freq,
8);
}
else
{
multadd_real_vector_complex_scalar(fmm,
ch,
ch_freq,
8);
}
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch_freq +=8;
}
//End pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
if(pIdx == 1) // 2nd pilot
{
multadd_real_vector_complex_scalar(fml,
ch,
ch_freq,
8);
}
else
{
multadd_real_vector_complex_scalar(fm,
ch,
ch_freq,
8);
}
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx+1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fr,
ch,
ch_freq,
8);
}
else if(prs_cfg->CombSize == 4)
{
// Choose the interpolation filters
switch (k_prime) {
case 0:
fl = filt16a_l0;
fml = filt16a_mm0;
fmm = filt16a_mm0;
fmr = filt16a_m0;
fm = filt16a_m0;
fr = filt16a_r0;
break;
case 1:
fl = filt16a_l1;
fml = filt16a_ml1;
fmm = filt16a_mm1;
fmr = filt16a_mr1;
fm = filt16a_m1;
fr = filt16a_r1;
break;
case 2:
fl = filt16a_l2;
fml = filt16a_ml2;
fmm = filt16a_mm2;
fmr = filt16a_mr2;
fm = filt16a_m2;
fr = filt16a_r2;
break;
case 3:
fl = filt16a_l3;
fml = filt16a_ml3;
fmm = filt16a_mm3;
fmr = filt16a_mm3;
fm = filt16a_m3;
fr = filt16a_r3;
break;
default:
LOG_I(PHY, "nr=prs channel_estimation: k_prime=%d -> ERROR\n",k_prime);
return(-1);
break;
}
if(pIdx == (prs_cfg->NumRB*(12/prs_cfg->CombSize)-3)) // 2nd last pilot
{
multadd_real_vector_complex_scalar(fmr,
ch,
ch_freq,
8);
}
else
{
multadd_real_vector_complex_scalar(fmm,
ch,
ch_freq,
8);
}
//Start pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch_freq +=8;
}
//End pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fl,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
multadd_real_vector_complex_scalar(fr,
ch,
ch_freq,
8);
}
else if(prs_cfg->CombSize == 4)
{
// Choose the interpolation filters
switch (k_prime) {
case 0:
fl = filt16a_l0;
fml = filt16a_mm0;
fmm = filt16a_mm0;
fmr = filt16a_m0;
fm = filt16a_m0;
fr = filt16a_r0;
break;
case 1:
fl = filt16a_l1;
fml = filt16a_ml1;
fmm = filt16a_mm1;
fmr = filt16a_mr1;
fm = filt16a_m1;
fr = filt16a_r1;
break;
case 2:
fl = filt16a_l2;
fml = filt16a_ml2;
fmm = filt16a_mm2;
fmr = filt16a_mr2;
fm = filt16a_m2;
fr = filt16a_r2;
break;
case 3:
fl = filt16a_l3;
fml = filt16a_ml3;
fmm = filt16a_mm3;
fmr = filt16a_mm3;
fm = filt16a_m3;
fr = filt16a_r3;
break;
default:
LOG_I(PHY, "nr=prs channel_estimation: k_prime=%d -> ERROR\n",k_prime);
return(-1);
break;
}
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
//Start pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot 1 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fml,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch_freq +=8;
multadd_real_vector_complex_scalar(fl,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
//Middle pilots
for(int pIdx = 2; pIdx < prs_cfg->NumRB*(12/prs_cfg->CombSize)-2; pIdx++)
{
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot 1 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fmm,
ch,
ch_freq,
16);
multadd_real_vector_complex_scalar(fml,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch_freq +=8;
}
//End pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
//Middle pilots
for(int pIdx = 2; pIdx < prs_cfg->NumRB*(12/prs_cfg->CombSize)-2; pIdx++)
{
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-2, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", pIdx, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fmr,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
multadd_real_vector_complex_scalar(fmm,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
ch_freq +=8;
}
//End pilot
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-2, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fr,
ch,
ch_freq,
16);
}
else
{
LOG_I(PHY, "NR_PRS UE Channel EStimation: CombSize other than 2 and 4 are NOT supported currently! Returning");
return(0);
}
multadd_real_vector_complex_scalar(fmr,
ch,
ch_freq,
16);
pil +=2;
k = (k+prs_cfg->CombSize) % frame_params->ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[rxAnt][l*frame_params->ofdm_symbol_size + k];
//reset channel pointer
ch_freq = ch_init;
ch[0] = (int16_t)(((int32_t)rxF[0]*pil[0] + (int32_t)rxF[1]*pil[1])>>15);
ch[1] = (int16_t)(((int32_t)rxF[1]*pil[0] - (int32_t)rxF[0]*pil[1])>>15);
#ifdef DEBUG_PRS_CHEST
for (int re = 0; re < prs_cfg->NumRB*12; re++)
{
printf("prs_ch[%d] %d %d\n", re, ch_freq[re<<1], ch_freq[(re<<1)+1]);
}
printf("pilot %d : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n", prs_cfg->NumRB*(12/prs_cfg->CombSize)-1, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
#endif
// Place PRS channel estimates in rxdataF shifted format
memcpy((int16_t *)&ue->prs_ch_estimates[rxAnt][l*frame_params->ofdm_symbol_size+re_offset], &ch_init[0], (frame_params->ofdm_symbol_size - re_offset)*sizeof(int32_t));
memcpy((int16_t *)&ue->prs_ch_estimates[rxAnt][l*frame_params->ofdm_symbol_size], &ch_init[2*(frame_params->ofdm_symbol_size - re_offset)], (prs_cfg->NumRB*12-(frame_params->ofdm_symbol_size-re_offset))*sizeof(int32_t));
// Time domain IMPULSE response
idft_size_idx_t idftsizeidx;
switch (frame_params->ofdm_symbol_size) {
case 128:
idftsizeidx = IDFT_128;
break;
case 256:
idftsizeidx = IDFT_256;
break;
case 512:
idftsizeidx = IDFT_512;
break;
case 768:
idftsizeidx = IDFT_768;
break;
case 1024:
idftsizeidx = IDFT_1024;
break;
case 1536:
idftsizeidx = IDFT_1536;
break;
case 2048:
idftsizeidx = IDFT_2048;
break;
case 3072:
idftsizeidx = IDFT_3072;
break;
multadd_real_vector_complex_scalar(fr,
ch,
ch_freq,
16);
}
else
{
LOG_I(PHY, "NR_PRS UE Channel EStimation: CombSize other than 2 and 4 are NOT supported currently! Returning");
return(0);
}
case 4096:
idftsizeidx = IDFT_4096;
break;
//reset channel pointer
ch_freq = ch_init;
#ifdef DEBUG_PRS_CHEST
for (int re = 0; re < prs_cfg->NumRB*12; re++)
{
printf("prs_ch[%d] %d %d\n", re, ch_freq[re<<1], ch_freq[(re<<1)+1]);
}
#endif
// Place PRS channel estimates in rxdataF shifted format
second_half = (prs_cfg->NumRB*12-(frame_params->ofdm_symbol_size-re_offset));
memcpy((int16_t *)&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size+re_offset], &ch_init[0], (frame_params->ofdm_symbol_size - re_offset)*sizeof(int32_t));
if(second_half > 0)
memcpy((int16_t *)&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size], &ch_init[(frame_params->ofdm_symbol_size - re_offset)<<1], second_half*sizeof(int32_t));
// Time domain IMPULSE response
idft_size_idx_t idftsizeidx;
switch (frame_params->ofdm_symbol_size) {
case 128:
idftsizeidx = IDFT_128;
break;
case 256:
idftsizeidx = IDFT_256;
break;
case 512:
idftsizeidx = IDFT_512;
break;
case 768:
idftsizeidx = IDFT_768;
break;
case 1024:
idftsizeidx = IDFT_1024;
break;
case 1536:
idftsizeidx = IDFT_1536;
break;
case 2048:
idftsizeidx = IDFT_2048;
break;
case 3072:
idftsizeidx = IDFT_3072;
break;
case 4096:
idftsizeidx = IDFT_4096;
break;
default:
LOG_I(PHY, "unsupported ofdm symbol size \n");
assert(0);
}
default:
LOG_I(PHY, "unsupported ofdm symbol size \n");
assert(0);
}
idft(idftsizeidx,
(int16_t *)&ue->prs_ch_estimates[rxAnt][l*frame_params->ofdm_symbol_size],
(int16_t *)&ch_time[0],1);
// rearrange impulse response
memcpy((int16_t *)&ue->prs_ch_estimates_time[rxAnt][l*frame_params->ofdm_symbol_size], &ch_time[frame_params->ofdm_symbol_size>>1], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
memcpy((int16_t *)&ue->prs_ch_estimates_time[rxAnt][l*frame_params->ofdm_symbol_size + (frame_params->ofdm_symbol_size>>1)], &ch_time[0], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
// peak estimator
peak_estimator(&ue->prs_ch_estimates_time[rxAnt][l*frame_params->ofdm_symbol_size],
frame_params->ofdm_symbol_size,
&tdoa[l],
&ch_pwr[l]);
LOG_I(PHY, "TDoA for PRS symbol %d ==> %d / %d samples, Channel power %.1f dB\n", l, tdoa[l]-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr[l]));
idft(idftsizeidx,
(int16_t *)&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size],
(int16_t *)&ch_time[0],1);
// rearrange impulse response
memcpy((int16_t *)&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size], &ch_time[frame_params->ofdm_symbol_size>>1], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
memcpy((int16_t *)&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size + (frame_params->ofdm_symbol_size>>1)], &ch_time[0], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
// peak estimator
peak_estimator(&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size],
frame_params->ofdm_symbol_size,
&tdoa[l],
&ch_pwr[l]);
LOG_I(PHY, "[gNB %d][Rx %d] TDoA for PRS symbol %d ==> %d / %d samples, peak channel power %.1f dB\n", gNB_id, rxAnt, l, tdoa[l]-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr[l]));
} // for rxAnt
} //for l
#ifdef DEBUG_PRS_CHEST
LOG_M("PRSpilot.m", "prs_loc", &mod_prs[0], prs_cfg->NumRB*(12/prs_cfg->CombSize),1,1);
LOG_M("rxSigF.m","rxF",&rxdataF[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
LOG_M("prsEstF.m","prs_chestF",&ue->prs_ch_estimates[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
LOG_M("prsEstT.m","prs_chestT",&ue->prs_ch_estimates_time[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
LOG_M("prsEstF.m","prs_chestF",&prs_chestF[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
LOG_M("prsEstT.m","prs_chestT",&prs_chestT[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
#endif
// T tracer dump
T(T_UE_PHY_DL_CHANNEL_ESTIMATE_FREQ, T_INT(0),
T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
T_INT(0), T_BUFFER(&ue->prs_ch_estimates[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t)));
T_INT(0), T_BUFFER(&prs_chestF[0][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t)));
T(T_UE_PHY_DL_CHANNEL_ESTIMATE, T_INT(0),
T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
T_INT(0), T_BUFFER(&ue->prs_ch_estimates_time[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t)));
T_INT(0), T_BUFFER(&prs_chestT[0][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t)));
free(ch_freq);
free(ch_time);
......
......@@ -33,7 +33,8 @@
#define SYNCH_HYST 2
/* A function to perform the channel estimation of DL PRS signal */
int nr_prs_channel_estimation(PHY_VARS_NR_UE *ue,
int nr_prs_channel_estimation(uint8_t gNB_id,
PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
NR_DL_FRAME_PARMS *frame_params);
......
......@@ -262,6 +262,7 @@ void dft98304(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft64(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft128(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft256(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft384(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft512(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft768(int16_t *x,int16_t *y,uint8_t scale_flag);
void idft1024(int16_t *x,int16_t *y,uint8_t scale_flag);
......@@ -324,14 +325,14 @@ adftfunc_t dft_ftab[]={
#endif
typedef enum idft_size_idx {
IDFT_128, IDFT_256, IDFT_512, IDFT_768, IDFT_1024, IDFT_1536, IDFT_2048, IDFT_3072, IDFT_4096,
IDFT_128, IDFT_256, IDFT_384, IDFT_512, IDFT_768, IDFT_1024, IDFT_1536, IDFT_2048, IDFT_3072, IDFT_4096,
IDFT_6144, IDFT_8192, IDFT_9216, IDFT_12288, IDFT_18432, IDFT_24576, IDFT_36864, IDFT_49152,
IDFT_73728, IDFT_98304,
IDFT_SIZE_IDXTABLESIZE
} idft_size_idx_t;
#ifdef OAIDFTS_MAIN
aidftfunc_t idft_ftab[]={
idft128, idft256, idft512, idft768, idft1024, idft1536, idft2048, idft3072, idft4096,
idft128, idft256, idft384, idft512, idft768, idft1024, idft1536, idft2048, idft3072, idft4096,
idft6144, idft8192, idft9216, idft12288, idft18432, idft24576, idft36864, idft49152,
idft73728, idft98304
};
......
......@@ -383,6 +383,12 @@ typedef struct {
int32_t **ptrs_re_per_slot;
} NR_UE_PDSCH;
typedef struct {
prs_data_t prs_cfg;
int32_t **prs_ch_estimates;
int32_t **prs_ch_estimates_time;
} NR_UE_PRS;
#define NR_PDCCH_DEFS_NR_UE
#define NR_NBR_CORESET_ACT_BWP 3 // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0)
#define NR_NBR_SEARCHSPACE_ACT_BWP 10 // The number of SearchSpaces per BWP is limited to 10 (including initial SEARCHSPACE: SearchSpaceId 0)
......@@ -823,9 +829,7 @@ typedef struct {
NR_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_gNB_MAX];
prs_data_t prs_cfg;
int32_t **prs_ch_estimates;
int32_t **prs_ch_estimates_time;
NR_UE_PRS *prs_vars[NUMBER_OF_CONNECTED_gNB_MAX];
//Paging parameters
uint32_t IMSImod1024;
......
......@@ -1661,20 +1661,20 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
}
/*
ue->prs_cfg.PRSResourceSetPeriod[0]=40; // PRS resource slot period
ue->prs_cfg.PRSResourceSetPeriod[1]=0; // resource slot offset
ue->prs_cfg.SymbolStart=7;
ue->prs_cfg.NumPRSSymbols=4;
ue->prs_cfg.NumRB=fp->N_RB_DL;
ue->prs_cfg.RBOffset=0;
ue->prs_cfg.CombSize=4;
ue->prs_cfg.REOffset=0;
ue->prs_cfg.PRSResourceOffset=0;
ue->prs_cfg.PRSResourceRepetition=1;
ue->prs_cfg.PRSResourceTimeGap=1;
ue->prs_cfg.NPRSID=0;
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceSetPeriod[0]=40; // PRS resource slot period
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceSetPeriod[1]=0; // resource slot offset
ue->prs_vars[gNB_id]->prs_cfg.SymbolStart=7;
ue->prs_vars[gNB_id]->prs_cfg.NumPRSSymbols=4;
ue->prs_vars[gNB_id]->prs_cfg.NumRB=fp->N_RB_DL;
ue->prs_vars[gNB_id]->prs_cfg.RBOffset=0;
ue->prs_vars[gNB_id]->prs_cfg.CombSize=4;
ue->prs_vars[gNB_id]->prs_cfg.REOffset=0;
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceOffset=0;
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceRepetition=1;
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceTimeGap=1;
ue->prs_vars[gNB_id]->prs_cfg.NPRSID=0;
*/
for(int j = ue->prs_cfg.SymbolStart; j < (ue->prs_cfg.SymbolStart + ue->prs_cfg.NumPRSSymbols); j++)
for(int j = ue->prs_vars[gNB_id]->prs_cfg.SymbolStart; j < (ue->prs_vars[gNB_id]->prs_cfg.SymbolStart + ue->prs_vars[gNB_id]->prs_cfg.NumPRSSymbols); j++)
{
nr_slot_fep(ue,
proc,
......@@ -1683,7 +1683,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
}
//PRS channel estimation
nr_prs_channel_estimation(ue,proc,fp);
nr_prs_channel_estimation(gNB_id,ue,proc,fp);
}
if ((frame_rx%64 == 0) && (nr_slot_rx==0)) {
......
......@@ -1278,7 +1278,7 @@ void RCconfig_nr_ue_L1(void) {
void RCconfig_nrUE_prs(void *cfg)
{
int j = 0;
int j = 0, gNB_id = 0;
PHY_VARS_NR_UE *ue = (PHY_VARS_NR_UE *)cfg;
paramdef_t PRS_Params[] = PRS_PARAMS_DESC;
paramlist_def_t PRS_ParamList = {GNB_CONFIG_STRING_PRS_CONFIG,NULL,0};
......@@ -1286,30 +1286,30 @@ void RCconfig_nrUE_prs(void *cfg)
printf("Inside RCconfig_nrUE_prs\n");
if (PRS_ParamList.numelt > 0) {
ue->prs_cfg.PRSResourceSetPeriod[0] = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_SET_PERIOD0].uptr);
ue->prs_cfg.PRSResourceSetPeriod[1] = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_SET_PERIOD1].uptr);
ue->prs_cfg.SymbolStart = *(PRS_ParamList.paramarray[j][PRS_SYMBOL_START].uptr);
ue->prs_cfg.NumPRSSymbols = *(PRS_ParamList.paramarray[j][PRS_NUM_SYMBOLS].uptr);
ue->prs_cfg.NumRB = *(PRS_ParamList.paramarray[j][PRS_NUM_RB].uptr);
ue->prs_cfg.RBOffset = *(PRS_ParamList.paramarray[j][PRS_RB_OFFSET].uptr);
ue->prs_cfg.CombSize = *(PRS_ParamList.paramarray[j][PRS_COMB_SIZE].uptr);
ue->prs_cfg.REOffset = *(PRS_ParamList.paramarray[j][PRS_RE_OFFSET].uptr);
ue->prs_cfg.PRSResourceOffset = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_OFFSET].uptr);
ue->prs_cfg.PRSResourceRepetition = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_REPETITION].uptr);
ue->prs_cfg.PRSResourceTimeGap = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_TIME_GAP].uptr);
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceSetPeriod[0] = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_SET_PERIOD0].uptr);
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceSetPeriod[1] = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_SET_PERIOD1].uptr);
ue->prs_vars[gNB_id]->prs_cfg.SymbolStart = *(PRS_ParamList.paramarray[j][PRS_SYMBOL_START].uptr);
ue->prs_vars[gNB_id]->prs_cfg.NumPRSSymbols = *(PRS_ParamList.paramarray[j][PRS_NUM_SYMBOLS].uptr);
ue->prs_vars[gNB_id]->prs_cfg.NumRB = *(PRS_ParamList.paramarray[j][PRS_NUM_RB].uptr);
ue->prs_vars[gNB_id]->prs_cfg.RBOffset = *(PRS_ParamList.paramarray[j][PRS_RB_OFFSET].uptr);
ue->prs_vars[gNB_id]->prs_cfg.CombSize = *(PRS_ParamList.paramarray[j][PRS_COMB_SIZE].uptr);
ue->prs_vars[gNB_id]->prs_cfg.REOffset = *(PRS_ParamList.paramarray[j][PRS_RE_OFFSET].uptr);
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceOffset = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_OFFSET].uptr);
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceRepetition = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_REPETITION].uptr);
ue->prs_vars[gNB_id]->prs_cfg.PRSResourceTimeGap = *(PRS_ParamList.paramarray[j][PRS_RESOURCE_TIME_GAP].uptr);
LOG_I(NR_PHY, "PRS Config for at nrUE %d\n", 0);
LOG_I(NR_PHY, "PRSResourceSetPeriod0 %d\n", ue->prs_cfg.PRSResourceSetPeriod[0]);
LOG_I(NR_PHY, "PRSResourceSetPeriod1 %d\n", ue->prs_cfg.PRSResourceSetPeriod[1]);
LOG_I(NR_PHY, "SymbolStart %d\n", ue->prs_cfg.SymbolStart);
LOG_I(NR_PHY, "NumPRSSymbols %d\n", ue->prs_cfg.NumPRSSymbols);
LOG_I(NR_PHY, "NumRB %d\n", ue->prs_cfg.NumRB);
LOG_I(NR_PHY, "RBOffset %d\n", ue->prs_cfg.RBOffset);
LOG_I(NR_PHY, "CombSize %d\n", ue->prs_cfg.CombSize);
LOG_I(NR_PHY, "REOffset %d\n", ue->prs_cfg.REOffset);
LOG_I(NR_PHY, "PRSResourceOffset %d\n", ue->prs_cfg.PRSResourceOffset);
LOG_I(NR_PHY, "PRSResourceRepetition %d\n", ue->prs_cfg.PRSResourceRepetition);
LOG_I(NR_PHY, "PRSResourceTimeGap %d\n", ue->prs_cfg.PRSResourceTimeGap);
LOG_I(NR_PHY, "PRSResourceSetPeriod0 %d\n", ue->prs_vars[gNB_id]->prs_cfg.PRSResourceSetPeriod[0]);
LOG_I(NR_PHY, "PRSResourceSetPeriod1 %d\n", ue->prs_vars[gNB_id]->prs_cfg.PRSResourceSetPeriod[1]);
LOG_I(NR_PHY, "SymbolStart %d\n", ue->prs_vars[gNB_id]->prs_cfg.SymbolStart);
LOG_I(NR_PHY, "NumPRSSymbols %d\n", ue->prs_vars[gNB_id]->prs_cfg.NumPRSSymbols);
LOG_I(NR_PHY, "NumRB %d\n", ue->prs_vars[gNB_id]->prs_cfg.NumRB);
LOG_I(NR_PHY, "RBOffset %d\n", ue->prs_vars[gNB_id]->prs_cfg.RBOffset);
LOG_I(NR_PHY, "CombSize %d\n", ue->prs_vars[gNB_id]->prs_cfg.CombSize);
LOG_I(NR_PHY, "REOffset %d\n", ue->prs_vars[gNB_id]->prs_cfg.REOffset);
LOG_I(NR_PHY, "PRSResourceOffset %d\n", ue->prs_vars[gNB_id]->prs_cfg.PRSResourceOffset);
LOG_I(NR_PHY, "PRSResourceRepetition %d\n", ue->prs_vars[gNB_id]->prs_cfg.PRSResourceRepetition);
LOG_I(NR_PHY, "PRSResourceTimeGap %d\n", ue->prs_vars[gNB_id]->prs_cfg.PRSResourceTimeGap);
}
else
{
......
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