mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
Add signal power measurement for better processing in int16
Signed-off-by: Raymond Knopp <raymond.knopp@eurecom.fr>
This commit is contained in:
@@ -963,13 +963,13 @@ void *ru_thread(void *param)
|
||||
if (!wait_free_rx_tti(&gNB->L1_rx_out, rx_tti_busy, proc->frame_rx, proc->tti_rx))
|
||||
break; // nothing to wait for: we have to stop
|
||||
if (ru->feprx) {
|
||||
ru->feprx(ru,proc->tti_rx);
|
||||
if (ru->dft_in_levdB == -1) {
|
||||
int sigenergy = 0;
|
||||
for (int aa = 0; aa < ru->nb_rx; aa++)
|
||||
sigenergy += signal_energy(ru->common.rxdata[aa] + get_samples_slot_timestamp(fp, proc->tti_rx), 2048);
|
||||
ru->dft_in_levdB = dB_fixed(sigenergy) + 40;
|
||||
}
|
||||
ru->feprx(ru, proc->tti_rx);
|
||||
LOG_D(NR_PHY, "Setting %d.%d (%d) to busy\n", proc->frame_rx, proc->tti_rx, proc->tti_rx % RU_RX_SLOT_DEPTH);
|
||||
//LOG_M("rxdata.m","rxs",ru->common.rxdata[0],1228800,1,1);
|
||||
LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx);
|
||||
|
||||
@@ -1137,13 +1137,100 @@ int pbch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_da
|
||||
// Buffer to hold estimates of symbol 1 for FO compensation in symbol 3
|
||||
c16_t pbch_ch_est_sym1[NR_PBCH_NUM_RB * NR_NB_SC_PER_RB];
|
||||
|
||||
int ssbIndex = -1;
|
||||
// TODO: Remove loopover symbols when symbol based receiver is fully integrated.
|
||||
for (int symbol = 0; symbol < fp->symbols_per_slot; symbol++) {
|
||||
const int pbch_sampleShift =
|
||||
pbch_process(ue, proc, symbol, &ssbIndex, pbch_ch_est_sym1, pbch_ch_est_time, pbch_e_rx, &pbchSymbCnt);
|
||||
// To prevent overwrite estimated shift by consecutive symbol calls
|
||||
sampleShift = (sampleShift == INT_MAX) ? pbch_sampleShift : sampleShift;
|
||||
const int default_ssb_period = 2;
|
||||
const int ssb_period = ue->received_config_request ? ue->nrUE_config.ssb_table.ssb_period : default_ssb_period;
|
||||
if (ssb_period == 0 || !(frame_rx % (1 << (ssb_period - 1)))) {
|
||||
const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size;
|
||||
// loop over SSB blocks
|
||||
for (int ssb_index = 0; ssb_index < fp->Lmax; ssb_index++) {
|
||||
// check if current SSB is transmitted
|
||||
if (is_ssb_index_transmitted(ue, ssb_index)) {
|
||||
int ssb_start_symbol = nr_get_ssb_start_symbol(fp, ssb_index);
|
||||
int ssb_slot = ssb_start_symbol/fp->symbols_per_slot;
|
||||
int ssb_slot_2 = (ssb_period == 0) ? ssb_slot + (fp->slots_per_frame >> 1) : -1;
|
||||
|
||||
if (ssb_slot == nr_slot_rx || ssb_slot_2 == nr_slot_rx) {
|
||||
LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
|
||||
|
||||
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz];
|
||||
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size];
|
||||
|
||||
for (int i=1; i<4; i++) {
|
||||
if (i == 1)
|
||||
ue->dft_in_levdB = -1; // trigger recalculation of DFT scaling
|
||||
nr_slot_fep(ue,
|
||||
fp,
|
||||
proc->nr_slot_rx,
|
||||
(ssb_start_symbol + i) % (fp->symbols_per_slot),
|
||||
rxdataF,
|
||||
link_type_dl,
|
||||
0,
|
||||
ue->common_vars.rxdata);
|
||||
|
||||
nr_pbch_channel_estimation(&ue->frame_parms,
|
||||
NULL,
|
||||
estimateSz,
|
||||
dl_ch_estimates,
|
||||
dl_ch_estimates_time,
|
||||
proc,
|
||||
(ssb_start_symbol + i) % (fp->symbols_per_slot),
|
||||
i - 1,
|
||||
ssb_index & 7,
|
||||
ssb_slot_2 == nr_slot_rx,
|
||||
fp->ssb_start_subcarrier,
|
||||
rxdataF,
|
||||
false,
|
||||
fp->Nid_cell);
|
||||
|
||||
if (i - 1 == 2)
|
||||
UEscopeCopy(ue,
|
||||
pbchDlChEstimateTime,
|
||||
(void *)dl_ch_estimates_time,
|
||||
sizeof(c16_t),
|
||||
fp->nb_antennas_rx,
|
||||
fp->ofdm_symbol_size,
|
||||
0);
|
||||
}
|
||||
|
||||
nr_ue_ssb_rsrp_measurements(ue, ssb_index, proc, rxdataF);
|
||||
|
||||
// resetting ssb index for PBCH detection if there is a stronger SSB index
|
||||
if(ue->measurements.ssb_rsrp_dBm[ssb_index] > ue->measurements.ssb_rsrp_dBm[fp->ssb_index]) {
|
||||
fp->ssb_index = ssb_index;
|
||||
LOG_D(PHY, "New best SSB: index %d RSRP %d\n", ssb_index, ue->measurements.ssb_rsrp_dBm[ssb_index]);
|
||||
}
|
||||
|
||||
if(ssb_index != fp->ssb_index)
|
||||
continue;
|
||||
|
||||
LOG_D(PHY, " ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx % 1024, nr_slot_rx);
|
||||
const int pbchSuccess = nr_ue_pbch_procedures(ue, proc, estimateSz, dl_ch_estimates, rxdataF);
|
||||
|
||||
if (ue->no_timing_correction == 0 && pbchSuccess == 0) {
|
||||
LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
|
||||
sampleShift =
|
||||
nr_adjust_synch_ue(fp, ue, fp->ofdm_symbol_size, dl_ch_estimates_time, frame_rx, nr_slot_rx, 16384);
|
||||
}
|
||||
|
||||
if (get_nrUE_params()->cont_fo_comp && pbchSuccess == 0) {
|
||||
double freq_offset = nr_ue_pbch_freq_offset(fp, estimateSz, dl_ch_estimates);
|
||||
LOG_D(PHY,
|
||||
"compensated freq offset = %.3f Hz, detected residual freq offset = %.3f Hz, accumulated freq offset = %.3f Hz\n",
|
||||
ue->freq_offset,
|
||||
freq_offset,
|
||||
ue->freq_off_acc);
|
||||
|
||||
// PI controller
|
||||
const double PID_P = get_nrUE_params()->freq_sync_P;
|
||||
const double PID_I = get_nrUE_params()->freq_sync_I;
|
||||
ue->freq_offset += freq_offset * PID_P + ue->freq_off_acc * PID_I;
|
||||
ue->freq_off_acc += freq_offset;
|
||||
}
|
||||
|
||||
LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__);
|
||||
nr_ue_rrc_measurements(ue, proc, rxdataF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user