diff options
9 files changed, 38 insertions, 53 deletions
diff --git a/gr-channels/grc/channels_fading_model.block.yml b/gr-channels/grc/channels_fading_model.block.yml index 7e1587feb6..5dbc5bd1a1 100644 --- a/gr-channels/grc/channels_fading_model.block.yml +++ b/gr-channels/grc/channels_fading_model.block.yml @@ -48,10 +48,10 @@ documentation: |- A. Alimohammad S.F. Fard B.F. Cockburn C. Schlegel 26th November 2008 - int d_N=8; // number of sinusoids + unsigned int d_N=8; // number of sinusoids float d_fDTs=0.01 // normalized maximum doppler frequency (f_doppler / f_samprate) float d_K=4; // Rician factor (ratio of the specular power to the scattered power) bool d_LOS=true; // LOS path exists? chooses Rician (LOS) vs Rayleigh (NLOS) model. - int seed=0; // noise seed + uint32_t seed=0; // noise seed file_format: 1 diff --git a/gr-channels/grc/channels_selective_fading_model.block.yml b/gr-channels/grc/channels_selective_fading_model.block.yml index 1fb782ce65..f9829727a5 100644 --- a/gr-channels/grc/channels_selective_fading_model.block.yml +++ b/gr-channels/grc/channels_selective_fading_model.block.yml @@ -56,12 +56,12 @@ templates: - set_K(${K}) documentation: |- - int d_N=8; // number of sinusoids used to simulate gain on each ray + unsigned int d_N=8; // number of sinusoids used to simulate gain on each ray float d_fDTs=0.01 // normalized maximum doppler frequency (f_doppler / f_samprate) float d_K=4; // Rician factor (ratio of the specular power to the scattered power) bool d_LOS=true; // LOS path exists? chooses Rician (LOS) vs Rayleigh (NLOS) model. - int seed=0; // noise seed - int ntaps; // Number of FIR taps to use in selective fading model + uint32_t seed=0; // noise seed + unsigned int ntaps; // Number of FIR taps to use in selective fading model These two vectors comprise the Power Delay Profile of the signal float_vector delays // Time delay in the fir filter (in samples) for each arriving WSSUS Ray diff --git a/gr-channels/grc/channels_selective_fading_model2.block.yml b/gr-channels/grc/channels_selective_fading_model2.block.yml index 885dc708ba..6079071400 100644 --- a/gr-channels/grc/channels_selective_fading_model2.block.yml +++ b/gr-channels/grc/channels_selective_fading_model2.block.yml @@ -67,12 +67,12 @@ templates: - set_K(${K}) documentation: |- - int d_N=8; // number of sinusoids used to simulate gain on each ray + unsigned int d_N=8; // number of sinusoids used to simulate gain on each ray float d_fDTs=0.01 // normalized maximum doppler frequency (f_doppler / f_samprate) float d_K=4; // Rician factor (ratio of the specular power to the scattered power) bool d_LOS=true; // LOS path exists? chooses Rician (LOS) vs Rayleigh (NLOS) model. - int seed=0; // noise seed - int ntaps; // Number of FIR taps to use in selective fading model + uint32_t seed=0; // noise seed + unsigned int ntaps; // Number of FIR taps to use in selective fading model These two vectors comprise the Power Delay Profile of the signal float_vector delays // Time delay in the fir filter (in samples) for each arriving WSSUS Ray diff --git a/gr-channels/include/gnuradio/channels/fading_model.h b/gr-channels/include/gnuradio/channels/fading_model.h index 93a2329c27..7ab088d7b7 100644 --- a/gr-channels/include/gnuradio/channels/fading_model.h +++ b/gr-channels/include/gnuradio/channels/fading_model.h @@ -48,13 +48,17 @@ public: /*! \brief Build the channel simulator. * * \param N the number of sinusoids to use in simulating the channel; 8 is a good - * value \param fDTs normalized maximum Doppler frequency, fD * Ts \param LOS include - * Line-of-Site path? selects between Rayleigh (NLOS) and Rician (LOS) models \param K - * Rician factor (ratio of the specular power to the scattered power) \param seed a - * random number to seed the noise generators + * value + * \param fDTs normalized maximum Doppler frequency, fD * Ts + * \param LOS include Line-of-Site path? selects between Rayleigh (NLOS) and Rician + * (LOS) models \param K Rician factor (ratio of the specular power to the + * scattered power) \param seed a random number to seed the noise generators */ - static sptr - make(unsigned int N, float fDTs = 0.01, bool LOS = true, float K = 4, int seed = 0); + static sptr make(unsigned int N, + float fDTs = 0.01f, + bool LOS = true, + float K = 4, + uint32_t seed = 0); virtual float fDTs() = 0; virtual float K() = 0; diff --git a/gr-channels/include/gnuradio/channels/selective_fading_model2.h b/gr-channels/include/gnuradio/channels/selective_fading_model2.h index 522a7c3b71..4a842b26c4 100644 --- a/gr-channels/include/gnuradio/channels/selective_fading_model2.h +++ b/gr-channels/include/gnuradio/channels/selective_fading_model2.h @@ -66,12 +66,12 @@ public: float fDTs, bool LOS, float K, - int seed, + uint32_t seed, std::vector<float> delays, - std::vector<float> delay_std, - std::vector<float> delay_maxdev, + std::vector<float> delays_std, + std::vector<float> delays_maxdev, std::vector<float> mags, - int ntaps); + unsigned int ntaps); virtual float fDTs() = 0; virtual float K() = 0; diff --git a/gr-channels/lib/fading_model_impl.cc b/gr-channels/lib/fading_model_impl.cc index 439c936a32..c80ed31863 100644 --- a/gr-channels/lib/fading_model_impl.cc +++ b/gr-channels/lib/fading_model_impl.cc @@ -28,14 +28,14 @@ namespace gr { namespace channels { fading_model::sptr -fading_model::make(unsigned int N, float fDTs, bool LOS, float K, int seed) +fading_model::make(unsigned int N, float fDTs, bool LOS, float K, uint32_t seed) { return gnuradio::get_initial_sptr(new fading_model_impl(N, fDTs, LOS, K, seed)); } // Block constructor fading_model_impl::fading_model_impl( - unsigned int N, float fDTs, bool LOS, float K, int seed) + unsigned int N, float fDTs, bool LOS, float K, uint32_t seed) : sync_block("fading_model", io_signature::make(1, 1, sizeof(gr_complex)), io_signature::make(1, 1, sizeof(gr_complex))), diff --git a/gr-channels/lib/fading_model_impl.h b/gr-channels/lib/fading_model_impl.h index f6e8e0aebb..1c52d6b573 100644 --- a/gr-channels/lib/fading_model_impl.h +++ b/gr-channels/lib/fading_model_impl.h @@ -27,10 +27,6 @@ #include <gnuradio/channels/fading_model.h> #include <gnuradio/sync_block.h> -//#include <iostream> -#include <boost/format.hpp> -#include <boost/random.hpp> - #include "sincostable.h" #include <gnuradio/fxpt.h> @@ -43,7 +39,7 @@ private: gr::channels::flat_fader_impl d_fader; public: - fading_model_impl(unsigned int N, float fDTs, bool LOS, float K, int seed); + fading_model_impl(unsigned int N, float fDTs, bool LOS, float K, uint32_t seed); ~fading_model_impl(); void setup_rpc(); int work(int noutput_items, diff --git a/gr-channels/lib/selective_fading_model2_impl.cc b/gr-channels/lib/selective_fading_model2_impl.cc index dd6cc80127..154f252170 100644 --- a/gr-channels/lib/selective_fading_model2_impl.cc +++ b/gr-channels/lib/selective_fading_model2_impl.cc @@ -27,12 +27,6 @@ #include <gnuradio/io_signature.h> #include <gnuradio/math.h> -#include <boost/format.hpp> -#include <boost/random.hpp> - -#include <iostream> - - // FASTSINCOS: 0 = slow native, 1 = gr::fxpt impl, 2 = sincostable.h #define FASTSINCOS 2 @@ -45,12 +39,12 @@ selective_fading_model2::make(unsigned int N, float fDTs, bool LOS, float K, - int seed, + uint32_t seed, std::vector<float> delays, std::vector<float> delays_std, std::vector<float> delays_maxdev, std::vector<float> mags, - int ntaps) + unsigned int ntaps) { return gnuradio::get_initial_sptr(new selective_fading_model2_impl( N, fDTs, LOS, K, seed, delays, delays_std, delays_maxdev, mags, ntaps)); @@ -62,12 +56,12 @@ selective_fading_model2_impl::selective_fading_model2_impl( float fDTs, bool LOS, float K, - int seed, + uint32_t seed, std::vector<float> delays, std::vector<float> delays_std, std::vector<float> delays_maxdev, std::vector<float> mags, - int ntaps) + unsigned int ntaps) : sync_block("selective_fading_model2", io_signature::make(1, 1, sizeof(gr_complex)), io_signature::make(1, 1, sizeof(gr_complex))), @@ -77,9 +71,8 @@ selective_fading_model2_impl::selective_fading_model2_impl( d_delays_maxdev(delays_maxdev), d_mags(mags), d_sintable(1024), - seed_1(0), - dist_1(0, 1), - rv_1(seed_1, dist_1) + rng_1(0), + dist_1(0, 1) { if (mags.size() != delays.size()) throw std::runtime_error("magnitude and delay vectors must be the same length!"); @@ -94,9 +87,6 @@ selective_fading_model2_impl::selective_fading_model2_impl( } // set up tap history - if (ntaps < 1) { - throw std::runtime_error("ntaps must be >= 1"); - } set_history(ntaps); d_taps.resize(ntaps, gr_complex(0, 0)); @@ -130,7 +120,7 @@ int selective_fading_model2_impl::work(int noutput_items, // move the tap delays around (random walk + clipping) for (size_t j = 0; j < d_faders.size(); j++) { - float tmp = d_delays[j] + rv_1() * d_delays_std[j]; + float tmp = d_delays[j] + dist_1(rng_1) * d_delays_std[j]; d_delays[j] = std::max(std::min(tmp, d_delays_orig[j] + d_delays_maxdev[j]), d_delays_orig[j] - d_delays_maxdev[j]); } diff --git a/gr-channels/lib/selective_fading_model2_impl.h b/gr-channels/lib/selective_fading_model2_impl.h index 55a818db30..f1a2d6d64d 100644 --- a/gr-channels/lib/selective_fading_model2_impl.h +++ b/gr-channels/lib/selective_fading_model2_impl.h @@ -27,10 +27,6 @@ #include <gnuradio/channels/selective_fading_model2.h> #include <gnuradio/sync_block.h> -//#include <iostream> -#include <boost/format.hpp> -#include <boost/random.hpp> - #include "sincostable.h" #include <gnuradio/fxpt.h> @@ -48,21 +44,20 @@ private: std::vector<float> d_mags; sincostable d_sintable; - boost::mt19937 seed_1; - boost::normal_distribution<> dist_1; // U(-pi,pi) - boost::variate_generator<boost::mt19937&, boost::normal_distribution<>> rv_1; + std::mt19937 rng_1; + std::normal_distribution<> dist_1; // U(-pi,pi) public: selective_fading_model2_impl(unsigned int N, float fDTs, bool LOS, float K, - int seed, + uint32_t seed, std::vector<float> delays, - std::vector<float> delay_std, - std::vector<float> delay_maxdev, + std::vector<float> delays_std, + std::vector<float> delays_maxdev, std::vector<float> mags, - int ntaps); + unsigned int ntaps); ~selective_fading_model2_impl(); void setup_rpc(); int work(int noutput_items, |