Revert to timing adjustment based on cyclic prefix and improves it
This commit is contained in:
+5
-20
@@ -456,26 +456,10 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int computeSamplesShift(PHY_VARS_NR_UE *UE) {
|
int computeSamplesShift(PHY_VARS_NR_UE *UE) {
|
||||||
|
int samples_shift = -(UE->rx_offset>>1);
|
||||||
// compute TO compensation that should be applied for this frame
|
UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame
|
||||||
if ( UE->rx_offset < UE->frame_parms.samples_per_frame/2 &&
|
UE->max_pos_fil = 0; // reset IIR filter when sample shift is applied
|
||||||
UE->rx_offset > 0 ) {
|
return samples_shift;
|
||||||
LOG_I(PHY,"!!!adjusting -1 samples!!! rx_offset == %d\n", UE->rx_offset);
|
|
||||||
UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame
|
|
||||||
UE->max_pos_fil = 0; // reset IIR filter when sample shift is applied
|
|
||||||
return -1 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( UE->rx_offset > UE->frame_parms.samples_per_frame/2 &&
|
|
||||||
UE->rx_offset < UE->frame_parms.samples_per_frame ) {
|
|
||||||
int rx_offset = UE->rx_offset - UE->frame_parms.samples_per_frame;
|
|
||||||
LOG_I(PHY,"!!!adjusting +1 samples!!! rx_offset == %d\n", rx_offset);
|
|
||||||
UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame
|
|
||||||
UE->max_pos_fil = 0; // reset IIR filter when sample shift is applied
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
|
static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
|
||||||
@@ -642,6 +626,7 @@ void *UE_thread(void *arg) {
|
|||||||
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms);
|
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms);
|
||||||
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms);
|
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms);
|
||||||
} else {
|
} else {
|
||||||
|
UE->rx_offset_diff = computeSamplesShift(UE);
|
||||||
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) -
|
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) -
|
||||||
UE->rx_offset_diff;
|
UE->rx_offset_diff;
|
||||||
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff;
|
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff;
|
||||||
|
|||||||
@@ -141,8 +141,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
|
|||||||
int *eNB_id,
|
int *eNB_id,
|
||||||
int *f_off);
|
int *f_off);
|
||||||
|
|
||||||
int nr_adjust_pss_synch(PHY_VARS_NR_UE *ue);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|
||||||
|
|||||||
@@ -115,12 +115,6 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ue->rx_offset < 0)
|
|
||||||
ue->rx_offset += frame_parms->samples_per_frame;
|
|
||||||
|
|
||||||
if (ue->rx_offset >= frame_parms->samples_per_frame)
|
|
||||||
ue->rx_offset -= frame_parms->samples_per_frame;
|
|
||||||
|
|
||||||
#ifdef DEBUG_PHY
|
#ifdef DEBUG_PHY
|
||||||
LOG_D(PHY,"AbsSubframe %d: diff = %i, rx_offset (final) = %i : clear = %d, max_pos = %d, max_pos_fil = %d, max_val = %d, sync_pos %d\n",
|
LOG_D(PHY,"AbsSubframe %d: diff = %i, rx_offset (final) = %i : clear = %d, max_pos = %d, max_pos_fil = %d, max_val = %d, sync_pos %d\n",
|
||||||
subframe,
|
subframe,
|
||||||
|
|||||||
@@ -976,62 +976,3 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
|
|||||||
return(peak_position);
|
return(peak_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nr_adjust_pss_synch(PHY_VARS_NR_UE *ue) {
|
|
||||||
|
|
||||||
int **rxdata = ue->common_vars.rxdata;
|
|
||||||
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
|
|
||||||
uint8_t Nid2 = GET_NID2(frame_parms->Nid_cell);
|
|
||||||
int peak_position_ref = ((frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples)<<1) + frame_parms->nb_prefix_samples0;
|
|
||||||
|
|
||||||
int maxval=0;
|
|
||||||
for (int i=0;i<2*(frame_parms->ofdm_symbol_size);i++) {
|
|
||||||
maxval = max(maxval,primary_synchro_time_nr[Nid2][i]);
|
|
||||||
maxval = max(maxval,-primary_synchro_time_nr[Nid2][i]);
|
|
||||||
}
|
|
||||||
int shift = log2_approx(maxval);
|
|
||||||
|
|
||||||
/* Search pss in the received buffer each 4 samples which ensures a memory alignment on 128 bits (32 bits x 4 ) */
|
|
||||||
/* This is required by SIMD (single instruction Multiple Data) Extensions of Intel processors. */
|
|
||||||
/* Correlation computation is based on a dot product which is realized thank to SIMS extensions */
|
|
||||||
int64_t peak_value = 0;
|
|
||||||
int peak_position = 0;
|
|
||||||
int64_t result = 0;
|
|
||||||
int64_t avg=0;
|
|
||||||
int start = peak_position_ref - (frame_parms->ofdm_symbol_size>>3);
|
|
||||||
int length = frame_parms->ofdm_symbol_size + (frame_parms->ofdm_symbol_size>>3);
|
|
||||||
memset(pss_corr_ue[Nid2],0,(start+length)*sizeof(int64_t));
|
|
||||||
for (int n=start; n < start+length; n+=4) { //
|
|
||||||
for (int ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
|
|
||||||
result = dot_product64((short*)primary_synchro_time_nr[Nid2],
|
|
||||||
(short*) &(rxdata[ar][n]),
|
|
||||||
frame_parms->ofdm_symbol_size,
|
|
||||||
shift);
|
|
||||||
pss_corr_ue[Nid2][n] += abs64(result);
|
|
||||||
}
|
|
||||||
avg+=pss_corr_ue[Nid2][n];
|
|
||||||
if (pss_corr_ue[Nid2][n] > peak_value) {
|
|
||||||
peak_value = pss_corr_ue[Nid2][n];
|
|
||||||
peak_position = n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
avg/=(length/4);
|
|
||||||
if (peak_value < 5*avg) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int peak_position_diff = peak_position_ref - peak_position;
|
|
||||||
|
|
||||||
ue->rx_offset_diff = 0;
|
|
||||||
if(peak_position_diff != 0) {
|
|
||||||
ue->rx_offset_diff = peak_position_diff>>3;
|
|
||||||
if (ue->rx_offset_diff == 0) {
|
|
||||||
ue->rx_offset_diff = peak_position_diff > 0 ? 1 : -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_D(NR_PHY,"nr_adjust_pss_synch: peak_position %d, peak_position_diff %d, peak_value %d dB, avg %d dB\n",
|
|
||||||
peak_position, peak_position_diff, dB_fixed64(peak_value),dB_fixed64(avg));
|
|
||||||
|
|
||||||
return peak_position_diff;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1638,12 +1638,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
|
|||||||
|
|
||||||
if ((ue->decode_MIB == 1) && slot_pbch) {
|
if ((ue->decode_MIB == 1) && slot_pbch) {
|
||||||
|
|
||||||
nr_adjust_pss_synch(ue);
|
|
||||||
|
|
||||||
LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
|
LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
|
||||||
nr_ue_pbch_procedures(gNB_id, ue, proc, 0);
|
nr_ue_pbch_procedures(gNB_id, ue, proc, 0);
|
||||||
|
|
||||||
/* if (ue->no_timing_correction==0) {
|
if (ue->no_timing_correction==0) {
|
||||||
LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
|
LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
|
||||||
nr_adjust_synch_ue(fp,
|
nr_adjust_synch_ue(fp,
|
||||||
ue,
|
ue,
|
||||||
@@ -1652,7 +1650,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
|
|||||||
nr_slot_rx,
|
nr_slot_rx,
|
||||||
0,
|
0,
|
||||||
16384);
|
16384);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__);
|
LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__);
|
||||||
nr_ue_rrc_measurements(ue, proc, nr_slot_rx);
|
nr_ue_rrc_measurements(ue, proc, nr_slot_rx);
|
||||||
|
|||||||
Reference in New Issue
Block a user