From 6f51b930c10585a6a81322406384da0ecba00b81 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Tue, 30 Aug 2022 19:45:08 +0100 Subject: [PATCH] Put the correlation level (low, medium or high) as input of new_channel_desc_scm() --- openair1/SIMULATION/LTE_PHY/dlsim.c | 8 +++- openair1/SIMULATION/LTE_PHY/ulsim.c | 4 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 14 ++++--- openair1/SIMULATION/NR_PHY/dlsim.c | 8 ++-- openair1/SIMULATION/NR_PHY/pbchsim.c | 10 +++-- openair1/SIMULATION/NR_PHY/prachsim.c | 4 +- openair1/SIMULATION/NR_PHY/pucchsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 6 ++- openair1/SIMULATION/NR_PHY/ulsim.c | 11 ++++-- openair1/SIMULATION/TOOLS/random_channel.c | 26 ++++++++----- openair1/SIMULATION/TOOLS/sim.h | 7 ++-- radio/rfsimulator/simulator.c | 18 ++++----- targets/RT/USER/rfsim.c | 44 +++++++++++----------- 13 files changed, 98 insertions(+), 64 deletions(-) diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index e2f78e9036..5da6a3cde7 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -1192,9 +1192,11 @@ int main(int argc, char **argv) { N_RB2sampling_rate(eNB->frame_parms.N_RB_DL), N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL), DS_TDL, + CORR_LEVEL_LOW, forgetting_factor, rx_sample_offset, - 0, 0); + 0, + 0); reset_meas(&eNB2UE[0]->random_channel); reset_meas(&eNB2UE[0]->interp_time); @@ -1206,9 +1208,11 @@ int main(int argc, char **argv) { N_RB2sampling_rate(eNB->frame_parms.N_RB_DL), N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL), DS_TDL, + CORR_LEVEL_LOW, forgetting_factor, rx_sample_offset, - 0, 0); + 0, + 0); reset_meas(&eNB2UE[n]->random_channel); reset_meas(&eNB2UE[n]->interp_time); } diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index b72ed441f6..5db449e4b9 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -741,9 +741,11 @@ int main(int argc, char **argv) { N_RB2sampling_rate(eNB->frame_parms.N_RB_UL), N_RB2channel_bandwidth(eNB->frame_parms.N_RB_UL), 30e-9, + CORR_LEVEL_LOW, forgetting_factor, delay, - 0, 0); + 0, + 0); // set Doppler UE2eNB->max_Doppler = maxDoppler; diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 768501e99a..3b36b0d6e5 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -336,11 +336,15 @@ int main(int argc, char **argv) if (ouput_vcd) vcd_signal_dumper_init("/tmp/openair_dump_nr_dlschsim.vcd"); - gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, - 61.44e6, //N_RB2sampling_rate(N_RB_DL), - 40e6, //N_RB2channel_bandwidth(N_RB_DL), - DS_TDL, - 0, 0, 0, 0); + gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, + 61.44e6, //N_RB2sampling_rate(N_RB_DL), + 40e6, //N_RB2channel_bandwidth(N_RB_DL), + DS_TDL, + CORR_LEVEL_LOW, + 0, + 0, + 0, + 0); if (gNB2UE == NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 59a74c9e91..3a0c90842d 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -901,11 +901,13 @@ int main(int argc, char **argv) n_rx, channel_model, fs/1e6,//sampling frequency in MHz - txbw, - 30e-9, + txbw, + 30e-9, + CORR_LEVEL_LOW, 0, 0, - 0, 0); + 0, + 0); if (gNB2UE==NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 8c7bce71f6..0a50e79139 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -534,12 +534,14 @@ int main(int argc, char **argv) gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, - fs, - bw, - 300e-9, + fs, + bw, + 300e-9, + CORR_LEVEL_LOW, 0, 0, - 0, 0); + 0, + 0); if (gNB2UE==NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 3622ba49ba..7adb0d4b93 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -734,9 +734,11 @@ int main(int argc, char **argv){ fs, bw, DS_TDL, + CORR_LEVEL_LOW, 0.0, delay, - 0, 0); + 0, + 0); if (UE2gNB==NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index cabe87ef01..199942bd30 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -415,7 +415,7 @@ int main(int argc, char **argv) &txbw, &rxbw); - UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, txbw, DS_TDL,0, 0, 0, 0); + UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, txbw, DS_TDL, CORR_LEVEL_LOW, 0, 0, 0, 0); if (UE2gNB==NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 91377e3d31..7d9b465d37 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -383,7 +383,11 @@ int main(int argc, char **argv) 61.44e6, //N_RB2sampling_rate(N_RB_DL), 40e6, //N_RB2channel_bandwidth(N_RB_DL), DS_TDL, - 0,0,0, 0); + CORR_LEVEL_LOW, + 0, + 0, + 0, + 0); if (gNB2UE == NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 3ec1c58467..def47fb3db 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -699,12 +699,17 @@ int main(int argc, char **argv) LOG_I( PHY,"++++++++++++++++++++++++++++++++++++++++++++++%i+++++++++++++++++++++++++++++++++++++++++",loglvl); - - UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, + corr_level_t corr_level = CORR_LEVEL_MEDIUM; // FIXME: Remove this hardcoded value + UE2gNB = new_channel_desc_scm(n_tx, + n_rx, channel_model, sampling_frequency/1e6, tx_bandwidth, DS_TDL, - 0, 0, 0, 0); + corr_level, + 0, + 0, + 0, + 0); if (UE2gNB == NULL) { printf("Problem generating channel model. Exiting.\n"); diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 9eb8ebe7e6..8b6d100ca3 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -386,9 +386,6 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS for (int i = 0; inb_taps; i++) chan_desc->a[i] = (struct complexd *) malloc(nb_tx*nb_rx * sizeof(struct complexd)); - // FIXME: Remove this hardcoded value - chan_desc->corr_level = CORR_LEVEL_LOW; - int matrix_size = nb_tx*nb_rx; double *correlation_matrix[matrix_size]; if (chan_desc->corr_level!=CORR_LEVEL_LOW) { @@ -459,10 +456,11 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, double sampling_rate, double channel_bandwidth, double DS_TDL, + const corr_level_t corr_level, double forgetting_factor, int32_t channel_offset, double path_loss_dB, - float noise_power_dB) { + float noise_power_dB) { channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t)); for(int i=0; imodelid = channel_model; + chan_desc->modelid = channel_model; chan_desc->nb_tx = nb_tx; chan_desc->nb_rx = nb_rx; chan_desc->sampling_rate = sampling_rate; chan_desc->channel_bandwidth = channel_bandwidth; + chan_desc->corr_level = corr_level; chan_desc->forgetting_factor = forgetting_factor; chan_desc->channel_offset = channel_offset; chan_desc->path_loss_dB = path_loss_dB; chan_desc->first_run = 1; - chan_desc->ip = 0.0; + chan_desc->ip = 0.0; chan_desc->noise_power_dB = noise_power_dB; LOG_I(OCM,"Channel Model (inside of new_channel_desc_scm)=%d\n\n", channel_model); int tdl_paths=0; @@ -2009,10 +2008,17 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double AssertFatal(0, "\n Choose a valid model type\n"); } - channel_desc_t *channeldesc_p = new_channel_desc_scm(nb_tx,nb_rx,modid,sampling_rate,channel_bandwidth, - *(channel_list.paramarray[i][pindex_DT].dblptr), *(channel_list.paramarray[i][pindex_FF].dblptr), - *(channel_list.paramarray[i][pindex_CO].iptr), *(channel_list.paramarray[i][pindex_PL].dblptr), - *(channel_list.paramarray[i][pindex_NP].dblptr) ); + channel_desc_t *channeldesc_p = new_channel_desc_scm(nb_tx, + nb_rx, + modid, + sampling_rate, + channel_bandwidth, + *(channel_list.paramarray[i][pindex_DT].dblptr), + CORR_LEVEL_LOW, + *(channel_list.paramarray[i][pindex_FF].dblptr), + *(channel_list.paramarray[i][pindex_CO].iptr), + *(channel_list.paramarray[i][pindex_PL].dblptr), + *(channel_list.paramarray[i][pindex_NP].dblptr)); AssertFatal( (channeldesc_p!= NULL), "Could not allocate channel %s type %s \n",*(channel_list.paramarray[i][pindex_NAME].strptr), *(channel_list.paramarray[i][pindex_TYPE].strptr)); channeldesc_p->model_name = strdup(*(channel_list.paramarray[i][pindex_NAME].strptr)); LOG_I(OCM,"Model %s type %s allocated from config file, list %s\n",*(channel_list.paramarray[i][pindex_NAME].strptr), diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 8068cba53b..fc35b5cae5 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -312,13 +312,14 @@ typedef struct { channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, uint8_t nb_rx, SCM_t channel_model, - double sampling_rate, + double sampling_rate, double channel_bandwidth, - double TDL_DS, + double DS_TDL, + const corr_level_t corr_level, double forgetting_factor, int32_t channel_offset, double path_loss_dB, - float noise_power_dB); + float noise_power_dB); channel_desc_t *find_channel_desc_fromname( char *modelname ); diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index 332d588b6f..498c3d1ea3 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -343,15 +343,15 @@ static int rfsimu_setchanmod_cmd(char *buff, int debug, telnet_printfunc_t prnt, if (b->conn_sock >= 0 && (strcmp(b->channel_model->model_name,modelname)==0)) { channel_desc_t *newmodel=new_channel_desc_scm(t->tx_num_channels,t->rx_num_channels, - channelmod, - t->sample_rate, - t->tx_bw, - 30e-9, // TDL delay-spread parameter - t->chan_forgetfact, // forgetting_factor - t->chan_offset, // maybe used for TA - t->chan_pathloss, - t->noise_power_dB - ); // path_loss in dB + channelmod, + t->sample_rate, + t->tx_bw, + 30e-9, // TDL delay-spread parameter + CORR_LEVEL_LOW, + t->chan_forgetfact, // forgetting_factor + t->chan_offset, // maybe used for TA + t->chan_pathloss, + t->noise_power_dB); // path_loss in dB set_channeldesc_owner(newmodel, RFSIMU_MODULEID); set_channeldesc_name(newmodel,modelname); random_channel(newmodel,false); diff --git a/targets/RT/USER/rfsim.c b/targets/RT/USER/rfsim.c index 2bd95507c3..df604d247a 100644 --- a/targets/RT/USER/rfsim.c +++ b/targets/RT/USER/rfsim.c @@ -352,31 +352,33 @@ void init_ocm(void) { for (CC_id=0; CC_idframe_parms->N_RB_DL); - sim.RU2UE[ru_id][UE_id][CC_id] = - new_channel_desc_scm(RC.ru[ru_id]->nb_tx, - PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), - DS_TDL, - 0.0, - 0, - 0, - 0); + sim.RU2UE[ru_id][UE_id][CC_id] = + new_channel_desc_scm(RC.ru[ru_id]->nb_tx, + PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, + AWGN, + N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), + N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), + DS_TDL, + CORR_LEVEL_LOW, + 0.0, + 0, + 0, + 0); random_channel(sim.RU2UE[ru_id][UE_id][CC_id],0); LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN", UE_id, ru_id); sim.UE2RU[UE_id][ru_id][CC_id] = - new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, - RC.ru[ru_id]->nb_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), - DS_TDL, - 0.0, - 0, - 0, - 0); + new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, + RC.ru[ru_id]->nb_rx, + AWGN, + N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), + N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), + DS_TDL, + CORR_LEVEL_LOW, + 0.0, + 0, + 0, + 0); random_channel(sim.UE2RU[UE_id][ru_id][CC_id],0); // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id];