diff --git a/lib/include/srslte/phy/channel/channel.h b/lib/include/srslte/phy/channel/channel.h index e607c503c..198b21cf0 100644 --- a/lib/include/srslte/phy/channel/channel.h +++ b/lib/include/srslte/phy/channel/channel.h @@ -39,6 +39,10 @@ public: // General bool enable = false; + // AWGN options + bool awgn_enable = false; + float awgn_n0_dBfs = -30.0f; + // Fading options bool fading_enable = false; std::string fading_model = "none"; @@ -71,6 +75,7 @@ public: private: srslte_channel_fading_t* fading[SRSLTE_MAX_CHANNELS] = {}; srslte_channel_delay_t* delay[SRSLTE_MAX_CHANNELS] = {}; + srslte_channel_awgn_t* awgn = nullptr; srslte_channel_hst_t* hst = nullptr; // HST has no buffers / no multiple instance is required srslte_channel_rlf_t* rlf = nullptr; // RLF has no buffers / no multiple instance is required cf_t* buffer_in = nullptr; diff --git a/lib/src/phy/channel/channel.cc b/lib/src/phy/channel/channel.cc index 980b17670..76c1a5493 100644 --- a/lib/src/phy/channel/channel.cc +++ b/lib/src/phy/channel/channel.cc @@ -74,6 +74,13 @@ channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels) } } + // Create AWGN channnel + if (channel_args.awgn_enable && ret == SRSLTE_SUCCESS) { + awgn = (srslte_channel_awgn_t*)calloc(sizeof(srslte_channel_awgn_t), 1); + ret = srslte_channel_awgn_init(awgn, 1234); + srslte_channel_awgn_set_n0(awgn, args.awgn_n0_dBfs); + } + // Create high speed train if (channel_args.hst_enable && ret == SRSLTE_SUCCESS) { hst = (srslte_channel_hst_t*)calloc(sizeof(srslte_channel_hst_t), 1); @@ -101,6 +108,11 @@ channel::~channel() free(buffer_out); } + if (awgn) { + srslte_channel_awgn_free(awgn); + free(awgn); + } + if (hst) { srslte_channel_hst_free(hst); free(hst); @@ -143,6 +155,11 @@ void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS], // Copy input buffer memcpy(buffer_in, in[i], sizeof(cf_t) * len); + if (awgn) { + srslte_channel_awgn_run_c(awgn, buffer_in, buffer_out, len); + memcpy(buffer_in, buffer_out, sizeof(cf_t) * len); + } + if (fading[i]) { srslte_channel_fading_execute(fading[i], buffer_in, buffer_out, len, t.full_secs + t.frac_secs); memcpy(buffer_in, buffer_out, sizeof(cf_t) * len); diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index a7cfe971f..16cb36c4a 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -175,6 +175,10 @@ pusch_max_mcs = 16 # Channel emulator options: # enable: Enable/Disable internal Downlink/Uplink channel emulator # +# -- AWGN Generator +# awgn.enable: Enable/disable AWGN generator +# awgn.n0: Noise power in dBfs +# # -- Fading emulator # fading.enable: Enable/disable fading simulator # fading.model: Fading model + maximum doppler (E.g. none, epa5, eva70, etu300, etc) @@ -201,6 +205,10 @@ pusch_max_mcs = 16 [channel.dl] #enable = false +[channel.dl.awgn] +#enable = false +#n0 = -30 + [channel.dl.fading] #enable = false #model = none @@ -226,6 +234,10 @@ pusch_max_mcs = 16 [channel.ul] #enable = false +[channel.ul.awgn] +#enable = false +#n0 = -30 + [channel.ul.fading] #enable = false #model = none diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index b6baa9858..43ad4a9fa 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -134,6 +134,8 @@ void parse_args(all_args_t* args, int argc, char* argv[]) /* Downlink Channel emulator section */ ("channel.dl.enable", bpo::value(&args->phy.dl_channel_args.enable)->default_value(false), "Enable/Disable internal Downlink channel emulator") + ("channel.dl.awgn.enable", bpo::value(&args->phy.dl_channel_args.awgn_enable)->default_value(false), "Enable/Disable AWGN simulator") + ("channel.dl.awgn.n0", bpo::value(&args->phy.dl_channel_args.awgn_n0_dBfs)->default_value(-30.0f), "Noise level in decibels full scale (dBfs)") ("channel.dl.fading.enable", bpo::value(&args->phy.dl_channel_args.fading_enable)->default_value(false), "Enable/Disable Fading model") ("channel.dl.fading.model", bpo::value(&args->phy.dl_channel_args.fading_model)->default_value("none"), "Fading model + maximum doppler (E.g. none, epa5, eva70, etu300, etc)") ("channel.dl.delay.enable", bpo::value(&args->phy.dl_channel_args.delay_enable)->default_value(false), "Enable/Disable Delay simulator") @@ -151,6 +153,8 @@ void parse_args(all_args_t* args, int argc, char* argv[]) /* Uplink Channel emulator section */ ("channel.ul.enable", bpo::value(&args->phy.ul_channel_args.enable)->default_value(false), "Enable/Disable internal Uplink channel emulator") + ("channel.ul.awgn.enable", bpo::value(&args->phy.ul_channel_args.awgn_enable)->default_value(false), "Enable/Disable AWGN simulator") + ("channel.ul.awgn.n0", bpo::value(&args->phy.ul_channel_args.awgn_n0_dBfs)->default_value(-30.0f), "Noise level in decibels full scale (dBfs)") ("channel.ul.fading.enable", bpo::value(&args->phy.ul_channel_args.fading_enable)->default_value(false), "Enable/Disable Fading model") ("channel.ul.fading.model", bpo::value(&args->phy.ul_channel_args.fading_model)->default_value("none"), "Fading model + maximum doppler (E.g. none, epa5, eva70, etu300, etc)") ("channel.ul.delay.enable", bpo::value(&args->phy.ul_channel_args.delay_enable)->default_value(false), "Enable/Disable Delay simulator") diff --git a/srsenb/src/phy/phy_common.cc b/srsenb/src/phy/phy_common.cc index 9675f8df3..1105e2714 100644 --- a/srsenb/src/phy/phy_common.cc +++ b/srsenb/src/phy/phy_common.cc @@ -72,7 +72,7 @@ bool phy_common::init(const phy_cell_cfg_list_t& cell_list_, pthread_cond_init(&mtch_cvar, nullptr); // Instantiate DL channel emulator - if (params.ul_channel_args.enable) { + if (params.dl_channel_args.enable) { dl_channel = srslte::channel_ptr(new srslte::channel(params.dl_channel_args, 1)); dl_channel->set_srate((uint32_t)srslte_sampling_freq_hz(cell_list[0].cell.nof_prb)); } diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 3fa71f023..3973c76f3 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -172,6 +172,8 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) /* Downlink Channel emulator section */ ("channel.dl.enable", bpo::value(&args->phy.dl_channel_args.enable)->default_value(false), "Enable/Disable internal Downlink channel emulator") + ("channel.dl.awgn.enable", bpo::value(&args->phy.dl_channel_args.awgn_enable)->default_value(false), "Enable/Disable AWGN simulator") + ("channel.dl.awgn.n0", bpo::value(&args->phy.dl_channel_args.awgn_n0_dBfs)->default_value(-30.0f), "Noise level in decibels full scale (dBfs)") ("channel.dl.fading.enable", bpo::value(&args->phy.dl_channel_args.fading_enable)->default_value(false), "Enable/Disable Fading model") ("channel.dl.fading.model", bpo::value(&args->phy.dl_channel_args.fading_model)->default_value("none"), "Fading model + maximum doppler (E.g. none, epa5, eva70, etu300, etc)") ("channel.dl.delay.enable", bpo::value(&args->phy.dl_channel_args.delay_enable)->default_value(false), "Enable/Disable Delay simulator") @@ -189,6 +191,8 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) /* Uplink Channel emulator section */ ("channel.ul.enable", bpo::value(&args->phy.ul_channel_args.enable)->default_value(false), "Enable/Disable internal Uplink channel emulator") + ("channel.ul.awgn.enable", bpo::value(&args->phy.ul_channel_args.awgn_enable)->default_value(false), "Enable/Disable AWGN simulator") + ("channel.ul.awgn.n0", bpo::value(&args->phy.ul_channel_args.awgn_n0_dBfs)->default_value(-30.0f), "Noise level in decibels full scale (dBfs)") ("channel.ul.fading.enable", bpo::value(&args->phy.ul_channel_args.fading_enable)->default_value(false), "Enable/Disable Fading model") ("channel.ul.fading.model", bpo::value(&args->phy.ul_channel_args.fading_model)->default_value("none"), "Fading model + maximum doppler (E.g. none, epa5, eva70, etu300, etc)") ("channel.ul.delay.enable", bpo::value(&args->phy.ul_channel_args.delay_enable)->default_value(false), "Enable/Disable Delay simulator") diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index d1975e45b..a0aea68c0 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -186,6 +186,10 @@ enable = false # Channel emulator options: # enable: Enable/Disable internal Downlink/Uplink channel emulator # +# -- AWGN Generator +# awgn.enable: Enable/disable AWGN generator +# awgn.n0: Noise power in dBfs +# # -- Fading emulator # fading.enable: Enable/disable fading simulator # fading.model: Fading model + maximum doppler (E.g. none, epa5, eva70, etu300, etc) @@ -212,6 +216,10 @@ enable = false [channel.dl] #enable = false +[channel.dl.awgn] +#enable = false +#n0 = -30 + [channel.dl.fading] #enable = false #model = none @@ -237,6 +245,10 @@ enable = false [channel.ul] #enable = false +[channel.ul.awgn] +#enable = false +#n0 = -30 + [channel.ul.fading] #enable = false #model = none