Commit 9574efbf authored by Florian Kaltenberger's avatar Florian Kaltenberger
Browse files

Merge remote-tracking branch 'origin/nr_ssb_periodicity' into integration-nr-2019-w21

parents 4cd3d635 acc88008
...@@ -169,6 +169,7 @@ static void UE_synch(void *arg) { ...@@ -169,6 +169,7 @@ static void UE_synch(void *arg) {
int freq_offset=0; int freq_offset=0;
UE->is_synchronized = 0; UE->is_synchronized = 0;
if (UE->UE_scan == 0) { if (UE->UE_scan == 0) {
get_band(downlink_frequency[CC_id][0], &UE->frame_parms.eutra_band, &uplink_frequency_offset[CC_id][0], &UE->frame_parms.frame_type); get_band(downlink_frequency[CC_id][0], &UE->frame_parms.eutra_band, &uplink_frequency_offset[CC_id][0], &UE->frame_parms.frame_type);
LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n", LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n",
...@@ -239,7 +240,7 @@ static void UE_synch(void *arg) { ...@@ -239,7 +240,7 @@ static void UE_synch(void *arg) {
case pbch: case pbch:
LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode);
if (nr_initial_sync( &syncD->proc, UE, UE->mode ) == 0) { if (nr_initial_sync( &syncD->proc, UE, UE->mode,2) == 0) {
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 = (UE->rx_offset<<1) / UE->frame_parms.samples_per_slot; hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_slot;
LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n", LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n",
...@@ -348,7 +349,7 @@ static void UE_synch(void *arg) { ...@@ -348,7 +349,7 @@ static void UE_synch(void *arg) {
} }
} }
void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
// Process Rx data for one sub-frame // Process Rx data for one sub-frame
if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) {
//clean previous FAPI MESSAGE //clean previous FAPI MESSAGE
...@@ -376,9 +377,9 @@ void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { ...@@ -376,9 +377,9 @@ void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
#else #else
uint64_t a=rdtsc(); uint64_t a=rdtsc();
phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode); phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode, UE_mac->phy_config.config_req.pbch_config);
LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500); LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500);
// printf(">>> nr_ue_pdcch_procedures ended\n"); //printf(">>> nr_ue_pdcch_procedures ended\n");
#endif #endif
} }
...@@ -413,7 +414,7 @@ void UE_processing(void *arg) { ...@@ -413,7 +414,7 @@ void UE_processing(void *arg) {
processingData_t *rxtxD=(processingData_t *) arg; processingData_t *rxtxD=(processingData_t *) arg;
UE_nr_rxtx_proc_t *proc = &rxtxD->proc; UE_nr_rxtx_proc_t *proc = &rxtxD->proc;
PHY_VARS_NR_UE *UE = rxtxD->UE; PHY_VARS_NR_UE *UE = rxtxD->UE;
processSubframeRX(UE, proc); processSlotRX(UE, proc);
//printf(">>> mac ended\n"); //printf(">>> mac ended\n");
// Prepare the future Tx data // Prepare the future Tx data
#if 0 #if 0
...@@ -447,7 +448,7 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { ...@@ -447,7 +448,7 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4); dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4);
for(int x=0; x<10; x++) { for(int x=0; x<20; x++) { // two frames for initial sync
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) + 4*x*UE->frame_parms.samples_per_subframe; rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) + 4*x*UE->frame_parms.samples_per_subframe;
...@@ -613,6 +614,7 @@ void *UE_thread(void *arg) { ...@@ -613,6 +614,7 @@ void *UE_thread(void *arg) {
continue; continue;
} }
absolute_slot++; absolute_slot++;
// whatever means thread_idx // whatever means thread_idx
// Fix me: will be wrong when slot 1 is slow, as slot 2 finishes // Fix me: will be wrong when slot 1 is slow, as slot 2 finishes
......
...@@ -393,7 +393,7 @@ static void get_options(void) { ...@@ -393,7 +393,7 @@ static void get_options(void) {
uint32_t online_log_messages; uint32_t online_log_messages;
uint32_t glog_level, glog_verbosity; uint32_t glog_level, glog_verbosity;
uint32_t start_telnetsrv=0; uint32_t start_telnetsrv=0;
paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC_UE ;
paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
/* command line parameters common to eNodeB and UE */ /* command line parameters common to eNodeB and UE */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_PARAMS_DESC { \ #define CMDLINE_PARAMS_DESC_UE { \
{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \
{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \
......
...@@ -398,6 +398,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { ...@@ -398,6 +398,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
gNB_config->sch_config.n_ssb_crb.value = (phy_config->cfg->rf_config.dl_carrier_bandwidth.value-20); gNB_config->sch_config.n_ssb_crb.value = (phy_config->cfg->rf_config.dl_carrier_bandwidth.value-20);
gNB_config->sch_config.physical_cell_id.value = phy_config->cfg->sch_config.physical_cell_id.value; gNB_config->sch_config.physical_cell_id.value = phy_config->cfg->sch_config.physical_cell_id.value;
gNB_config->sch_config.ssb_scg_position_in_burst.value= phy_config->cfg->sch_config.ssb_scg_position_in_burst.value; gNB_config->sch_config.ssb_scg_position_in_burst.value= phy_config->cfg->sch_config.ssb_scg_position_in_burst.value;
gNB_config->sch_config.ssb_periodicity.value = phy_config->cfg->sch_config.ssb_periodicity.value;
if (phy_config->cfg->subframe_config.duplex_mode.value == 0) { if (phy_config->cfg->subframe_config.duplex_mode.value == 0) {
gNB_config->subframe_config.duplex_mode.value = TDD; gNB_config->subframe_config.duplex_mode.value = TDD;
......
...@@ -715,14 +715,13 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ...@@ -715,14 +715,13 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
} }
// init RX buffers // init RX buffers
common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); common_vars->common_vars_rx_data_per_thread[th_id].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
} }
for (i=0; i<fp->nb_antennas_rx; i++) { for (i=0; i<fp->nb_antennas_rx; i++) {
common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_subframe*10+2048)*sizeof(int32_t) ); common_vars->rxdata[i] = (int32_t*) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) );
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) );
} }
...@@ -905,6 +904,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ...@@ -905,6 +904,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
ue->decode_MIB = 1; ue->decode_MIB = 1;
ue->decode_SIB = 1; ue->decode_SIB = 1;
ue->ssb_periodicity = 5; // initialization of ssb periodicity to 5ms according to TS38.213 section 4.1
init_prach_tables(839); init_prach_tables(839);
......
...@@ -117,8 +117,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -117,8 +117,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
return(-1); return(-1);
} }
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
memset(&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int)); memset(&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int));
...@@ -135,13 +133,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -135,13 +133,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
if (symbol==0) { if (symbol==0) {
if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
memcpy((short *)&common_vars->rxdata[aa][frame_length_samples], memcpy((short*) &common_vars->rxdata[aa][frame_length_samples],
(short *)&common_vars->rxdata[aa][0], (short*) &common_vars->rxdata[aa][0],
frame_parms->ofdm_symbol_size*sizeof(int)); frame_parms->ofdm_symbol_size*sizeof(int));
if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs
memcpy((void *)tmp_dft_in, memcpy((void *)tmp_dft_in,
(void *)&common_vars->rxdata[aa][rx_offset % frame_length_samples], (void *) &common_vars->rxdata[aa][rx_offset % frame_length_samples],
frame_parms->ofdm_symbol_size*sizeof(int)); frame_parms->ofdm_symbol_size*sizeof(int));
dft((int16_t *)tmp_dft_in, dft((int16_t *)tmp_dft_in,
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
...@@ -150,19 +148,20 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -150,19 +148,20 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
start_meas(&ue->rx_dft_stats); start_meas(&ue->rx_dft_stats);
#endif #endif
dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
stop_meas(&ue->rx_dft_stats); stop_meas(&ue->rx_dft_stats);
#endif #endif
} }
} else { } else {
rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol;// +
// (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol;
// + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1);
if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
memcpy((void *)&common_vars->rxdata[aa][frame_length_samples], memcpy((void *) &common_vars->rxdata[aa][frame_length_samples],
(void *)&common_vars->rxdata[aa][0], (void *) &common_vars->rxdata[aa][0],
frame_parms->ofdm_symbol_size*sizeof(int)); frame_parms->ofdm_symbol_size*sizeof(int));
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats); start_meas(&ue->rx_dft_stats);
...@@ -170,13 +169,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -170,13 +169,13 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
if ((rx_offset&7)!=0) { // if input to dft is not 128-bit aligned, issue for size 6 and 15 PRBs if ((rx_offset&7)!=0) { // if input to dft is not 128-bit aligned, issue for size 6 and 15 PRBs
memcpy((void *)tmp_dft_in, memcpy((void *)tmp_dft_in,
(void *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], (void *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
frame_parms->ofdm_symbol_size*sizeof(int)); frame_parms->ofdm_symbol_size*sizeof(int));
dft((int16_t *)tmp_dft_in, dft((int16_t *)tmp_dft_in,
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
} else { // use dft input from RX buffer directly } else { // use dft input from RX buffer directly
dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
} }
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
...@@ -192,6 +191,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -192,6 +191,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#endif #endif
} }
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
printf("slot_fep: done\n"); printf("slot_fep: done\n");
#endif #endif
......
...@@ -134,10 +134,11 @@ void free_context_synchro_nr(void); ...@@ -134,10 +134,11 @@ void free_context_synchro_nr(void);
void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue); void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue);
void free_context_pss_nr(void); void free_context_pss_nr(void);
int set_pss_nr(int ofdm_symbol_size); int set_pss_nr(int ofdm_symbol_size);
int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change); 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 is,
int *eNB_id, int *eNB_id,
int *f_off); int *f_off);
......
...@@ -65,7 +65,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, ...@@ -65,7 +65,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
k = nushift; k = nushift;
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns>>1], eNB_offset,ue->frame_parms.ofdm_symbol_size, printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
...@@ -324,6 +324,9 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -324,6 +324,9 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1); re_offset = (re_offset+4)&(ue->frame_parms.ofdm_symbol_size-1);
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif #endif
...@@ -441,8 +444,8 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -441,8 +444,8 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
k = coreset_start_subcarrier; k = coreset_start_subcarrier;
#ifdef DEBUG_PDCCH #ifdef DEBUG_PDCCH
printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,l,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
fl = filt16a_l1; fl = filt16a_l1;
...@@ -638,6 +641,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -638,6 +641,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
unsigned short bwp_start_subcarrier, unsigned short bwp_start_subcarrier,
unsigned short nb_rb_pdsch) unsigned short nb_rb_pdsch)
{ {
int pilot[1320] __attribute__((aligned(16))); int pilot[1320] __attribute__((aligned(16)));
unsigned char aarx; unsigned char aarx;
unsigned short k; unsigned short k;
...@@ -665,8 +669,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -665,8 +669,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
int re_offset = k; int re_offset = k;
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size, printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,l,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
switch (nushift) { switch (nushift) {
......
...@@ -201,13 +201,14 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini ...@@ -201,13 +201,14 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
char duplex_string[2][4] = {"FDD","TDD"}; char duplex_string[2][4] = {"FDD","TDD"};
char prefix_string[2][9] = {"NORMAL","EXTENDED"}; char prefix_string[2][9] = {"NORMAL","EXTENDED"};
int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, int n_frames)
{ {
int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2, int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2,
int32_t metric_tdd_ncp=0; int32_t metric_tdd_ncp=0;
uint8_t phase_tdd_ncp; uint8_t phase_tdd_ncp;
double im, re; double im, re;
int is;
NR_DL_FRAME_PARMS *fp = &ue->frame_parms; NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
int ret=-1; int ret=-1;
...@@ -222,10 +223,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -222,10 +223,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode)
nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,0); nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,0);
LOG_D(PHY,"nr_initial sync ue RB_DL %d\n", fp->N_RB_DL); LOG_D(PHY,"nr_initial sync ue RB_DL %d\n", fp->N_RB_DL);
/*
write_output("rxdata0.m","rxd0",ue->common_vars.rxdata[0],10*fp->samples_per_subframe,1,1);
exit(-1);
*/
/* Initial synchronisation /* Initial synchronisation
* *
...@@ -242,26 +240,27 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -242,26 +240,27 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode)
cnt++; cnt++;
if (1){ // (cnt>100) if (1){ // (cnt>100)
cnt =0; cnt =0;
/* process pss search on received buffer */ // initial sync performed on two successive frames, if pbch passes on first frame, no need to process second frame
sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE); // only one frame is used for symulation tools
for(is=0; is<n_frames;is++) {
if (sync_pos >= fp->nb_prefix_samples) /* process pss search on received buffer */
ue->ssb_offset = sync_pos - fp->nb_prefix_samples; sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE);
else
ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples;
if (sync_pos >= fp->nb_prefix_samples)
//write_output("rxdata1.m","rxd1",ue->common_vars.rxdata[0],10*fp->samples_per_subframe,1,1); ue->ssb_offset = sync_pos - fp->nb_prefix_samples;
else
ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples;
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id); LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id);
LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset);
#endif #endif
// 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
double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample
...@@ -276,11 +275,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -276,11 +275,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode)
((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle)));
} }
} }
} }
/* check that SSS/PBCH block is continuous inside the received buffer */ /* check that SSS/PBCH block is continuous inside the received buffer */
if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) { if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) {
/* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */ /* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */
/* for NR this is not the case but slot_fep is still used for computing FFT of samples */ /* for NR this is not the case but slot_fep is still used for computing FFT of samples */
...@@ -291,33 +289,33 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -291,33 +289,33 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode)
/* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ /* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
/* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */ /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
for(int i=0; i<4;i++) for(int i=0; i<4;i++)
nr_slot_fep(ue, nr_slot_fep(ue,
i, i,
0, 0,
ue->ssb_offset, ue->ssb_offset,
0); 0);
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"Calling sss detection (normal CP)\n"); LOG_I(PHY,"Calling sss detection (normal CP)\n");
#endif #endif
rx_sss_nr(ue,&metric_tdd_ncp,&phase_tdd_ncp); rx_sss_nr(ue,&metric_tdd_ncp,&phase_tdd_ncp);
//FK: why do we need to do this again here? //FK: why do we need to do this again here?
//nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0); //nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0);
nr_gold_pbch(ue); nr_gold_pbch(ue);
ret = nr_pbch_detection(proc, ue,1,mode); // start pbch detection at first symbol after pss ret = nr_pbch_detection(proc, ue,1,mode); // start pbch detection at first symbol after pss
if (ret == 0) { if (ret == 0) {
// 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
sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples); sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
ue->rx_offset = ue->ssb_offset - sync_pos_frame; ue->rx_offset = ue->ssb_offset - sync_pos_frame;
} }
nr_gold_pdcch(ue,0, 2); nr_gold_pdcch(ue,0, 2);
/* /*
int nb_prefix_samples0 = fp->nb_prefix_samples0; int nb_prefix_samples0 = fp->nb_prefix_samples0;
fp->nb_prefix_samples0 = fp->nb_prefix_samples; fp->nb_prefix_samples0 = fp->nb_prefix_samples;
...@@ -333,16 +331,20 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -333,16 +331,20 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode)
ue->common_vars.freq_offset ); ue->common_vars.freq_offset );
*/ */
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"TDD Normal prefix: CellId %d metric %d, phase %d, pbch %d\n", LOG_I(PHY,"TDD Normal prefix: CellId %d metric %d, phase %d, pbch %d\n",
fp->Nid_cell,metric_tdd_ncp,phase_tdd_ncp,ret); fp->Nid_cell,metric_tdd_ncp,phase_tdd_ncp,ret);
#endif #endif
}
else { }
else {
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
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);