From 54b7fde0aa7d09abbc573a985abb73526b4b3236 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 27 Sep 2022 10:55:38 +0200 Subject: [PATCH 01/10] NR_UE: fix noise in PDCCH scope --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index cf237ef1fe..f8fe1ccc4c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -682,18 +682,22 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, int32_t avgs; int32_t avgP[4]; int n_rb,rb_offset; + get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset); // Pointers to extracted PDCCH symbols in frequency-domain. - int32_t rx_size = 4*273*12; - __attribute__ ((aligned(32))) int32_t rxdataF_ext[4*frame_parms->nb_antennas_rx][rx_size]; - __attribute__ ((aligned(32))) int32_t rxdataF_comp[4*frame_parms->nb_antennas_rx][rx_size]; - __attribute__ ((aligned(32))) int32_t pdcch_dl_ch_estimates_ext[4*frame_parms->nb_antennas_rx][rx_size]; + int32_t rx_size = 4*n_rb*12; + __attribute__ ((aligned(32))) int32_t rxdataF_ext[frame_parms->nb_antennas_rx][rx_size]; + __attribute__ ((aligned(32))) int32_t rxdataF_comp[frame_parms->nb_antennas_rx][rx_size]; + __attribute__ ((aligned(32))) int32_t pdcch_dl_ch_estimates_ext[frame_parms->nb_antennas_rx][rx_size]; + + memset(rxdataF_comp, 0, sizeof(rxdataF_comp)); // Pointer to llrs, 4-bit resolution. - int32_t llr_size = 2*4*100*12; + int32_t llr_size = 2*4*n_rb*9; int16_t llr[llr_size]; - get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset); + memset(llr, 0, sizeof(llr)); + LOG_D(PHY,"pdcch coreset: freq %x, n_rb %d, rb_offset %d\n", rel15->coreset.frequency_domain_resource[0],n_rb,rb_offset); for (int s=rel15->coreset.StartSymbolIndex; s<(rel15->coreset.StartSymbolIndex+rel15->coreset.duration); s++) { From 9ae6095a78a54f106d22258d8e8d50fd39b83be0 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 27 Sep 2022 10:57:48 +0200 Subject: [PATCH 02/10] nr_ulsim: fix calculation of statistics --- openair1/SIMULATION/NR_PHY/ulsim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 54c0d42db1..37e6341e95 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1074,6 +1074,7 @@ int main(int argc, char **argv) varArray_t *table_rx=initVarArray(1000,sizeof(double)); int error_flag = 0; n_false_positive = 0; + roundStats[snrRun] = 0; effRate[snrRun] = 0; effTP[snrRun] = 0; reset_meas(&gNB->phy_proc_rx); @@ -1098,7 +1099,6 @@ int main(int argc, char **argv) crc_status = 1; errors_decoding = 0; - memset((void*)roundStats,0,50*sizeof(roundStats[0])); while (roundharq_processes[harq_pid]->round = round; @@ -1539,7 +1539,7 @@ int main(int argc, char **argv) effRate[snrRun] /= (double)n_trials; printf("*****************************************\n"); - printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0][snrRun], round_trials[0][snrRun],n_errors[1][snrRun], round_trials[1][snrRun],n_errors[2][snrRun], round_trials[2][snrRun],n_errors[3][snrRun], round_trials[3][snrRun], n_false_positive, n_trials, errors_scrambling[0][snrRun],available_bits*n_trials,errors_scrambling[1][snrRun],available_bits*n_trials,errors_scrambling[2][snrRun],available_bits*n_trials,errors_scrambling[3][snrRun],available_bits*n_trials); + printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0][snrRun], round_trials[0][snrRun],n_errors[1][snrRun], round_trials[1][snrRun],n_errors[2][snrRun], round_trials[2][snrRun],n_errors[3][snrRun], round_trials[3][snrRun], n_false_positive, n_trials, errors_scrambling[0][snrRun],available_bits*round_trials[0][snrRun],errors_scrambling[1][snrRun],available_bits*round_trials[1][snrRun],errors_scrambling[2][snrRun],available_bits*round_trials[2][snrRun],errors_scrambling[3][snrRun],available_bits*round_trials[3][snrRun]); printf("\n"); blerStats[0][snrRun] = (double)n_errors[0][snrRun]/round_trials[0][snrRun]; blerStats[1][snrRun] = (double)n_errors[1][snrRun]/round_trials[1][snrRun]; From b94d6b5b33e895c1798ffae38e425f85f44b4643 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 27 Sep 2022 11:00:02 +0200 Subject: [PATCH 03/10] remove unsupported "thread_pool_size" parameter from conf files --- .../GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf | 1 - .../GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf | 1 - .../CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf | 1 - .../CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf | 1 - 4 files changed, 4 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf index c74476902b..b640e2de55 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf @@ -181,7 +181,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf index ac1dba7e42..3337f67ac8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf @@ -179,7 +179,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf index f5918cfb83..538ce4f615 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -235,7 +235,6 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - thread_pool_size = 4; # pucch0_dtx_threshold = 150; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf index e893e88d1a..8d409bf423 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -239,7 +239,6 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - thread_pool_size = 8; # pucch0_dtx_threshold = 150; } ); From a2c6ad42e4d8eea15e2836cccfddb3b60bcc1a4b Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 27 Sep 2022 11:01:33 +0200 Subject: [PATCH 04/10] NR_UE: minor improvements in nr_initial_sync() --- openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 6bf425974d..af439c5957 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -51,7 +51,7 @@ extern openair0_config_t openair0_cfg[]; int cnt=0; #define DEBUG_INITIAL_SYNCH - +#define DUMP_PBCH_CH_ESTIMATES 0 // create a new node of SSB structure NR_UE_SSB* create_ssb_node(uint8_t i, uint8_t h) { @@ -168,6 +168,11 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini phy_pdcch_config, &result); + if (DUMP_PBCH_CH_ESTIMATES && (ret == 0)) { + 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); + } + temp_ptr=temp_ptr->next_ssb; } @@ -250,7 +255,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, if (sync_pos >= fp->nb_prefix_samples) ue->ssb_offset = sync_pos - fp->nb_prefix_samples; else - ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples; + ue->ssb_offset = sync_pos + fp->samples_per_frame - fp->nb_prefix_samples; #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); @@ -269,7 +274,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset; // loop over samples - int end = sa ? n_frames*fp->samples_per_frame-1 : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples); + int end = sa ? n_frames*fp->samples_per_frame : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples); for(int n=start; nnb_antennas_rx; ar++) { @@ -282,7 +287,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, } /* 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 (is*fp->samples_per_frame + ue->ssb_offset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) < n_frames*fp->samples_per_frame) { /* 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 */ From f73fcd94ee3cd131315e5fb27c3e2b0e06abc66d Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 27 Sep 2022 11:02:16 +0200 Subject: [PATCH 05/10] NR_UE: fix/add some debugging in nr_adjust_synch_ue.c and nr_dl_channel_estimation.c --- openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c | 4 ++-- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 045197adc1..20be091975 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -27,7 +27,7 @@ #include "executables/softmodem-common.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#define DEBUG_PHY +//#define DEBUG_PHY // Adjust location synchronization point to account for drift // The adjustment is performed once per frame based on the @@ -118,7 +118,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, } #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_I(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, diff, ue->rx_offset, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index f15b99fb1c..d772be591c 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1223,6 +1223,10 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_sum[0] / 3; ch[1] = ch_sum[1] / 3; multadd_real_vector_complex_scalar(filt16a_1, ch, dl_ch, 16); +#ifdef DEBUG_PDCCH + for (int m =0; m<12; m++) + printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]); +#endif dl_ch += 24; ch_sum[0] = 0; ch_sum[1] = 0; From cd8122d24d3135512f6dd98e92b72308364f7b41 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 11 Oct 2022 10:20:20 +0200 Subject: [PATCH 06/10] NR_UE: fix frequency offset estimation/compensation if SSB is in the second captured frame --- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index af439c5957..0d5e850450 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -251,52 +251,51 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, /* process pss search on received buffer */ sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE); + if (sync_pos < fp->nb_prefix_samples) + continue; - if (sync_pos >= fp->nb_prefix_samples) - ue->ssb_offset = sync_pos - fp->nb_prefix_samples; - else - ue->ssb_offset = sync_pos + fp->samples_per_frame - fp->nb_prefix_samples; + ue->ssb_offset = sync_pos - fp->nb_prefix_samples; #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,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); #endif - // digital compensation of FFO for SSB symbols - if (ue->UE_fo_compensation){ - 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 + /* check that SSS/PBCH block is continuous inside the received buffer */ + if (ue->ssb_offset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) < fp->samples_per_frame) { - // In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1 - // and we do not know yet in which slot it goes. + // digital compensation of FFO for SSB symbols + if (ue->UE_fo_compensation){ + 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 - // start for offset correction - int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset; + // In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1 + // and we do not know yet in which slot it goes. - // loop over samples - int end = sa ? n_frames*fp->samples_per_frame : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples); + // start for offset correction + int start = is*fp->samples_per_frame; - for(int n=start; nnb_antennas_rx; ar++) { - re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]); - im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]); - ((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); - ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); + // loop over samples + int end = start + fp->samples_per_frame; + + for(int n=start; nnb_antennas_rx; ar++) { + re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]); + im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]); + ((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(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 */ - if (is*fp->samples_per_frame + ue->ssb_offset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) < n_frames*fp->samples_per_frame) { - - /* 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 */ - /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ - /* symbol number are from beginning of SS/PBCH blocks as below: */ - /* Signal PSS PBCH SSS PBCH */ - /* symbol number 0 1 2 3 */ - /* 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 */ + /* 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 */ + /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ + /* symbol number are from beginning of SS/PBCH blocks as below: */ + /* Signal PSS PBCH SSS PBCH */ + /* symbol number 0 1 2 3 */ + /* 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 */ for(int i=0; i<4;i++) nr_slot_fep_init_sync(ue, @@ -322,10 +321,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, // and we do not know yet in which slot it goes. // start for offset correction - int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset; + int start = is*fp->samples_per_frame; // loop over samples - int end = sa ? n_frames*fp->samples_per_frame-1 : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples); + int end = start + fp->samples_per_frame; for(int n=start; nnb_antennas_rx; ar++) { From a7d9f94ef3f59ba8c10ad455a8f7e4d273c9ba09 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 11 Oct 2022 11:27:13 +0200 Subject: [PATCH 07/10] NR_UE scope: show complete CIR --- openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index d772be591c..24d0295a44 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -990,7 +990,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } if (dmrss == 2) - UEscopeCopy(ue, pbchDlChEstimateTime, (void*)dl_ch_estimates_time, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, idftsizeidx); + UEscopeCopy(ue, pbchDlChEstimateTime, (void*)dl_ch_estimates_time, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, ue->frame_parms.ofdm_symbol_size); return(0); } From 39fe985681bcc63b0c23fc214549984b8b051785 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 11 Oct 2022 11:31:34 +0200 Subject: [PATCH 08/10] NR_UE: slightly improve timing synchronization by minimizing the adjustment of the filtered peak position value --- executables/nr-ue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 8b022adc62..c274773880 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -798,10 +798,10 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { int computeSamplesShift(PHY_VARS_NR_UE *UE) { int samples_shift = -(UE->rx_offset>>1); - 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 if (samples_shift != 0) { LOG_I(NR_PHY,"Adjusting frame in time by %i samples\n", samples_shift); + 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 += samples_shift; // reset IIR filter when sample shift is applied } return samples_shift; } From c5e68e146c0eae95de8020b2ab384bc0f4777af3 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 11 Oct 2022 12:11:22 +0200 Subject: [PATCH 09/10] NR_UE: increase the accuracy of the filtered peak position value --- executables/nr-ue.c | 2 +- openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index c274773880..641aa0a64c 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -801,7 +801,7 @@ int computeSamplesShift(PHY_VARS_NR_UE *UE) { if (samples_shift != 0) { LOG_I(NR_PHY,"Adjusting frame in time by %i samples\n", samples_shift); 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 += samples_shift; // reset IIR filter when sample shift is applied + UE->max_pos_fil += samples_shift << 15; // reset IIR filter when sample shift is applied } return samples_shift; } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 20be091975..c387c7f38b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -75,14 +75,14 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, // filter position to reduce jitter if (clear == 1) - ue->max_pos_fil = max_pos; + ue->max_pos_fil = max_pos << 15; else - ue->max_pos_fil = ((ue->max_pos_fil * coef) + (max_pos * ncoef)) >> 15; + ue->max_pos_fil = ((ue->max_pos_fil * coef) >> 15) + (max_pos * ncoef); // do not filter to have proactive timing adjustment - //ue->max_pos_fil = max_pos; + //ue->max_pos_fil = max_pos << 15; - int diff = ue->max_pos_fil - sync_pos; + int diff = (ue->max_pos_fil >> 15) - sync_pos; if (frame_parms->freq_range==nr_FR2) sync_offset = 2; From 5063957a161d9b50a035822ea148d2363aa5a3ea Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 17 Oct 2022 16:46:02 +0200 Subject: [PATCH 10/10] fix merge artefact in nr_dl_channel_estimation.c --- .../nr_dl_channel_estimation.c | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 24d0295a44..624f4afa83 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -27,6 +27,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h" +#include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "common/utils/nr/nr_common.h" @@ -39,7 +40,26 @@ //#define DEBUG_PBCH //#define DEBUG_PRS_CHEST // To enable PRS Matlab dumps //#define DEBUG_PRS_PRINTS // To enable PRS channel estimation debug logs -extern short nr_qpsk_mod_table[8]; + +#define CH_INTERP 0 +#define NO_INTERP 1 + +/* Generic function to find the peak of channel estimation buffer */ +void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val) +{ + int32_t max_val = 0, max_idx = 0, abs_val = 0; + for(int k = 0; k < buf_len; k++) + { + abs_val = squaredMod(((c16_t*)buffer)[k]); + if(abs_val > max_val) + { + max_val = abs_val; + max_idx = k; + } + } + *peak_val = max_val; + *peak_idx = max_idx; +} int nr_prs_channel_estimation(uint8_t gNB_id, uint8_t rsc_id, @@ -545,29 +565,6 @@ int nr_prs_channel_estimation(uint8_t gNB_id, return(0); } -#define CH_INTERP 0 -#define NO_INTERP 1 - -/* Generic function to find the peak of channel estimation buffer */ -void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val) -{ - int32_t max_val = 0, max_idx = 0, abs_val = 0; - for(int k = 0; k < buf_len; k++) - { - abs_val = squaredMod(((c16_t*)buffer)[k]); - if(abs_val > max_val) - { - max_val = abs_val; - max_idx = k; - } - } - *peak_val = max_val; - *peak_idx = max_idx; -} - -#define CH_INTERP 0 -#define NO_INTERP 1 - int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id,