diff options
Diffstat (limited to 'gr-digital')
-rw-r--r-- | gr-digital/include/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-digital/include/Makefile.am | 2 | ||||
-rw-r--r-- | gr-digital/include/digital_probe_mpsk_snr_est_c.h | 76 | ||||
-rw-r--r-- | gr-digital/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-digital/lib/Makefile.am | 2 | ||||
-rw-r--r-- | gr-digital/lib/digital_probe_mpsk_snr_est_c.cc | 123 | ||||
-rw-r--r-- | gr-digital/swig/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-digital/swig/Makefile.am | 2 | ||||
-rw-r--r-- | gr-digital/swig/digital_probe_mpsk_snr_est_c.i | 41 | ||||
-rw-r--r-- | gr-digital/swig/digital_swig.i | 9 |
10 files changed, 258 insertions, 0 deletions
diff --git a/gr-digital/include/CMakeLists.txt b/gr-digital/include/CMakeLists.txt index 8bac4c991..81ed8d368 100644 --- a/gr-digital/include/CMakeLists.txt +++ b/gr-digital/include/CMakeLists.txt @@ -45,6 +45,7 @@ install(FILES digital_ofdm_insert_preamble.h digital_ofdm_mapper_bcv.h digital_ofdm_sampler.h + digital_probe_mpsk_snr_est_c.h digital_gmskmod_bc.h digital_cpmmod_bc.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio diff --git a/gr-digital/include/Makefile.am b/gr-digital/include/Makefile.am index 9fa619015..3cf186d3d 100644 --- a/gr-digital/include/Makefile.am +++ b/gr-digital/include/Makefile.am @@ -40,12 +40,14 @@ grinclude_HEADERS = \ digital_kurtotic_equalizer_cc.h \ digital_metric_type.h \ digital_mpsk_receiver_cc.h \ + digital_mpsk_snr_est_cc.h \ digital_ofdm_cyclic_prefixer.h \ digital_ofdm_frame_acquisition.h \ digital_ofdm_frame_sink.h \ digital_ofdm_insert_preamble.h \ digital_ofdm_mapper_bcv.h \ digital_ofdm_sampler.h \ + digital_probe_mpsk_snr_est_c.h \ digital_gmskmod_bc.h \ digital_cpmmod_bc.h diff --git a/gr-digital/include/digital_probe_mpsk_snr_est_c.h b/gr-digital/include/digital_probe_mpsk_snr_est_c.h new file mode 100644 index 000000000..4920a0ae3 --- /dev/null +++ b/gr-digital/include/digital_probe_mpsk_snr_est_c.h @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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_DIGITAL_PROBE_MPSK_SNR_EST_C_H +#define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include <digital_impl_mpsk_snr_est.h> + +class digital_probe_mpsk_snr_est_c; +typedef boost::shared_ptr<digital_probe_mpsk_snr_est_c> digital_probe_mpsk_snr_est_c_sptr; + +DIGITAL_API digital_probe_mpsk_snr_est_c_sptr +digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, double alpha); + +/*! + * Provides various methods to compute SNR. + */ +class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block +{ + private: + snr_est_type_t d_type; + double d_alpha; + digital_impl_mpsk_snr_est *d_snr_est; + + // Factory function returning shared pointer of this class + friend DIGITAL_API digital_probe_mpsk_snr_est_c_sptr + digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, double alpha); + + // Private constructor + digital_probe_mpsk_snr_est_c(snr_est_type_t type, double alpha); + +public: + + ~digital_probe_mpsk_snr_est_c(); + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + //! Return the estimated signal-to-noise ratio in decibels + double snr(); + + //! Return the type of estimator in use + snr_est_type_t type() const; + + //! Get the running-average coefficient + double alpha() const; + + //! Set type of estimator to use + void set_type(snr_est_type_t t); + + //! Set the running-average coefficient + void set_alpha(double alpha); +}; + +#endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */ diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index 94ef2b64d..779972ff3 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -54,6 +54,7 @@ list(APPEND gr_digital_sources digital_ofdm_insert_preamble.cc digital_ofdm_mapper_bcv.cc digital_ofdm_sampler.cc + digital_probe_mpsk_snr_est_c.cc digital_gmskmod_bc.cc digital_cpmmod_bc.cc ) diff --git a/gr-digital/lib/Makefile.am b/gr-digital/lib/Makefile.am index b6fea599f..d5ad199e3 100644 --- a/gr-digital/lib/Makefile.am +++ b/gr-digital/lib/Makefile.am @@ -42,12 +42,14 @@ libgnuradio_digital_la_SOURCES = \ digital_lms_dd_equalizer_cc.cc \ digital_kurtotic_equalizer_cc.cc \ digital_mpsk_receiver_cc.cc \ + digital_mpsk_snr_est_cc.cc \ digital_ofdm_cyclic_prefixer.cc \ digital_ofdm_frame_acquisition.cc \ digital_ofdm_frame_sink.cc \ digital_ofdm_insert_preamble.cc \ digital_ofdm_mapper_bcv.cc \ digital_ofdm_sampler.cc \ + digital_probe_mpsk_snr_est_c.cc \ digital_gmskmod_bc.cc \ digital_cpmmod_bc.cc diff --git a/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc new file mode 100644 index 000000000..259074e13 --- /dev/null +++ b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc @@ -0,0 +1,123 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <digital_probe_mpsk_snr_est_c.h> +#include <gr_io_signature.h> +#include <cstdio> + +digital_probe_mpsk_snr_est_c_sptr +digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, + double alpha) +{ + return gnuradio::get_initial_sptr( + new digital_probe_mpsk_snr_est_c(type, alpha)); +} + +digital_probe_mpsk_snr_est_c::digital_probe_mpsk_snr_est_c( + snr_est_type_t type, double alpha) + : gr_sync_block ("probe_mpsk_snr_est_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)) +{ + d_snr_est = NULL; + + d_type = type; + set_alpha(alpha); + + set_type(type); + + // at least 1 estimator has to look back + set_history(2); +} + +digital_probe_mpsk_snr_est_c::~digital_probe_mpsk_snr_est_c() +{ + if(d_snr_est) + delete d_snr_est; +} + +int +digital_probe_mpsk_snr_est_c::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + return d_snr_est->update(noutput_items, input_items); +} + +double +digital_probe_mpsk_snr_est_c::snr() +{ + if(d_snr_est) + return d_snr_est->snr(); + else + throw std::runtime_error("digital_probe_mpsk_snr_est_c:: No SNR estimator defined.\n"); +} + +snr_est_type_t +digital_probe_mpsk_snr_est_c::type() const +{ + return d_type; +} + +double +digital_probe_mpsk_snr_est_c::alpha() const +{ + return d_alpha; +} + +void +digital_probe_mpsk_snr_est_c::set_type(snr_est_type_t t) +{ + d_type = t; + + if(d_snr_est) + delete d_snr_est; + + switch (d_type) { + case(SNR_EST_SIMPLE): + d_snr_est = new digital_impl_mpsk_snr_est_simple(d_alpha); + break; + case(SNR_EST_SKEW): + d_snr_est = new digital_impl_mpsk_snr_est_skew(d_alpha); + break; + case(SNR_EST_M2M4): + d_snr_est = new digital_impl_mpsk_snr_est_m2m4(d_alpha); + break; + case(SNR_EST_SVN): + d_snr_est = new digital_impl_mpsk_snr_est_svn(d_alpha); + break; + default: + throw std::invalid_argument("digital_probe_mpsk_snr_est_c: unknown type specified.\n"); + } +} + +void +digital_probe_mpsk_snr_est_c::set_alpha(double alpha) +{ + d_alpha = alpha; + if(d_snr_est) + d_snr_est->set_alpha(d_alpha); +} diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt index 136f9e43f..6f2c2251a 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -66,6 +66,7 @@ install( digital_ofdm_insert_preamble.i digital_ofdm_mapper_bcv.i digital_ofdm_sampler.i + digital_probe_mpsk_snr_est_c.i digital_gmskmod_bc.i digital_cpmmod_bc.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig diff --git a/gr-digital/swig/Makefile.am b/gr-digital/swig/Makefile.am index 8591c8d74..97b47fafa 100644 --- a/gr-digital/swig/Makefile.am +++ b/gr-digital/swig/Makefile.am @@ -84,12 +84,14 @@ digital_swig_swiginclude_headers = \ digital_lms_dd_equalizer_cc.i \ digital_kurtotic_equalizer_cc.i \ digital_mpsk_receiver_cc.i \ + digital_mpsk_snr_est_cc.i \ digital_ofdm_cyclic_prefixer.i \ digital_ofdm_frame_acquisition.i \ digital_ofdm_frame_sink.i \ digital_ofdm_insert_preamble.i \ digital_ofdm_mapper_bcv.i \ digital_ofdm_sampler.i \ + digital_probe_mpsk_snr_est_c.i \ digital_gmskmod_bc.i \ digital_cpmmod_bc.i \ $(TOP_SWIG_DOC_IFILES) diff --git a/gr-digital/swig/digital_probe_mpsk_snr_est_c.i b/gr-digital/swig/digital_probe_mpsk_snr_est_c.i new file mode 100644 index 000000000..fe3684a81 --- /dev/null +++ b/gr-digital/swig/digital_probe_mpsk_snr_est_c.i @@ -0,0 +1,41 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital,probe_mpsk_snr_est_c); + +digital_probe_mpsk_snr_est_c_sptr +digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, + double alpha); + +class digital_probe_mpsk_snr_est_c : public gr_sync_block +{ +private: + void digital_probe_mpsk_snr_est_c(snr_est_type_t type, + double alpha); + +public: + double snr(); + snr_est_type_t type() const; + double alpha() const; + void set_type(snr_est_type_t t); + void set_alpha(double alpha); +}; diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index 9182b2b09..bc50fc727 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -24,6 +24,13 @@ //load generated python docstrings %include "digital_swig_doc.i" +enum snr_est_type_t { + SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB) + SNR_EST_SKEW, // Skewness-base est (>= 5 dB) + SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB) + SNR_EST_SVN // SVN-based est (>= 0dB) +}; + %include <gri_control_loop.i> %{ @@ -48,6 +55,7 @@ #include "digital_ofdm_insert_preamble.h" #include "digital_ofdm_mapper_bcv.h" #include "digital_ofdm_sampler.h" +#include "digital_probe_mpsk_snr_est_c.h" #include "digital_cpmmod_bc.h" #include "digital_gmskmod_bc.h" %} @@ -73,6 +81,7 @@ %include "digital_ofdm_insert_preamble.i" %include "digital_ofdm_mapper_bcv.i" %include "digital_ofdm_sampler.i" +%include "digital_probe_mpsk_snr_est_c.i" %include "digital_cpmmod_bc.i" %include "digital_gmskmod_bc.i" |