Commit 9af7987e authored by Sagar Parsawar's avatar Sagar Parsawar

OAI UE: Cleaned up PRS buffer handling

parent 4e869190
......@@ -338,10 +338,10 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
AssertFatal((prs_vars[idx]->prs_resource[k].prs_meas!=NULL), "NR UE init: PRS measurements malloc failed for gNB_id %d\n", idx);
for (i=0; i<fp->nb_antennas_rx; i++) {
prs_vars[idx]->prs_resource[k].prs_ch_estimates[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*NR_SYMBOLS_PER_SLOT*sizeof(int32_t));
prs_vars[idx]->prs_resource[k].prs_ch_estimates_time[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*NR_SYMBOLS_PER_SLOT*sizeof(int32_t));
prs_vars[idx]->prs_resource[k].prs_ch_estimates[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t));
prs_vars[idx]->prs_resource[k].prs_ch_estimates_time[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t));
AssertFatal(((prs_vars[idx]->prs_resource[k].prs_ch_estimates[i]!=NULL) || (prs_vars[idx]->prs_resource[k].prs_ch_estimates_time[i]!=NULL)), "NR UE init: PRS channel estimates malloc failed for rx_ant %d\n", i);
prs_vars[idx]->prs_resource[k].prs_meas[i] = (prs_meas_t *)malloc16_clear(NR_SYMBOLS_PER_SLOT*sizeof(prs_meas_t) );
prs_vars[idx]->prs_resource[k].prs_meas[i] = (prs_meas_t *)malloc16_clear(sizeof(prs_meas_t) );
AssertFatal((prs_vars[idx]->prs_resource[k].prs_meas[i]!=NULL), "NR UE init: PRS measurements malloc failed for rx_ant %d\n", i);
}
}
......
......@@ -240,7 +240,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
#endif
// average out the SNR computed
snr = snr/num_pilots;
prs_meas[rxAnt][l].snr = snr;
prs_meas[rxAnt]->snr = snr;
}
else if(prs_cfg->CombSize == 4)
{
......@@ -384,7 +384,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
#endif
// average out the SNR computed
snr = snr/num_pilots;
prs_meas[rxAnt][l].snr = snr;
prs_meas[rxAnt]->snr = snr;
}
else
{
......@@ -396,7 +396,6 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
} // for rxAnt
} //for l
int16_t l = 0; //symbIdx
for (rxAnt=0; rxAnt < frame_params->nb_antennas_rx; rxAnt++)
{
// scale by averaging factor 1/NumPrsSymbols
......@@ -423,9 +422,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
first_half = frame_params->ofdm_symbol_size - re_offset;
second_half = (prs_cfg->NumRB*12) - first_half;
if(first_half > 0)
memcpy((int16_t *)&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size+re_offset], &ch_tmp[0], first_half*sizeof(int32_t));
memcpy((int16_t *)&prs_chestF[rxAnt][re_offset], &ch_tmp[0], first_half*sizeof(int32_t));
if(second_half > 0)
memcpy((int16_t *)&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size], &ch_tmp[(frame_params->ofdm_symbol_size - re_offset)<<1], second_half*sizeof(int32_t));
memcpy((int16_t *)&prs_chestF[rxAnt][0], &ch_tmp[(first_half<<1)], second_half*sizeof(int32_t));
// Time domain IMPULSE response
idft_size_idx_t idftsizeidx;
......@@ -472,39 +471,40 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
}
idft(idftsizeidx,
(int16_t *)&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size],
(int16_t *)&prs_chestF[rxAnt][0],
(int16_t *)&ch_tmp[0],1);
// rearrange impulse response
memcpy((int16_t *)&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size], &ch_tmp[frame_params->ofdm_symbol_size], (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_tmp[0], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
memcpy((int16_t *)&prs_chestT[rxAnt][0], &ch_tmp[frame_params->ofdm_symbol_size], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
memcpy((int16_t *)&prs_chestT[rxAnt][(frame_params->ofdm_symbol_size>>1)], &ch_tmp[0], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t));
// peak estimator
peak_estimator(&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size],
peak_estimator(&prs_chestT[rxAnt][0],
frame_params->ofdm_symbol_size,
&prs_meas[rxAnt][l].dl_toa,
&prs_meas[rxAnt]->dl_toa,
&ch_pwr);
LOG_I(PHY, "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] ToA for PRS symbol %2d ==> %d / %d samples, peak channel power %.1f dB\n", gNB_id, rsc_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, l, prs_meas[rxAnt][l].dl_toa-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr));
//prs measurements
prs_meas[rxAnt][l].gNB_id = gNB_id;
prs_meas[rxAnt][l].sfn = proc->frame_rx;
prs_meas[rxAnt][l].slot = proc->nr_slot_rx;
prs_meas[rxAnt][l].rxAnt_idx = rxAnt;
prs_meas[rxAnt][l].dl_aoa = 0;
prs_meas[rxAnt]->dl_toa -= (frame_params->ofdm_symbol_size>>1);
prs_meas[rxAnt]->gNB_id = gNB_id;
prs_meas[rxAnt]->sfn = proc->frame_rx;
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);
#ifdef DEBUG_PRS_CHEST
sprintf(filename, "%s%i%s", "PRSpilot_", rxAnt, ".m");
LOG_M(filename, "prs_loc", &mod_prs[0], prs_cfg->NumRB*(12/prs_cfg->CombSize),1,1);
sprintf(filename, "%s%i%s", "rxSigF_", rxAnt, ".m");
sprintf(varname, "%s%i", "rxF_", rxAnt);
LOG_M(filename, varname, &rxdataF[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
LOG_M(filename, varname, &rxdataF[rxAnt][0], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size,1,1);
sprintf(filename, "%s%i%s", "prsChestF_", rxAnt, ".m");
sprintf(varname, "%s%i", "prsChF_", rxAnt);
LOG_M(filename, varname, &prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size], frame_params->ofdm_symbol_size,1,1);
LOG_M(filename, varname, &prs_chestF[rxAnt][0], frame_params->ofdm_symbol_size,1,1);
sprintf(filename, "%s%i%s", "prsChestT_", rxAnt, ".m");
sprintf(varname, "%s%i", "prsChT_", rxAnt);
LOG_M(filename, varname, &prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size], frame_params->ofdm_symbol_size,1,1);
LOG_M(filename, varname, &prs_chestT[rxAnt][0], frame_params->ofdm_symbol_size,1,1);
#endif
// T tracer dump
......@@ -514,11 +514,11 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
T(T_UE_PHY_DL_CHANNEL_ESTIMATE_FREQ, T_INT(gNB_id),
T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
T_INT(rxAnt), T_BUFFER(&prs_chestF[rxAnt][l*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t)));
T_INT(rxAnt), T_BUFFER(&prs_chestF[rxAnt][0], frame_params->ofdm_symbol_size*sizeof(int32_t)));
T(T_UE_PHY_DL_CHANNEL_ESTIMATE, T_INT(gNB_id),
T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
T_INT(rxAnt), T_BUFFER(&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t)));
T_INT(rxAnt), T_BUFFER(&prs_chestT[rxAnt][0], frame_params->ofdm_symbol_size*sizeof(int32_t)));
}
free(ch_tmp);
......
......@@ -1692,12 +1692,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
nr_slot_rx);
}
//PRS channel estimation
//for(int gIdx = 0; gIdx < ue->prs_active_gNBs; gIdx++)
{
nr_prs_channel_estimation(prs_gNB_id,rsc_id,ue,proc,fp);
}
}
if ((frame_rx%64 == 0) && (nr_slot_rx==0)) {
LOG_I(NR_PHY,"============================================\n");
......
......@@ -26,20 +26,20 @@ PRSs =
prs_config1 = (
{
gNB_id = 1;
PRSResourceSetPeriod0 = 40;
PRSResourceSetPeriod1 = 0;
SymbolStart = 7;
NumPRSSymbols = 4;
NumPRSResources = 1;
PRSResourceSetPeriod = [20, 5];
SymbolStart = [8];
NumPRSSymbols = [5];
NumRB = 106;
RBOffset = 0;
CombSize = 4;
REOffset = 1;
PRSResourceOffset = 0;
REOffset = [1];
PRSResourceOffset = [1];
PRSResourceRepetition = 1;
PRSResourceTimeGap = 1;
NPRS_ID = 0;
MutingPattern1 = [0];
MutingPattern2 = [0];
NPRS_ID = [5];
MutingPattern1 = [];
MutingPattern2 = [];
MutingBitRepetition = 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