diff options
Diffstat (limited to 'gr-channels/lib')
-rw-r--r-- | gr-channels/lib/CMakeLists.txt | 57 | ||||
-rw-r--r-- | gr-channels/lib/channel_model_impl.cc | 137 | ||||
-rw-r--r-- | gr-channels/lib/channel_model_impl.h | 75 |
3 files changed, 269 insertions, 0 deletions
diff --git a/gr-channels/lib/CMakeLists.txt b/gr-channels/lib/CMakeLists.txt new file mode 100644 index 0000000000..ec3a8b3572 --- /dev/null +++ b/gr-channels/lib/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} + ${GR_FILTER_INCLUDE_DIRS} + ${GR_ANALOG_INCLUDE_DIRS} + ${GR_CHANNELS_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) + +link_directories(${Boost_LIBRARY_DIRS}) + +######################################################################## +# Setup library +######################################################################## +list(APPEND channels_sources + channel_model_impl.cc +) + +list(APPEND channels_libs + volk + gnuradio-core + gnuradio-filter + gnuradio-analog + gnuradio-blocks + ${Boost_LIBRARIES} +) + +add_library(gnuradio-channels SHARED ${channels_sources}) +target_link_libraries(gnuradio-channels ${channels_libs}) +GR_LIBRARY_FOO(gnuradio-channels RUNTIME_COMPONENT "channels_runtime" DEVEL_COMPONENT "channels_devel") +add_dependencies(gnuradio-channels + channels_generated_includes channels_generated_swigs + gnuradio-core gnuradio-filter gnuradio-analog gnuradio-blocks) diff --git a/gr-channels/lib/channel_model_impl.cc b/gr-channels/lib/channel_model_impl.cc new file mode 100644 index 0000000000..a9ed06eb53 --- /dev/null +++ b/gr-channels/lib/channel_model_impl.cc @@ -0,0 +1,137 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "channel_model_impl.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace channels { + + channel_model::sptr + channel_model::make(double noise_voltage, + double frequency_offset, + double epsilon, + const std::vector<gr_complex> &taps, + double noise_seed) + { + return gnuradio::get_initial_sptr + (new channel_model_impl(noise_voltage, + frequency_offset, + epsilon, + taps, + noise_seed)); + } + + // Hierarchical block constructor + channel_model_impl::channel_model_impl(double noise_voltage, + double frequency_offset, + double epsilon, + const std::vector<gr_complex> &taps, + double noise_seed) + : gr_hier_block2("channel_model", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex))) + { + d_taps = taps; + while(d_taps.size() < 2) { + d_taps.push_back(0); + } + + d_timing_offset = filter::fractional_interpolator_cc::make(0, epsilon); + + d_multipath = filter::fir_filter_ccc::make(1, d_taps); + + d_noise_adder = blocks::add_cc::make(); + d_noise = analog::noise_source_c::make(analog::GR_GAUSSIAN, + noise_voltage, noise_seed); + d_freq_offset = analog::sig_source_c::make(1, analog::GR_SIN_WAVE, + frequency_offset, 1.0, 0.0); + d_mixer_offset = blocks::multiply_cc::make(); + + connect(self(), 0, d_timing_offset, 0); + connect(d_timing_offset, 0, d_multipath, 0); + connect(d_multipath, 0, d_mixer_offset, 0); + connect(d_freq_offset, 0, d_mixer_offset, 1); + connect(d_mixer_offset, 0, d_noise_adder, 1); + connect(d_noise, 0, d_noise_adder, 0); + connect(d_noise_adder, 0, self(), 0); + } + + channel_model_impl::~channel_model_impl() + { + } + + void + channel_model_impl::set_noise_voltage(double noise_voltage) + { + d_noise->set_amplitude(noise_voltage); + } + + void + channel_model_impl::set_frequency_offset(double frequency_offset) + { + d_freq_offset->set_frequency(frequency_offset); + } + + void + channel_model_impl::set_taps(const std::vector<gr_complex> &taps) + { + d_taps = taps; + while(d_taps.size() < 2) { + d_taps.push_back(0); + } + d_multipath->set_taps(d_taps); + } + + void + channel_model_impl::set_timing_offset(double epsilon) + { + d_timing_offset->set_interp_ratio(epsilon); + } + + double + channel_model_impl::noise_voltage() const + { + return d_noise->amplitude(); + } + + double + channel_model_impl::frequency_offset() const + { + return d_freq_offset->frequency(); + } + + std::vector<gr_complex> + channel_model_impl::taps() const + { + return d_multipath->taps(); + } + + double + channel_model_impl::timing_offset() const + { + return d_timing_offset->interp_ratio(); + } + + } /* namespace channels */ +} /* namespace gr */ diff --git a/gr-channels/lib/channel_model_impl.h b/gr-channels/lib/channel_model_impl.h new file mode 100644 index 0000000000..03408dad64 --- /dev/null +++ b/gr-channels/lib/channel_model_impl.h @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_CHANNELS_CHANNEL_MODEL_IMPL_H +#define INCLUDED_CHANNELS_CHANNEL_MODEL_IMPL_H + +#include <gr_top_block.h> +#include <blocks/add_cc.h> +#include <blocks/multiply_cc.h> +#include <analog/sig_source_c.h> +#include <analog/noise_source_c.h> +#include <channels/channel_model.h> +#include <filter/fractional_interpolator_cc.h> +#include <filter/fir_filter_ccc.h> + +namespace gr { + namespace channels { + + class CHANNELS_API channel_model_impl : public channel_model + { + private: + blocks::add_cc::sptr d_noise_adder; + blocks::multiply_cc::sptr d_mixer_offset; + + analog::sig_source_c::sptr d_freq_offset; + analog::noise_source_c::sptr d_noise; + + filter::fractional_interpolator_cc::sptr d_timing_offset; + filter::fir_filter_ccc::sptr d_multipath; + + std::vector<gr_complex> d_taps; + + public: + channel_model_impl(double noise_voltage, + double frequency_offset, + double epsilon, + const std::vector<gr_complex> &taps, + double noise_seed); + + ~channel_model_impl(); + + void set_noise_voltage(double noise_voltage); + void set_frequency_offset(double frequency_offset); + void set_taps(const std::vector<gr_complex> &taps); + void set_timing_offset(double epsilon); + + double noise_voltage() const; + double frequency_offset() const; + std::vector<gr_complex> taps() const; + double timing_offset() const; + }; + + } /* namespace channels */ +} /* namespace gr */ + +#endif /* INCLUDED_CHANNELS_CHANNEL_MODEL_IMPL_H */ |