Commit ecaa424c authored by Francesco Mani's avatar Francesco Mani

fixes in how sync for two frames is handled in pss functions, it works

parent 385dcea7
...@@ -138,7 +138,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change); ...@@ -138,7 +138,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change);
int pss_search_time_nr(int **rxdata, ///rx data in time domain int pss_search_time_nr(int **rxdata, ///rx data in time domain
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
int fo_flag, int fo_flag,
int corr_samples, int is,
int *eNB_id, int *eNB_id,
int *f_off); int *f_off);
......
...@@ -608,14 +608,10 @@ void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_ch ...@@ -608,14 +608,10 @@ void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_ch
* *
********************************************************************/ ********************************************************************/
void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int is, int **rxdata) void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **rxdata)
{ {
int samples_for_frame;
NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms);
if (is==0) int samples_for_frame = 2*frame_parms->samples_per_frame;
samples_for_frame = frame_parms->samples_per_frame + frame_parms->ofdm_symbol_size;
else
samples_for_frame = frame_parms->samples_per_frame;
AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti); AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti);
...@@ -630,11 +626,11 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int is, ...@@ -630,11 +626,11 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int is,
/* build with cic filter does not work properly. Performances are significantly deteriorated */ /* build with cic filter does not work properly. Performances are significantly deteriorated */
#ifdef CIC_DECIMATOR #ifdef CIC_DECIMATOR
cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][is*frame_parms->samples_per_frame]), (int16_t *)&(rxdata[0][0]), cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata_is[0][0]), (int16_t *)&(rxdata[0][0]),
samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE); samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE);
#else #else
fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][frame_parms->samples_per_frame]), (int16_t *)&(rxdata[0][0]), fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata_is[0][0]), (int16_t *)&(rxdata[0][0]),
samples_for_frame, rate_change, 0); samples_for_frame, rate_change, 0);
#endif #endif
...@@ -666,44 +662,36 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) ...@@ -666,44 +662,36 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change)
{ {
NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms);
int synchro_position; int synchro_position;
int **rxdata; int **rxdata = NULL;
int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation
int samples_for_frame;
// to take into account the possibility of PSS to be found between the two frames
// the analysis of the first of two frames is extended by one symbol (duration of PSS)
if (is==0)
samples_for_frame = frame_parms->samples_per_frame + frame_parms->ofdm_symbol_size;
else
samples_for_frame = frame_parms->samples_per_frame;
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], 2*frame_parms->samples_per_frame, 1, 1);
#endif
rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata_is[0][0], frame_parms->samples_per_frame, 1, 1);
for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++)
rxdata[aa] = (int32_t*) malloc16_clear( (samples_for_frame+8192)*sizeof(int32_t)); #endif
if (rate_change != 1) { if (rate_change != 1) {
rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*));
for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) {
rxdata[aa] = (int32_t*) malloc16_clear( (frame_parms->samples_per_frame+8192)*sizeof(int32_t));
}
#ifdef SYNCHRO_DECIMAT #ifdef SYNCHRO_DECIMAT
decimation_synchro_nr(PHY_vars_UE, rate_change, is, rxdata); decimation_synchro_nr(PHY_vars_UE, rate_change, rxdata);
#endif #endif
} }
else { else {
for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++)
memcpy(&(rxdata[aa][0]),
&(PHY_vars_UE->common_vars.rxdata[aa][is*frame_parms->samples_per_frame]),
samples_for_frame*sizeof(int32_t));
rxdata = PHY_vars_UE->common_vars.rxdata_is;
} }
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
LOG_M("rxdata0_des.m","rxd0_des", &rxdata[0][0], samples_for_frame,1,1); LOG_M("rxdata0_des.m","rxd0_des", &rxdata[0][0], frame_parms->samples_per_frame,1,1);
#endif #endif
...@@ -718,7 +706,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) ...@@ -718,7 +706,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change)
synchro_position = pss_search_time_nr(rxdata, synchro_position = pss_search_time_nr(rxdata,
frame_parms, frame_parms,
fo_flag, fo_flag,
samples_for_frame, is,
(int *)&PHY_vars_UE->common_vars.eNb_id, (int *)&PHY_vars_UE->common_vars.eNb_id,
(int *)&PHY_vars_UE->common_vars.freq_offset); (int *)&PHY_vars_UE->common_vars.freq_offset);
...@@ -738,20 +726,26 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) ...@@ -738,20 +726,26 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change)
#endif #endif
#ifdef SYNCHRO_DECIMAT #ifdef SYNCHRO_DECIMAT
if (rate_change != 1)
restore_frame_context_pss_nr(frame_parms, rate_change); if (rate_change != 1) {
#endif
if (rxdata[0] != NULL) { if (rxdata[0] != NULL) {
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
free(rxdata[aa]); free(rxdata[aa]);
}
free(rxdata); free(rxdata);
} }
restore_frame_context_pss_nr(frame_parms, rate_change);
}
#endif
return synchro_position; return synchro_position;
} }
static inline int abs32(int x) static inline int abs32(int x)
{ {
return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1])); return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1]));
...@@ -777,7 +771,7 @@ static inline double angle64(int64_t x) ...@@ -777,7 +771,7 @@ static inline double angle64(int64_t x)
* *
* PARAMETERS : received buffer * PARAMETERS : received buffer
* frame parameters * frame parameters
* *https://www.ilpost.it/
* RETURN : position of detected pss * RETURN : position of detected pss
* *
* DESCRIPTION : Synchronisation on pss sequence is based on a time domain correlation between received samples and pss sequence * DESCRIPTION : Synchronisation on pss sequence is based on a time domain correlation between received samples and pss sequence
...@@ -826,7 +820,7 @@ static inline double angle64(int64_t x) ...@@ -826,7 +820,7 @@ static inline double angle64(int64_t x)
int pss_search_time_nr(int **rxdata, ///rx data in time domain int pss_search_time_nr(int **rxdata, ///rx data in time domain
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
int fo_flag, int fo_flag,
int corr_samples, int is,
int *eNB_id, int *eNB_id,
int *f_off) int *f_off)
{ {
...@@ -836,13 +830,18 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -836,13 +830,18 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
int64_t avg[NUMBER_PSS_SEQUENCE]; int64_t avg[NUMBER_PSS_SEQUENCE];
double ffo_est=0; double ffo_est=0;
// performing the correlation on a frame length plus one symbol for the first of the two frame
unsigned int length = corr_samples; // to take into account the possibility of PSS in between the two frames
unsigned int length;
if (is==0)
length = frame_parms->samples_per_frame + (2*frame_parms->ofdm_symbol_size);
else
length = frame_parms->samples_per_frame;
AssertFatal(length>0,"illegal length %d\n",length); AssertFatal(length>0,"illegal length %d\n",length);
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i); for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i);
printf("%d\n\n",length);
peak_value = 0; peak_value = 0;
peak_position = 0; peak_position = 0;
pss_source = 0; pss_source = 0;
...@@ -878,7 +877,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -878,7 +877,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
/* perform correlation of rx data and pss sequence ie it is a dot product */ /* perform correlation of rx data and pss sequence ie it is a dot product */
result = dot_product64((short*)primary_synchro_time_nr[pss_index], result = dot_product64((short*)primary_synchro_time_nr[pss_index],
(short*) &(rxdata[ar][n]), (short*) &(rxdata[ar][n])+(is*frame_parms->samples_per_frame),
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
shift); shift);
pss_corr_ue[pss_index][n] += abs64(result); pss_corr_ue[pss_index][n] += abs64(result);
...@@ -912,13 +911,13 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -912,13 +911,13 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
int64_t result1,result2; int64_t result1,result2;
// Computing cross-correlation at peak on half the symbol size for first half of data // Computing cross-correlation at peak on half the symbol size for first half of data
result1 = dot_product64((short*)primary_synchro_time_nr[pss_source], result1 = dot_product64((short*)primary_synchro_time_nr[pss_source],
(short*) &(rxdata[0][peak_position]), (short*) &(rxdata[0][peak_position])+(is*frame_parms->samples_per_frame),
frame_parms->ofdm_symbol_size>>1, frame_parms->ofdm_symbol_size>>1,
shift); shift);
// Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size // Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size
// as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift // as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift
result2 = dot_product64((short*)primary_synchro_time_nr[pss_source]+(frame_parms->ofdm_symbol_size), result2 = dot_product64((short*)primary_synchro_time_nr[pss_source]+(frame_parms->ofdm_symbol_size),
(short*) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size), (short*) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size+(is*frame_parms->samples_per_frame)),
frame_parms->ofdm_symbol_size>>1, frame_parms->ofdm_symbol_size>>1,
shift); shift);
...@@ -957,6 +956,9 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -957,6 +956,9 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6); LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6);
LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6); LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6);
LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6); LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6);
if (is)
LOG_M("rxdata1.m","rxd0",rxdata[frame_parms->samples_per_frame],length,1,1);
else
LOG_M("rxdata0.m","rxd0",rxdata[0],length,1,1); LOG_M("rxdata0.m","rxd0",rxdata[0],length,1,1);
} else { } else {
debug_cnt++; debug_cnt++;
......
...@@ -71,7 +71,7 @@ gNBs = ...@@ -71,7 +71,7 @@ gNBs =
UL_timeAlignmentTimerCommon = "infinity"; UL_timeAlignmentTimerCommon = "infinity";
ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_n_TimingAdvanceOffset = "n0"
ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01;
ServingCellConfigCommon_ssb_periodicityServingCell = 20; ServingCellConfigCommon_ssb_periodicityServingCell = 10;
ServingCellConfigCommon_dmrs_TypeA_Position = 2; ServingCellConfigCommon_dmrs_TypeA_Position = 2;
NIA_SubcarrierSpacing = "kHz15"; NIA_SubcarrierSpacing = "kHz15";
ServingCellConfigCommon_ss_PBCH_BlockPower = -60; ServingCellConfigCommon_ss_PBCH_BlockPower = -60;
......
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