From 215f263a69f4259049752fdf5fb9310fcc4b6ece Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Sun, 25 Apr 2021 21:05:56 +0200 Subject: [PATCH] Making sample offset as cmd line parameter for gNB its in L1 section of config file for UE its a cmd line paramenter --- executables/nr-uesoftmodem.c | 3 +++ executables/nr-uesoftmodem.h | 5 +++- openair1/PHY/INIT/nr_init.c | 2 ++ openair1/PHY/MODULATION/nr_modulation.c | 24 +++++++++---------- openair1/PHY/MODULATION/slot_fep_nr.c | 16 ++++--------- .../PHY/NR_ESTIMATION/nr_measurements_gNB.c | 2 +- .../PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c | 2 +- openair1/PHY/defs_gNB.h | 2 ++ openair1/PHY/defs_nr_common.h | 2 ++ openair1/SIMULATION/NR_PHY/dlsim.c | 1 + openair1/SIMULATION/NR_PHY/pbchsim.c | 3 +++ openair1/SIMULATION/NR_PHY/ulsim.c | 1 + openair2/GNB_APP/L1_nr_paramdef.h | 5 +++- openair2/GNB_APP/gnb_config.c | 1 + .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 1 + 15 files changed, 42 insertions(+), 28 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 3b27716ed6..670748c275 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -242,6 +242,7 @@ void init_tpools(uint8_t nun_dlsch_threads) { } static void get_options(void) { + nrUE_params.ofdm_offset_divisor = 8; paramdef_t cmdline_params[] =CMDLINE_NRUEPARAMS_DESC ; int numparams = sizeof(cmdline_params)/sizeof(paramdef_t); config_process_cmdline( cmdline_params,numparams,NULL); @@ -325,6 +326,8 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ LOG_I(PHY, "Set UE nb_rx_antenna %d, nb_tx_antenna %d, threequarter_fs %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->threequarter_fs); + fp->ofdm_offset_divisor = nrUE_params.ofdm_offset_divisor; + } void init_openair0(void) { diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 3345aafd26..7f25a9f9fa 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -8,7 +8,8 @@ -#define CONFIG_HLP_DLSCH_PARA "number of threads for dlsch processing 0 for no parallelization" +#define CONFIG_HLP_DLSCH_PARA "number of threads for dlsch processing 0 for no parallelization\n" +#define CONFIG_HLP_OFFSET_DIV "Divisor for computing OFDM symbol offset in Rx chain (num samples in CP/). Default value is 8. To set the sample offset to 0, set this value ~ 10e6\n" /***************************************************************************************************************************************/ /* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument when calling config_get or config_getlist functions */ @@ -29,6 +30,7 @@ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, iptr:(int32_t *)&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ + {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:(uint32_t *)&nrUE_params.ofdm_offset_divisor, defuintval:UINT_MAX, TYPE_UINT32, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0} \ @@ -66,6 +68,7 @@ typedef struct { uint64_t optmask; //mask to store boolean config options + uint32_t ofdm_offset_divisor; // Divisor for sample offset computation for each OFDM symbol uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization tpool_t Tpool; // thread pool } nrUE_params_t; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 34ea60f02c..ca49fe6ce1 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -483,6 +483,7 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB, gNB_config->carrier_config.dl_bandwidth.value = config_bandwidth(mu, N_RB_DL, fp->nr_band); nr_init_frame_parms(gNB_config, fp); + fp->ofdm_offset_divisor = UINT_MAX; gNB->configured = 1; LOG_I(PHY,"gNB configured\n"); } @@ -534,6 +535,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { // } RC.gNB[Mod_id]->configured = 1; + fp->ofdm_offset_divisor = RC.gNB[Mod_id]->ofdm_offset_divisor; init_symbol_rotation(fp); init_timeshift_rotation(fp); diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index 954cabc21d..d38373afff 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -762,7 +762,7 @@ void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp) for (i = 0; i < fp->ofdm_symbol_size/2; i++) { timeshift_symbol_rotation = fp->timeshift_symbol_rotation[0]; f = fd * i; - t0 = Ncp0 / 8; + t0 = Ncp0 / fp->ofdm_offset_divisor; poff = 2 * M_PI * -t0 * Tc * f; exp_re = cos(poff); exp_im = sin(-poff); @@ -770,7 +770,7 @@ void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp) timeshift_symbol_rotation[i*2+1] = (int16_t)floor(exp_im * 32767); timeshift_symbol_rotation = fp->timeshift_symbol_rotation[1]; - t0 = Ncp1 / 8; + t0 = Ncp1 / fp->ofdm_offset_divisor; poff = 2 * M_PI * -t0 * Tc * f; exp_re = cos(poff); exp_im = sin(-poff); @@ -779,8 +779,8 @@ void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp) if (i < 10) LOG_I(PHY,"Timeshift symbol rotation %d => (%d,%d) %f\n",i, - fp->timeshift_symbol_rotation[1][i*2], - fp->timeshift_symbol_rotation[1][i*2+1], + fp->timeshift_symbol_rotation[0][i*2], + fp->timeshift_symbol_rotation[0][i*2+1], poff); } @@ -789,25 +789,25 @@ void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp) for (int j = fp->ofdm_symbol_size-1; j > fp->ofdm_symbol_size/2-1; j--) { timeshift_symbol_rotation = fp->timeshift_symbol_rotation[0]; f = -fd * i; - t0 = Ncp0 / 8; + t0 = Ncp0 / fp->ofdm_offset_divisor; poff = 2 * M_PI * -t0 * Tc * f; exp_re = cos(poff); exp_im = sin(-poff); - timeshift_symbol_rotation[j*2] = (int16_t)floor(exp_re * 32767); - timeshift_symbol_rotation[j*2+1] = (int16_t)floor(exp_im * 32767); + timeshift_symbol_rotation[j*2] = (int16_t)ceil(exp_re * 32767); + timeshift_symbol_rotation[j*2+1] = (int16_t)ceil(exp_im * 32767); timeshift_symbol_rotation = fp->timeshift_symbol_rotation[1]; - t0 = Ncp1 / 8; + t0 = Ncp1 / fp->ofdm_offset_divisor; poff = 2 * M_PI * -t0 * Tc * f; exp_re = cos(poff); exp_im = sin(-poff); - timeshift_symbol_rotation[j*2] = (int16_t)floor(exp_re * 32767); - timeshift_symbol_rotation[j*2+1] = (int16_t)floor(exp_im * 32767); + timeshift_symbol_rotation[j*2] = (int16_t)ceil(exp_re * 32767); + timeshift_symbol_rotation[j*2+1] = (int16_t)ceil(exp_im * 32767); if (j > fp->ofdm_symbol_size-10-1) LOG_I(PHY,"Timeshift symbol rotation %d => (%d,%d) %f\n",-i, - fp->timeshift_symbol_rotation[1][j*2], - fp->timeshift_symbol_rotation[1][j*2+1], + fp->timeshift_symbol_rotation[0][j*2], + fp->timeshift_symbol_rotation[0][j*2+1], poff); i++; } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 10c25ea7bc..2fe5901991 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -107,7 +107,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, rx_offset += frame_parms->ofdm_symbol_size * symbol; // use OFDM symbol from within 1/8th of the CP to avoid ISI - rx_offset -= nb_prefix_samples / 8; + rx_offset -= (nb_prefix_samples / frame_parms->ofdm_offset_divisor); #ifdef DEBUG_FEP // if (ue->frame <100) @@ -158,11 +158,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, frame_parms->ofdm_symbol_size, 15); - int16_t *shift_rot; - if (symb_offset+symbol == (7 * (1 << frame_parms->numerology_index))) - shift_rot = frame_parms->timeshift_symbol_rotation[0]; - else - shift_rot = frame_parms->timeshift_symbol_rotation[1]; + int16_t *shift_rot = frame_parms->timeshift_symbol_rotation[0]; multadd_cpx_vector((int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], shift_rot, @@ -309,7 +305,7 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, // offset of n-th OFDM symbol rxdata_offset += symbol * (frame_parms->ofdm_symbol_size + nb_prefix_samples); // use OFDM symbol from within 1/8th of the CP to avoid ISI - rxdata_offset -= nb_prefix_samples / 8; + rxdata_offset -= (nb_prefix_samples / frame_parms->ofdm_offset_divisor); int16_t *rxdata_ptr; @@ -370,11 +366,7 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, length, 15); - int16_t *shift_rot; - if (symb_offset+symbol == (7 * (1 << frame_parms->numerology_index))) - shift_rot = frame_parms->timeshift_symbol_rotation[0]; - else - shift_rot = frame_parms->timeshift_symbol_rotation[1]; + int16_t *shift_rot = frame_parms->timeshift_symbol_rotation[0]; multadd_cpx_vector((int16_t *)&rxdataF[frame_parms->ofdm_symbol_size*symbol], shift_rot, diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index d3e33a91a8..36e1c3fee9 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -45,7 +45,7 @@ int nr_est_timing_advance_pusch(PHY_VARS_gNB* gNB, int UE_id) NR_gNB_PUSCH *gNB_pusch_vars = gNB->pusch_vars[UE_id]; int32_t **ul_ch_estimates_time = gNB_pusch_vars->ul_ch_estimates_time; - int sync_pos = frame_parms->nb_prefix_samples / 8; + int sync_pos = frame_parms->nb_prefix_samples / frame_parms->ofdm_offset_divisor; for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { int temp = 0; 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 0318ed6478..f411e8d5b2 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -82,7 +82,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, // do not filter to have proactive timing adjustment //max_pos_fil = max_pos; - diff = max_pos_fil - (frame_parms->nb_prefix_samples>>3); + diff = max_pos_fil - (frame_parms->nb_prefix_samples / frame_parms->ofdm_offset_divisor); if (frame_parms->freq_range==nr_FR2) sync_offset = 2; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index ed43528088..b6119cad8c 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -776,6 +776,8 @@ typedef struct PHY_VARS_gNB_s { uint32_t max_peak_val; + /// OFDM symbol offset divisor for UL + uint32_t ofdm_offset_divisor; /// \brief sinr for all subcarriers of the current link (used only for abstraction). /// first index: ? [0..N_RB_DL*12[ double *sinr_dB; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index bd62bd3937..f89c3d66af 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -365,6 +365,8 @@ struct NR_DL_FRAME_PARMS { uint8_t ssb_index; /// PBCH polar encoder params t_nrPolar_params pbch_polar_params; + /// OFDM symbol offset divisor for UL + uint32_t ofdm_offset_divisor; }; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index f099d9e622..da2937208e 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -619,6 +619,7 @@ int main(int argc, char **argv) memset(RC.gNB[0],0,sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; + gNB->ofdm_offset_divisor = UINT_MAX; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index c75a590603..2c9fb268f2 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -109,7 +109,9 @@ void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB, gNB_config->carrier_config.dl_bandwidth.value = config_bandwidth(mu, N_RB_DL, fp->nr_band); + fp->ofdm_offset_divisor = UINT_MAX; nr_init_frame_parms(gNB_config, fp); + init_timeshift_rotation(fp); init_symbol_rotation(fp); @@ -405,6 +407,7 @@ int main(int argc, char **argv) RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; + gNB->ofdm_offset_divisor = UINT_MAX; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index bd2e76ee6f..8f3d2a5cc9 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -616,6 +616,7 @@ int main(int argc, char **argv) RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = calloc(1,sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; + gNB->ofdm_offset_divisor = UINT_MAX; gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); char tp_param[] = "n"; diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 88f2cb1615..2f58860161 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -47,6 +47,7 @@ #define CONFIG_STRING_L1_REMOTE_N_PORTD "remote_n_portd" #define CONFIG_STRING_L1_TRANSPORT_N_PREFERENCE "tr_n_preference" #define CONFIG_STRING_L1_PUSCH_PROC_THREADS "pusch_proc_threads" +#define CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR "ofdm_offset_divisor" /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* L1 configuration parameters */ @@ -62,7 +63,8 @@ {CONFIG_STRING_L1_REMOTE_N_PORTC, NULL, 0, uptr:NULL, defintval:50030, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_LOCAL_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:3, TYPE_UINT, 0} \ +{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:3, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR, NULL, 0, uptr:NULL, defuintval:UINT_MAX, TYPE_UINT, 0} \ } #define L1_CC_IDX 0 #define L1_TRANSPORT_N_PREFERENCE_IDX 1 @@ -74,6 +76,7 @@ #define L1_LOCAL_N_PORTD_IDX 7 #define L1_REMOTE_N_PORTD_IDX 8 #define L1_PUSCH_PROC_THREADS 9 +#define L1_OFDM_OFFSET_DIVISOR 10 /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index d3dd769807..fc811b2d11 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -591,6 +591,7 @@ void RCconfig_NR_L1(void) { } RC.gNB[j]->pusch_proc_threads = *(L1_ParamList.paramarray[j][L1_PUSCH_PROC_THREADS].uptr); + RC.gNB[j]->ofdm_offset_divisor = *(L1_ParamList.paramarray[j][L1_OFDM_OFFSET_DIVISOR].uptr); if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { //sf_ahead = 2; // Need 4 subframe gap between RX and TX diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 7080aff8ea..b53acbabdc 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -235,6 +235,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; pusch_proc_threads = 8; + ofdm_offset_divisor = 8; } );