Commit ee3dcc5c authored by francescomani's avatar francescomani

replacing cell_notdetected with cell_detected in initial_sync structure

parent 1fa6be2a
...@@ -440,7 +440,7 @@ static void UE_synch(void *arg) { ...@@ -440,7 +440,7 @@ static void UE_synch(void *arg) {
uint64_t dl_carrier, ul_carrier; uint64_t dl_carrier, ul_carrier;
nr_get_carrier_frequencies(UE, &dl_carrier, &ul_carrier); nr_get_carrier_frequencies(UE, &dl_carrier, &ul_carrier);
nr_initial_sync_t ret = nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa); nr_initial_sync_t ret = nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa);
if (!ret.cell_notdetected) { if (ret.cell_detected) {
syncD->rx_offset = ret.rx_offset; syncD->rx_offset = ret.rx_offset;
freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync
hw_slot_offset = hw_slot_offset =
......
...@@ -100,10 +100,10 @@ void free_list(NR_UE_SSB *node) { ...@@ -100,10 +100,10 @@ void free_list(NR_UE_SSB *node) {
free(node); free(node);
} }
int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
int pbch_initial_symbol, int pbch_initial_symbol,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
{ {
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
...@@ -138,8 +138,8 @@ int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, ...@@ -138,8 +138,8 @@ int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
} }
NR_UE_SSB *temp_ptr = best_ssb; NR_UE_SSB *temp_ptr = best_ssb;
int ret = -1; bool ret = false;
while (ret != 0 && temp_ptr != NULL) { while (!ret && temp_ptr != NULL) {
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
// computing channel estimation for selected best ssb // computing channel estimation for selected best ssb
...@@ -153,11 +153,18 @@ int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, ...@@ -153,11 +153,18 @@ int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
stop_meas(&ue->dlsch_channel_estimation_stats); stop_meas(&ue->dlsch_channel_estimation_stats);
fapiPbch_t result = {0}; fapiPbch_t result = {0};
ret = nr_rx_pbch(ue, proc, estimateSz, dl_ch_estimates, frame_parms, temp_ptr->i_ssb, &result, rxdataF);
if (DUMP_PBCH_CH_ESTIMATES && (ret == 0)) { int pbch_res = nr_rx_pbch(ue, proc, estimateSz, dl_ch_estimates, frame_parms, temp_ptr->i_ssb, &result, rxdataF);
ret = pbch_res == 0;
if (DUMP_PBCH_CH_ESTIMATES && ret) {
write_output("pbch_ch_estimates.m", "pbch_ch_estimates", dl_ch_estimates, frame_parms->nb_antennas_rx*estimateSz, 1, 1); write_output("pbch_ch_estimates.m", "pbch_ch_estimates", dl_ch_estimates, frame_parms->nb_antennas_rx*estimateSz, 1, 1);
write_output("pbch_ch_estimates_time.m", "pbch_ch_estimates_time", dl_ch_estimates_time, frame_parms->nb_antennas_rx*frame_parms->ofdm_symbol_size, 1, 1); write_output("pbch_ch_estimates_time.m",
"pbch_ch_estimates_time",
dl_ch_estimates_time,
frame_parms->nb_antennas_rx * frame_parms->ofdm_symbol_size,
1,
1);
} }
temp_ptr=temp_ptr->next_ssb; temp_ptr=temp_ptr->next_ssb;
...@@ -165,7 +172,7 @@ int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, ...@@ -165,7 +172,7 @@ int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
free_list(best_ssb); free_list(best_ssb);
if (ret == 0) { if (ret) {
frame_parms->nb_antenna_ports_gNB = 1; // pbch_tx_ant; frame_parms->nb_antenna_ports_gNB = 1; // pbch_tx_ant;
LOG_I(PHY, "[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n", ue->Mod_id, frame_parms->ssb_index); LOG_I(PHY, "[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n", ue->Mod_id, frame_parms->ssb_index);
} }
...@@ -258,7 +265,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -258,7 +265,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
int freq_offset_sss = 0; int freq_offset_sss = 0;
bool ret_sss = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss, rxdataF); bool ret_sss = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss, rxdataF);
ret.cell_notdetected = !ret_sss; // rx_sss_nr returns true if success ret.cell_detected = ret_sss; // rx_sss_nr returns true if success
// digital compensation of FFO for SSB symbols // digital compensation of FFO for SSB symbols
if (ue->UE_fo_compensation) { if (ue->UE_fo_compensation) {
double s_time = 1 / (1.0e3 * fp->samples_per_subframe); // sampling time double s_time = 1 / (1.0e3 * fp->samples_per_subframe); // sampling time
...@@ -278,12 +285,12 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -278,12 +285,12 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
ue->common_vars.freq_offset += freq_offset_sss; ue->common_vars.freq_offset += freq_offset_sss;
} }
if (ret.cell_notdetected == 0) { // we got sss channel if (ret.cell_detected) { // we got sss channel
nr_gold_pbch(ue); nr_gold_pbch(ue);
ret.cell_notdetected = nr_pbch_detection(proc, ue, 1, rxdataF); // start pbch detection at first symbol after pss ret.cell_detected = nr_pbch_detection(proc, ue, 1, rxdataF); // start pbch detection at first symbol after pss
} }
if (ret.cell_notdetected == 0) { if (ret.cell_detected) {
// sync at symbol ue->symbol_offset // sync at symbol ue->symbol_offset
// computing the offset wrt the beginning of the frame // computing the offset wrt the beginning of the frame
int mu = fp->numerology_index; int mu = fp->numerology_index;
...@@ -343,7 +350,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -343,7 +350,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
fp->Nid_cell, fp->Nid_cell,
metric_tdd_ncp, metric_tdd_ncp,
phase_tdd_ncp, phase_tdd_ncp,
!ret.cell_notdetected, ret.cell_detected,
ret.rx_offset); ret.rx_offset);
#endif #endif
...@@ -352,11 +359,11 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -352,11 +359,11 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
LOG_I(PHY, "TDD Normal prefix: SSS error condition: sync_pos %d\n", sync_pos); LOG_I(PHY, "TDD Normal prefix: SSS error condition: sync_pos %d\n", sync_pos);
#endif #endif
} }
if (ret.cell_notdetected == 0) if (ret.cell_detected)
break; break;
} }
} else { } else {
ret.cell_notdetected = true; ret.cell_detected = false;
} }
/* Consider this is a false detection if the offset is > 1000 Hz /* Consider this is a false detection if the offset is > 1000 Hz
...@@ -367,7 +374,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -367,7 +374,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
LOG_E(HW, "Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset); LOG_E(HW, "Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset);
}*/ }*/
if (ret.cell_notdetected == 0) { // PBCH found so indicate sync to higher layers and configure frame parameters if (ret.cell_detected) { // PBCH found so indicate sync to higher layers and configure frame parameters
//#ifdef DEBUG_INITIAL_SYNCH //#ifdef DEBUG_INITIAL_SYNCH
...@@ -402,7 +409,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -402,7 +409,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
} }
// gain control // gain control
if (ret.cell_notdetected != 0) { // we are not synched, so we cannot use rssi measurement (which is based on channel estimates) if (!ret.cell_detected) { // we are not synched, so we cannot use rssi measurement (which is based on channel estimates)
int rx_power = 0; int rx_power = 0;
// do a measurement on the best guess of the PSS // do a measurement on the best guess of the PSS
......
...@@ -319,7 +319,7 @@ int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -319,7 +319,7 @@ int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue,
@param sa current running mode @param sa current running mode
*/ */
typedef struct { typedef struct {
bool cell_notdetected; bool cell_detected;
int rx_offset; int rx_offset;
} nr_initial_sync_t; } nr_initial_sync_t;
nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *phy_vars_ue, int n_frames, int sa); nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *phy_vars_ue, int n_frames, int sa);
......
...@@ -766,10 +766,10 @@ int main(int argc, char **argv) ...@@ -766,10 +766,10 @@ int main(int argc, char **argv)
} }
if (UE->is_synchronized == 0) { if (UE->is_synchronized == 0) {
UE_nr_rxtx_proc_t proc={0}; UE_nr_rxtx_proc_t proc={0};
nr_initial_sync_t ret = nr_initial_sync(&proc, UE, 1, 0); nr_initial_sync_t ret = nr_initial_sync(&proc, UE, 1, 0);
printf("nr_initial_sync1 returns %d\n", ret.cell_notdetected); printf("nr_initial_sync1 returns %s\n", ret.cell_detected ? "cell detected" : "cell not detected");
if (ret.cell_notdetected) if (!ret.cell_detected)
n_errors++; n_errors++;
} }
else { else {
UE_nr_rxtx_proc_t proc={0}; UE_nr_rxtx_proc_t proc={0};
......
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