diff options
-rw-r--r-- | docs/doxygen/CMakeLists.txt | 4 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/CMakeLists.txt | 33 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/encoder.h (renamed from gr-trellis/include/gnuradio/trellis/encoder_XX.h.t) | 23 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/metrics.h (renamed from gr-trellis/include/gnuradio/trellis/metrics_X.h.t) | 27 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/pccc_decoder_blk.h (renamed from gr-trellis/include/gnuradio/trellis/pccc_decoder_X.h.t) | 20 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/pccc_decoder_combined_blk.h (renamed from gr-trellis/include/gnuradio/trellis/pccc_decoder_combined_XX.h.t) | 28 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/pccc_encoder.h (renamed from gr-trellis/include/gnuradio/trellis/pccc_encoder_XX.h.t) | 24 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/sccc_decoder_blk.h (renamed from gr-trellis/include/gnuradio/trellis/sccc_decoder_X.h.t) | 20 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/sccc_decoder_combined_blk.h (renamed from gr-trellis/include/gnuradio/trellis/sccc_decoder_combined_XX.h.t) | 28 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/sccc_encoder.h (renamed from gr-trellis/include/gnuradio/trellis/sccc_encoder_XX.h.t) | 22 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/viterbi.h (renamed from gr-trellis/include/gnuradio/trellis/viterbi_X.h.t) | 20 | ||||
-rw-r--r-- | gr-trellis/include/gnuradio/trellis/viterbi_combined.h (renamed from gr-trellis/include/gnuradio/trellis/viterbi_combined_XX.h.t) | 36 | ||||
-rw-r--r-- | gr-trellis/lib/CMakeLists.txt | 32 | ||||
-rw-r--r-- | gr-trellis/lib/encoder_XX_impl.cc.t | 118 | ||||
-rw-r--r-- | gr-trellis/lib/encoder_impl.cc | 131 | ||||
-rw-r--r-- | gr-trellis/lib/encoder_impl.h (renamed from gr-trellis/lib/encoder_XX_impl.h.t) | 21 | ||||
-rw-r--r-- | gr-trellis/lib/metrics_impl.cc (renamed from gr-trellis/lib/metrics_X_impl.cc.t) | 76 | ||||
-rw-r--r-- | gr-trellis/lib/metrics_impl.h (renamed from gr-trellis/lib/metrics_X_impl.h.t) | 24 | ||||
-rw-r--r-- | gr-trellis/lib/pccc_decoder_blk_impl.cc (renamed from gr-trellis/lib/pccc_decoder_X_impl.cc.t) | 39 | ||||
-rw-r--r-- | gr-trellis/lib/pccc_decoder_blk_impl.h (renamed from gr-trellis/lib/pccc_decoder_X_impl.h.t) | 18 | ||||
-rw-r--r-- | gr-trellis/lib/pccc_decoder_combined_blk_impl.cc (renamed from gr-trellis/lib/pccc_decoder_combined_XX_impl.cc.t) | 59 | ||||
-rw-r--r-- | gr-trellis/lib/pccc_decoder_combined_blk_impl.h (renamed from gr-trellis/lib/pccc_decoder_combined_XX_impl.h.t) | 25 | ||||
-rw-r--r-- | gr-trellis/lib/pccc_encoder_impl.cc (renamed from gr-trellis/lib/pccc_encoder_XX_impl.cc.t) | 42 | ||||
-rw-r--r-- | gr-trellis/lib/pccc_encoder_impl.h (renamed from gr-trellis/lib/pccc_encoder_XX_impl.h.t) | 19 | ||||
-rw-r--r-- | gr-trellis/lib/sccc_decoder_blk_impl.cc (renamed from gr-trellis/lib/sccc_decoder_X_impl.cc.t) | 39 | ||||
-rw-r--r-- | gr-trellis/lib/sccc_decoder_blk_impl.h (renamed from gr-trellis/lib/sccc_decoder_X_impl.h.t) | 18 | ||||
-rw-r--r-- | gr-trellis/lib/sccc_decoder_combined_blk_impl.cc (renamed from gr-trellis/lib/sccc_decoder_combined_XX_impl.cc.t) | 60 | ||||
-rw-r--r-- | gr-trellis/lib/sccc_decoder_combined_blk_impl.h (renamed from gr-trellis/lib/sccc_decoder_combined_XX_impl.h.t) | 25 | ||||
-rw-r--r-- | gr-trellis/lib/sccc_encoder_impl.cc (renamed from gr-trellis/lib/sccc_encoder_XX_impl.cc.t) | 44 | ||||
-rw-r--r-- | gr-trellis/lib/sccc_encoder_impl.h (renamed from gr-trellis/lib/sccc_encoder_XX_impl.h.t) | 19 | ||||
-rw-r--r-- | gr-trellis/lib/viterbi_combined_XX_impl.cc.t | 153 | ||||
-rw-r--r-- | gr-trellis/lib/viterbi_combined_impl.cc | 176 | ||||
-rw-r--r-- | gr-trellis/lib/viterbi_combined_impl.h (renamed from gr-trellis/lib/viterbi_combined_XX_impl.h.t) | 27 | ||||
-rw-r--r-- | gr-trellis/lib/viterbi_impl.cc (renamed from gr-trellis/lib/viterbi_X_impl.cc.t) | 65 | ||||
-rw-r--r-- | gr-trellis/lib/viterbi_impl.h (renamed from gr-trellis/lib/viterbi_X_impl.h.t) | 18 | ||||
-rw-r--r-- | gr-trellis/swig/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-trellis/swig/trellis_swig0.i | 96 | ||||
-rw-r--r-- | gr-trellis/swig/trellis_swig1.i | 145 |
38 files changed, 913 insertions, 862 deletions
diff --git a/docs/doxygen/CMakeLists.txt b/docs/doxygen/CMakeLists.txt index 019b01c305..8c8bd4b248 100644 --- a/docs/doxygen/CMakeLists.txt +++ b/docs/doxygen/CMakeLists.txt @@ -45,10 +45,6 @@ if(ENABLE_GNURADIO_RUNTIME) list(APPEND GENERATED_DEPS pmt_generated) endif(ENABLE_GNURADIO_RUNTIME) -if(ENABLE_GR_TRELLIS) - list(APPEND GENERATED_DEPS trellis_generated_includes) -endif(ENABLE_GR_TRELLIS) - ######################################################################## # Make and install doxygen docs ######################################################################## diff --git a/gr-trellis/include/gnuradio/trellis/CMakeLists.txt b/gr-trellis/include/gnuradio/trellis/CMakeLists.txt index 831f2916dc..a9c664606c 100644 --- a/gr-trellis/include/gnuradio/trellis/CMakeLists.txt +++ b/gr-trellis/include/gnuradio/trellis/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012,2014 Free Software Foundation, Inc. +# Copyright 2012,2014,2018 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -18,41 +18,30 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# Invoke macro to generate various headers -######################################################################## -include(GrMiscUtils) -GR_EXPAND_X_H(trellis encoder_XX bb bs bi ss si ii) -GR_EXPAND_X_H(trellis sccc_encoder_XX bb bs bi ss si ii) -GR_EXPAND_X_H(trellis pccc_encoder_XX bb bs bi ss si ii) -GR_EXPAND_X_H(trellis metrics_X s i f c) -GR_EXPAND_X_H(trellis viterbi_X b s i) -GR_EXPAND_X_H(trellis viterbi_combined_XX sb ss si ib is ii fb fs fi cb cs ci) -GR_EXPAND_X_H(trellis sccc_decoder_X b s i) -GR_EXPAND_X_H(trellis sccc_decoder_combined_XX fb fs fi cb cs ci) -GR_EXPAND_X_H(trellis pccc_decoder_X b s i) -GR_EXPAND_X_H(trellis pccc_decoder_combined_XX fb fs fi cb cs ci) - -add_custom_target(trellis_generated_includes DEPENDS - ${generated_includes} -) - -######################################################################## # Install header files ######################################################################## install(FILES - ${generated_includes} api.h base.h calc_metric.h constellation_metrics_cf.h core_algorithms.h + encoder.h fsm.h interleaver.h + metrics.h + pccc_decoder_blk.h + pccc_decoder_combined_blk.h + pccc_encoder.h permutation.h quicksort_index.h + sccc_encoder.h + sccc_decoder_blk.h + sccc_decoder_combined_blk.h siso_type.h siso_combined_f.h siso_f.h + viterbi.h + viterbi_combined.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/trellis ) - diff --git a/gr-trellis/include/gnuradio/trellis/encoder_XX.h.t b/gr-trellis/include/gnuradio/trellis/encoder.h index affd62f68b..5f022f2a01 100644 --- a/gr-trellis/include/gnuradio/trellis/encoder_XX.h.t +++ b/gr-trellis/include/gnuradio/trellis/encoder.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,14 +20,13 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef ENCODER_H +#define ENCODER_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> #include <gnuradio/sync_block.h> +#include <cstdint> namespace gr { namespace trellis { @@ -36,11 +35,11 @@ namespace gr { * \brief Convolutional encoder. * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public sync_block + template <class IN_T, class OUT_T> + class TRELLIS_API encoder : virtual public sync_block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + typedef boost::shared_ptr< encoder<IN_T,OUT_T> > sptr; static sptr make(const fsm &FSM, int ST); @@ -53,8 +52,14 @@ namespace gr { virtual void set_ST(int ST) =0; virtual void set_K(int K) =0; }; + typedef encoder<std::uint8_t, std::uint8_t> encoder_bb; + typedef encoder<std::uint8_t, std::int16_t> encoder_bs; + typedef encoder<std::uint8_t, std::int32_t> encoder_bi; + typedef encoder<std::int16_t, std::int16_t> encoder_ss; + typedef encoder<std::int16_t, std::int32_t> encoder_si; + typedef encoder<std::int32_t, std::int32_t> encoder_ii; } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* ENCODER_H */ diff --git a/gr-trellis/include/gnuradio/trellis/metrics_X.h.t b/gr-trellis/include/gnuradio/trellis/metrics.h index f463c865a9..e2ca32222a 100644 --- a/gr-trellis/include/gnuradio/trellis/metrics_X.h.t +++ b/gr-trellis/include/gnuradio/trellis/metrics.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,14 +20,14 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef METRICS_H +#define METRICS_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/calc_metric.h> #include <gnuradio/block.h> +#include <cstdint> namespace gr { namespace trellis { @@ -36,28 +36,33 @@ namespace gr { * \brief Evaluate metrics for use by the Viterbi algorithm. * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block +template<class T> + class TRELLIS_API metrics : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + // gr::trellis::metrics::sptr + typedef boost::shared_ptr< metrics<T> > sptr; - static sptr make(int O, int D, const std::vector<@I_TYPE@> &TABLE, + static sptr make(int O, int D, const std::vector<T> &TABLE, digital::trellis_metric_type_t TYPE); virtual int O() const = 0; virtual int D() const = 0; virtual digital::trellis_metric_type_t TYPE() const = 0; - virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual std::vector<T> TABLE() const = 0; virtual void set_O(int O) = 0; virtual void set_D(int D) = 0; virtual void set_TYPE(digital::trellis_metric_type_t type) = 0; - virtual void set_TABLE(const std::vector<@I_TYPE@> &table) = 0; + virtual void set_TABLE(const std::vector<T> &table) = 0; }; +typedef metrics<std::int16_t> metrics_s; +typedef metrics<std::int32_t> metrics_i; +typedef metrics<float> metrics_f; +typedef metrics<gr_complex> metrics_c; } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* METRICS_H */ diff --git a/gr-trellis/include/gnuradio/trellis/pccc_decoder_X.h.t b/gr-trellis/include/gnuradio/trellis/pccc_decoder_blk.h index affce07042..8684f33f03 100644 --- a/gr-trellis/include/gnuradio/trellis/pccc_decoder_X.h.t +++ b/gr-trellis/include/gnuradio/trellis/pccc_decoder_blk.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,9 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef PCCC_DECODER_BLK_H +#define PCCC_DECODER_BLK_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> @@ -31,6 +30,7 @@ #include <gnuradio/trellis/siso_type.h> #include <gnuradio/block.h> #include <vector> +#include <cstdint> namespace gr { namespace trellis { @@ -38,11 +38,12 @@ namespace gr { /*! * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block +template<class T> + class TRELLIS_API pccc_decoder_blk : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + // gr::trellis::pccc_decoder_blk::sptr + typedef boost::shared_ptr< pccc_decoder_blk<T> > sptr; static sptr make(const fsm &FSM1, int ST10, int ST1K, const fsm &FSM2, int ST20, int ST2K, @@ -63,7 +64,10 @@ namespace gr { virtual siso_type_t SISO_TYPE() const = 0; }; +typedef pccc_decoder_blk<std::uint8_t> pccc_decoder_b; +typedef pccc_decoder_blk<std::int16_t> pccc_decoder_s; +typedef pccc_decoder_blk<std::int32_t> pccc_decoder_i; } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* PCCC_DECODER_BLK_H */ diff --git a/gr-trellis/include/gnuradio/trellis/pccc_decoder_combined_XX.h.t b/gr-trellis/include/gnuradio/trellis/pccc_decoder_combined_blk.h index 719b0aa1e5..e09c08f3bc 100644 --- a/gr-trellis/include/gnuradio/trellis/pccc_decoder_combined_XX.h.t +++ b/gr-trellis/include/gnuradio/trellis/pccc_decoder_combined_blk.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,8 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef PCCC_DECODER_COMBINED_BLK_H +#define PCCC_DECODER_COMBINED_BLK_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> @@ -32,6 +30,7 @@ #include <gnuradio/trellis/siso_type.h> #include <gnuradio/block.h> #include <vector> +#include <cstdint> namespace gr { namespace trellis { @@ -39,11 +38,11 @@ namespace gr { /*! * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block + template <class IN_T,class OUT_T> + class TRELLIS_API pccc_decoder_combined_blk : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + typedef boost::shared_ptr< pccc_decoder_combined_blk<IN_T,OUT_T> > sptr; static sptr make(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, @@ -52,7 +51,7 @@ namespace gr { int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling); @@ -66,14 +65,21 @@ namespace gr { virtual int blocklength() const = 0; virtual int repetitions() const = 0; virtual int D() const = 0; - virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual std::vector<IN_T> TABLE() const = 0; virtual digital::trellis_metric_type_t METRIC_TYPE() const = 0; virtual siso_type_t SISO_TYPE() const = 0; virtual float scaling() const = 0; virtual void set_scaling(float scaling) = 0; }; + typedef pccc_decoder_combined_blk<float, std::uint8_t> pccc_decoder_combined_fb; + typedef pccc_decoder_combined_blk<float, std::int16_t> pccc_decoder_combined_fs; + typedef pccc_decoder_combined_blk<float, std::int32_t> pccc_decoder_combined_fi; + typedef pccc_decoder_combined_blk<gr_complex, std::uint8_t> pccc_decoder_combined_cb; + typedef pccc_decoder_combined_blk<gr_complex, std::int16_t> pccc_decoder_combined_cs; + typedef pccc_decoder_combined_blk<gr_complex, std::int32_t> pccc_decoder_combined_ci; + } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* PCCC_DECODER_COMBINED_BLK_H */ diff --git a/gr-trellis/include/gnuradio/trellis/pccc_encoder_XX.h.t b/gr-trellis/include/gnuradio/trellis/pccc_encoder.h index 5308fe275d..6f3ee25170 100644 --- a/gr-trellis/include/gnuradio/trellis/pccc_encoder_XX.h.t +++ b/gr-trellis/include/gnuradio/trellis/pccc_encoder.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,16 +20,15 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef PCCC_ENCODER_H +#define PCCC_ENCODER_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> #include <gnuradio/trellis/interleaver.h> #include <gnuradio/sync_block.h> #include <vector> +#include <cstdint> namespace gr { namespace trellis { @@ -38,11 +37,11 @@ namespace gr { * \brief PCCC encoder. * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public sync_block + template <class IN_T, class OUT_T> + class TRELLIS_API pccc_encoder : virtual public sync_block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + typedef boost::shared_ptr<pccc_encoder<IN_T,OUT_T>> sptr; static sptr make(const fsm &FSM1, int ST1, const fsm &FSM2, int ST2, @@ -56,8 +55,15 @@ namespace gr { virtual interleaver INTERLEAVER() const = 0; virtual int blocklength() const = 0; }; + typedef pccc_encoder<std::uint8_t, std::uint8_t> pccc_encoder_bb; + typedef pccc_encoder<std::uint8_t, std::int16_t> pccc_encoder_bs; + typedef pccc_encoder<std::uint8_t, std::int32_t> pccc_encoder_bi; + typedef pccc_encoder<std::int16_t, std::int16_t> pccc_encoder_ss; + typedef pccc_encoder<std::int16_t, std::int32_t> pccc_encoder_si; + typedef pccc_encoder<std::int32_t, std::int32_t> pccc_encoder_ii; + } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* PCCC_ENCODER_H */ diff --git a/gr-trellis/include/gnuradio/trellis/sccc_decoder_X.h.t b/gr-trellis/include/gnuradio/trellis/sccc_decoder_blk.h index cc1d86b709..48b90dc927 100644 --- a/gr-trellis/include/gnuradio/trellis/sccc_decoder_X.h.t +++ b/gr-trellis/include/gnuradio/trellis/sccc_decoder_blk.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,9 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef SCCC_DECODER_BLK_H +#define SCCC_DECODER_BLK_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> @@ -31,6 +30,7 @@ #include <gnuradio/trellis/siso_type.h> #include <gnuradio/block.h> #include <vector> +#include <cstdint> namespace gr { namespace trellis { @@ -38,11 +38,12 @@ namespace gr { /*! * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block +template<class T> + class TRELLIS_API sccc_decoder_blk : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + // gr::trellis::sccc_decoder_blk::sptr + typedef boost::shared_ptr< sccc_decoder_blk<T> > sptr; static sptr make(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, @@ -63,7 +64,10 @@ namespace gr { virtual siso_type_t SISO_TYPE() const = 0; }; +typedef sccc_decoder_blk<std::uint8_t> sccc_decoder_b; +typedef sccc_decoder_blk<std::int16_t> sccc_decoder_s; +typedef sccc_decoder_blk<std::int32_t> sccc_decoder_i; } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* SCCC_DECODER_BLK_H */ diff --git a/gr-trellis/include/gnuradio/trellis/sccc_decoder_combined_XX.h.t b/gr-trellis/include/gnuradio/trellis/sccc_decoder_combined_blk.h index e1f95dff1f..cfec71e981 100644 --- a/gr-trellis/include/gnuradio/trellis/sccc_decoder_combined_XX.h.t +++ b/gr-trellis/include/gnuradio/trellis/sccc_decoder_combined_blk.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,8 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef SCCC_DECODER_COMBINED_BLK_H +#define SCCC_DECODER_COMBINED_BLK_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> @@ -32,6 +30,7 @@ #include <gnuradio/trellis/siso_type.h> #include <gnuradio/block.h> #include <vector> +#include <cstdint> namespace gr { namespace trellis { @@ -39,11 +38,11 @@ namespace gr { /*! * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block + template <class IN_T,class OUT_T> + class TRELLIS_API sccc_decoder_combined_blk : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + typedef boost::shared_ptr< sccc_decoder_combined_blk<IN_T,OUT_T> > sptr; static sptr make(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, @@ -52,7 +51,7 @@ namespace gr { int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling); @@ -66,7 +65,7 @@ namespace gr { virtual int blocklength() const = 0; virtual int repetitions() const = 0; virtual int D() const = 0; - virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual std::vector<IN_T> TABLE() const = 0; virtual digital::trellis_metric_type_t METRIC_TYPE() const = 0; virtual siso_type_t SISO_TYPE() const = 0; virtual float scaling() const = 0; @@ -74,7 +73,14 @@ namespace gr { virtual void set_scaling(float scaling) = 0; }; + typedef sccc_decoder_combined_blk<float, std::uint8_t> sccc_decoder_combined_fb; + typedef sccc_decoder_combined_blk<float, std::int16_t> sccc_decoder_combined_fs; + typedef sccc_decoder_combined_blk<float, std::int32_t> sccc_decoder_combined_fi; + typedef sccc_decoder_combined_blk<gr_complex, std::uint8_t> sccc_decoder_combined_cb; + typedef sccc_decoder_combined_blk<gr_complex, std::int16_t> sccc_decoder_combined_cs; + typedef sccc_decoder_combined_blk<gr_complex, std::int32_t> sccc_decoder_combined_ci; + } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* SCCC_DECODER_COMBINED_H */ diff --git a/gr-trellis/include/gnuradio/trellis/sccc_encoder_XX.h.t b/gr-trellis/include/gnuradio/trellis/sccc_encoder.h index 85fad02eeb..394cce50de 100644 --- a/gr-trellis/include/gnuradio/trellis/sccc_encoder_XX.h.t +++ b/gr-trellis/include/gnuradio/trellis/sccc_encoder.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,8 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef SCCC_ENCODER_H +#define SCCC_ENCODER_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> @@ -38,11 +36,11 @@ namespace gr { * \brief SCCC encoder. * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public sync_block + template <class IN_T, class OUT_T> + class TRELLIS_API sccc_encoder : virtual public sync_block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + typedef boost::shared_ptr< sccc_encoder<IN_T,OUT_T> > sptr; static sptr make(const fsm &FSMo, int STo, const fsm &FSMi, int STi, @@ -56,8 +54,14 @@ namespace gr { virtual interleaver INTERLEAVER() const = 0; virtual int blocklength() const = 0; }; + typedef sccc_encoder<std::uint8_t, std::uint8_t> sccc_encoder_bb; + typedef sccc_encoder<std::uint8_t, std::int16_t> sccc_encoder_bs; + typedef sccc_encoder<std::uint8_t, std::int32_t> sccc_encoder_bi; + typedef sccc_encoder<std::int16_t, std::int16_t> sccc_encoder_ss; + typedef sccc_encoder<std::uint8_t, std::int32_t> sccc_encoder_si; + typedef sccc_encoder<std::int32_t, std::int32_t> sccc_encoder_ii; } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* SCCC_ENCODER_H */ diff --git a/gr-trellis/include/gnuradio/trellis/viterbi_X.h.t b/gr-trellis/include/gnuradio/trellis/viterbi.h index 252ffb715d..c37392fb99 100644 --- a/gr-trellis/include/gnuradio/trellis/viterbi_X.h.t +++ b/gr-trellis/include/gnuradio/trellis/viterbi.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,15 +20,15 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef VITERBI_H +#define VITERBI_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> #include <gnuradio/trellis/core_algorithms.h> #include <gnuradio/block.h> +#include <cstdint> namespace gr { namespace trellis { @@ -36,11 +36,12 @@ namespace gr { /*! * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block +template<class T> + class TRELLIS_API viterbi : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + // gr::trellis::viterbi::sptr + typedef boost::shared_ptr< viterbi<T> > sptr; static sptr make(const fsm &FSM, int K, int S0, int SK); @@ -56,7 +57,10 @@ namespace gr { virtual void set_SK(int SK) =0; }; +typedef viterbi<std::uint8_t> viterbi_b; +typedef viterbi<std::int16_t> viterbi_s; +typedef viterbi<std::int32_t> viterbi_i; } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* VITERBI_H */ diff --git a/gr-trellis/include/gnuradio/trellis/viterbi_combined_XX.h.t b/gr-trellis/include/gnuradio/trellis/viterbi_combined.h index 4546e95739..b48106a8b4 100644 --- a/gr-trellis/include/gnuradio/trellis/viterbi_combined_XX.h.t +++ b/gr-trellis/include/gnuradio/trellis/viterbi_combined.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,16 +20,15 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef VITERBI_COMBINED_H +#define VITERBI_COMBINED_H #include <gnuradio/trellis/api.h> #include <gnuradio/trellis/fsm.h> #include <gnuradio/trellis/calc_metric.h> #include <gnuradio/trellis/core_algorithms.h> #include <gnuradio/block.h> +#include <cstdint> namespace gr { namespace trellis { @@ -37,15 +36,15 @@ namespace gr { /*! * \ingroup trellis_coding_blk */ - class TRELLIS_API @NAME@ : virtual public block + template <class IN_T,class OUT_T> + class TRELLIS_API viterbi_combined : virtual public block { public: - // gr::trellis::@BASE_NAME@::sptr - typedef boost::shared_ptr<@BASE_NAME@> sptr; + typedef boost::shared_ptr< viterbi_combined<IN_T,OUT_T> > sptr; static sptr make(const fsm &FSM, int K, int S0, int SK, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t TYPE); virtual fsm FSM() const = 0; @@ -53,7 +52,7 @@ namespace gr { virtual int S0() const = 0; virtual int SK() const = 0; virtual int D() const = 0; - virtual std::vector<@I_TYPE@> TABLE() const = 0; + virtual std::vector<IN_T> TABLE() const = 0; virtual digital::trellis_metric_type_t TYPE() const = 0; virtual void set_FSM(const fsm &FSM) =0; @@ -61,11 +60,24 @@ namespace gr { virtual void set_S0(int S0) =0; virtual void set_SK(int SK) =0; virtual void set_D(int D) =0; - virtual void set_TABLE (const std::vector<@I_TYPE@> &table) = 0; + virtual void set_TABLE (const std::vector<IN_T> &table) = 0; virtual void set_TYPE(digital::trellis_metric_type_t type) = 0; }; + typedef viterbi_combined<std::int16_t, std::uint8_t> viterbi_combined_sb; + typedef viterbi_combined<std::int16_t, std::int16_t> viterbi_combined_ss; + typedef viterbi_combined<std::int16_t, std::int32_t> viterbi_combined_si; + typedef viterbi_combined<std::int32_t, std::uint8_t> viterbi_combined_ib; + typedef viterbi_combined<std::int32_t, std::int16_t> viterbi_combined_is; + typedef viterbi_combined<std::int32_t, std::int32_t> viterbi_combined_ii; + typedef viterbi_combined<float, std::uint8_t> viterbi_combined_fb; + typedef viterbi_combined<float, std::int16_t> viterbi_combined_fs; + typedef viterbi_combined<float, std::int32_t> viterbi_combined_fi; + typedef viterbi_combined<gr_complex, std::uint8_t> viterbi_combined_cb; + typedef viterbi_combined<gr_complex, std::int16_t> viterbi_combined_cs; + typedef viterbi_combined<gr_complex, std::int32_t> viterbi_combined_ci; + } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* VITERBI_COMBINED_H */ diff --git a/gr-trellis/lib/CMakeLists.txt b/gr-trellis/lib/CMakeLists.txt index a016f9885a..968de82879 100644 --- a/gr-trellis/lib/CMakeLists.txt +++ b/gr-trellis/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012,2014 Free Software Foundation, Inc. +# Copyright 2012,2014,2018 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -34,36 +34,30 @@ if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) endif(ENABLE_GR_CTRLPORT) -####################################################################### -# Invoke macro to generate various sources and headers -######################################################################## -include(GrMiscUtils) -GR_EXPAND_X_CC_H(trellis encoder_XX_impl bb bs bi ss si ii) -GR_EXPAND_X_CC_H(trellis sccc_encoder_XX_impl bb bs bi ss si ii) -GR_EXPAND_X_CC_H(trellis pccc_encoder_XX_impl bb bs bi ss si ii) -GR_EXPAND_X_CC_H(trellis metrics_X_impl s i f c) -GR_EXPAND_X_CC_H(trellis viterbi_X_impl b s i) -GR_EXPAND_X_CC_H(trellis viterbi_combined_XX_impl sb ss si ib is ii fb fs fi cb cs ci) -GR_EXPAND_X_CC_H(trellis sccc_decoder_X_impl b s i) -GR_EXPAND_X_CC_H(trellis sccc_decoder_combined_XX_impl fb fs fi cb cs ci) -GR_EXPAND_X_CC_H(trellis pccc_decoder_X_impl b s i) -GR_EXPAND_X_CC_H(trellis pccc_decoder_combined_XX_impl fb fs fi cb cs ci) - ######################################################################## # Setup library ######################################################################## list(APPEND trellis_sources - ${generated_sources} base.cc calc_metric.cc core_algorithms.cc + encoder_impl.cc fsm.cc interleaver.cc quicksort_index.cc constellation_metrics_cf_impl.cc + metrics_impl.cc + pccc_decoder_blk_impl.cc + pccc_encoder_impl.cc + pccc_decoder_combined_blk_impl.cc permutation_impl.cc + sccc_decoder_blk_impl.cc + sccc_decoder_combined_blk_impl.cc + sccc_encoder_impl.cc siso_f_impl.cc siso_combined_f_impl.cc + viterbi_impl.cc + viterbi_combined_impl.cc ) list(APPEND trellis_libs @@ -90,7 +84,7 @@ add_library(gnuradio-trellis SHARED ${trellis_sources}) target_link_libraries(gnuradio-trellis ${trellis_libs}) GR_LIBRARY_FOO(gnuradio-trellis) add_dependencies(gnuradio-trellis - trellis_generated_includes trellis_generated_swigs + trellis_generated_swigs gnuradio-runtime gnuradio-digital) if(ENABLE_STATIC_LIBS) @@ -108,7 +102,7 @@ if(ENABLE_STATIC_LIBS) add_library(gnuradio-trellis_static STATIC ${trellis_sources}) add_dependencies(gnuradio-trellis_static - trellis_generated_includes trellis_generated_swigs + trellis_generated_swigs gnuradio-runtime_static gnuradio-digital_static ) diff --git a/gr-trellis/lib/encoder_XX_impl.cc.t b/gr-trellis/lib/encoder_XX_impl.cc.t deleted file mode 100644 index 3a004a2f94..0000000000 --- a/gr-trellis/lib/encoder_XX_impl.cc.t +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,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. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "@NAME@.h" -#include <gnuradio/io_signature.h> -#include <iostream> - -namespace gr { - namespace trellis { - - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSM, int ST) - { - return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSM,ST,0,false)); - } - - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSM, int ST, int K) - { - return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSM,ST,K,true)); - } - - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM, int ST, int K, bool B) - : sync_block("@BASE_NAME@", - io_signature::make(1, 1, sizeof(@I_TYPE@)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), - d_FSM(FSM), - d_ST(ST), - d_K(K), - d_B(B) - { - } - - void @IMPL_NAME@::set_FSM(const fsm &FSM) - { - gr::thread::scoped_lock guard(d_setlock); - d_FSM = FSM; - } - - void @IMPL_NAME@::set_ST(int ST) - { - gr::thread::scoped_lock guard(d_setlock); - d_ST = ST; - } - - void @IMPL_NAME@::set_K(int K) - { - gr::thread::scoped_lock guard(d_setlock); - d_K = K; - } - - @IMPL_NAME@::~@IMPL_NAME@() - { - } - - int - @IMPL_NAME@::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - gr::thread::scoped_lock guard(d_setlock); - int ST_tmp = 0; - - if (d_B){ // blockwise operation - int nblocks = noutput_items /d_K; - const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - for(int n = 0; n < nblocks; n++) { - ST_tmp = d_ST; - for(int i = 0; i < d_K; i++) { - out[n*d_K+i] = (@O_TYPE@)d_FSM.OS()[ST_tmp*d_FSM.I()+in[n*d_K+i]]; - ST_tmp = (int)d_FSM.NS()[ST_tmp*d_FSM.I()+in[n*d_K+i]]; - } - } - return nblocks*d_K; - } // end blockwise operation - else{ // streaming operation - const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - ST_tmp = d_ST; - for(int i = 0; i < noutput_items; i++) { - out[i] = (@O_TYPE@)d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; - ST_tmp = (int)d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; - } - d_ST = ST_tmp; - return noutput_items; - } // end streaming operation - } - - } /* namespace trellis */ -} /* namespace gr */ diff --git a/gr-trellis/lib/encoder_impl.cc b/gr-trellis/lib/encoder_impl.cc new file mode 100644 index 0000000000..ecb0410a5f --- /dev/null +++ b/gr-trellis/lib/encoder_impl.cc @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012,2018 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 "encoder_impl.h" +#include <gnuradio/io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + template <class IN_T, class OUT_T> + typename encoder<IN_T,OUT_T>::sptr + encoder<IN_T,OUT_T>::make(const fsm &FSM, int ST) + { + return gnuradio::get_initial_sptr + (new encoder_impl<IN_T,OUT_T>(FSM,ST,0,false)); + } + + template <class IN_T, class OUT_T> + typename encoder<IN_T,OUT_T>::sptr + encoder<IN_T,OUT_T>::make(const fsm &FSM, int ST, int K) + { + return gnuradio::get_initial_sptr + (new encoder_impl<IN_T,OUT_T>(FSM,ST,K,true)); + } + + template <class IN_T, class OUT_T> + encoder_impl<IN_T,OUT_T>::encoder_impl(const fsm &FSM, int ST, int K, bool B) + : sync_block("encoder<IN_T,OUT_T>", + io_signature::make(1, 1, sizeof(IN_T)), + io_signature::make(1, 1, sizeof(OUT_T))), + d_FSM(FSM), + d_ST(ST), + d_K(K), + d_B(B) + { + } + + template <class IN_T, class OUT_T> + void encoder_impl<IN_T,OUT_T>::set_FSM(const fsm &FSM) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_FSM = FSM; + } + + template <class IN_T, class OUT_T> + void encoder_impl<IN_T,OUT_T>::set_ST(int ST) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_ST = ST; + } + + template <class IN_T, class OUT_T> + void encoder_impl<IN_T,OUT_T>::set_K(int K) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_K = K; + } + + template <class IN_T, class OUT_T> + encoder_impl<IN_T,OUT_T>::~encoder_impl() + { + } + + template <class IN_T, class OUT_T> + int + encoder_impl<IN_T,OUT_T>::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr::thread::scoped_lock guard(this->d_setlock); + int ST_tmp = 0; + + if (d_B){ // blockwise operation + int nblocks = noutput_items /d_K; + const IN_T *in = (const IN_T*)input_items[0]; + OUT_T *out = (OUT_T *) output_items[0]; + for(int n = 0; n < nblocks; n++) { + ST_tmp = d_ST; + for(int i = 0; i < d_K; i++) { + out[n*d_K+i] = (OUT_T)d_FSM.OS()[ST_tmp*d_FSM.I()+in[n*d_K+i]]; + ST_tmp = (int)d_FSM.NS()[ST_tmp*d_FSM.I()+in[n*d_K+i]]; + } + } + return nblocks*d_K; + } // end blockwise operation + else{ // streaming operation + const IN_T *in = (const IN_T*)input_items[0]; + OUT_T *out = (OUT_T *) output_items[0]; + ST_tmp = d_ST; + for(int i = 0; i < noutput_items; i++) { + out[i] = (OUT_T)d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; + ST_tmp = (int)d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + d_ST = ST_tmp; + return noutput_items; + } // end streaming operation + } + template class encoder<std::uint8_t, std::uint8_t>; + template class encoder<std::uint8_t, std::int16_t>; + template class encoder<std::uint8_t, std::int32_t>; + template class encoder<std::int16_t, std::int16_t>; + template class encoder<std::int16_t, std::int32_t>; + template class encoder<std::int32_t, std::int32_t>; + + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/encoder_XX_impl.h.t b/gr-trellis/lib/encoder_impl.h index 2b0ff31f4d..5832b9d848 100644 --- a/gr-trellis/lib/encoder_XX_impl.h.t +++ b/gr-trellis/lib/encoder_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,28 +20,27 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +#ifndef ENCODER_IMPL_H +#define ENCODER_IMPL_H -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/encoder.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ + template <class IN_T, class OUT_T> + class encoder_impl : public encoder<IN_T,OUT_T> { private: fsm d_FSM; int d_ST; int d_K; bool d_B; - + public: - @IMPL_NAME@(const fsm &FSM, int ST, int K, bool B); - ~@IMPL_NAME@(); + encoder_impl(const fsm &FSM, int ST, int K, bool B); + ~encoder_impl(); fsm FSM() const { return d_FSM;; } int ST() const { return d_ST; } @@ -57,4 +56,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* ENCODER_IMPL_H */ diff --git a/gr-trellis/lib/metrics_X_impl.cc.t b/gr-trellis/lib/metrics_impl.cc index 5e74e4b2fc..cf0697c521 100644 --- a/gr-trellis/lib/metrics_X_impl.cc.t +++ b/gr-trellis/lib/metrics_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,12 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "metrics_impl.h" #include <gnuradio/io_signature.h> #include <assert.h> #include <stdexcept> @@ -35,61 +34,69 @@ namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(int O, int D, const std::vector<@I_TYPE@> &TABLE, + template <class T> + typename metrics<T>::sptr + metrics<T>::make(int O, int D, const std::vector<T> &TABLE, digital::trellis_metric_type_t TYPE) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(O,D,TABLE,TYPE)); + (new metrics_impl<T>(O,D,TABLE,TYPE)); } - @IMPL_NAME@::@IMPL_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + template <class T> + metrics_impl<T>::metrics_impl(int O, int D, const std::vector<T> &TABLE, digital::trellis_metric_type_t TYPE) - : block("@BASE_NAME@", - io_signature::make(1, -1, sizeof (@I_TYPE@)), + : block("metrics", + io_signature::make(1, -1, sizeof (T)), io_signature::make(1, -1, sizeof (float))), d_O(O), d_D(D), d_TYPE(TYPE), d_TABLE(TABLE) { - set_relative_rate (1.0 * d_O / ((double) d_D)); - set_output_multiple ((int)d_O); + this->set_relative_rate (1.0 * d_O / ((double) d_D)); + this->set_output_multiple ((int)d_O); } - void @IMPL_NAME@::set_O(int O) - { - gr::thread::scoped_lock guard(d_setlock); - d_O = O; - set_relative_rate (1.0 * d_O / ((double) d_D)); - set_output_multiple ((int)d_O); + template <class T> + void metrics_impl<T>::set_O(int O) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_O = O; + this->set_relative_rate (1.0 * d_O / ((double) d_D)); + this->set_output_multiple ((int)d_O); } - void @IMPL_NAME@::set_D(int D) - { - gr::thread::scoped_lock guard(d_setlock); - d_D = D; - set_relative_rate (1.0 * d_O / ((double) d_D)); + template <class T> + void metrics_impl<T>::set_D(int D) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_D = D; + this->set_relative_rate (1.0 * d_O / ((double) d_D)); } + template <class T> void - @IMPL_NAME@::set_TYPE(digital::trellis_metric_type_t type) + metrics_impl<T>::set_TYPE(digital::trellis_metric_type_t type) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_TYPE = type; } + template <class T> void - @IMPL_NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) + metrics_impl<T>::set_TABLE(const std::vector<T> &table) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_TABLE = table; } - @IMPL_NAME@::~@IMPL_NAME@() + template <class T> + metrics_impl<T>::~metrics_impl() { } + template <class T> void - @IMPL_NAME@::forecast(int noutput_items, gr_vector_int &ninput_items_required) + metrics_impl<T>::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int input_required = d_D * noutput_items / d_O; unsigned ninputs = ninput_items_required.size(); @@ -97,17 +104,18 @@ namespace gr { ninput_items_required[i] = input_required; } + template <class T> int - @IMPL_NAME@::general_work(int noutput_items, + metrics_impl<T>::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); int nstreams = input_items.size(); for(int m = 0; m < nstreams; m++) { - const @I_TYPE@ *in = (@I_TYPE@*)input_items[m]; + const T *in = (T*)input_items[m]; float *out = (float*)output_items[m]; for(int i = 0; i < noutput_items / d_O ; i++) { @@ -115,9 +123,13 @@ namespace gr { } } - consume_each(d_D * noutput_items / d_O); + this->consume_each(d_D * noutput_items / d_O); return noutput_items; } +template class metrics<std::int16_t>; +template class metrics<std::int32_t>; +template class metrics<float>; +template class metrics<gr_complex>; } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/metrics_X_impl.h.t b/gr-trellis/lib/metrics_impl.h index 9323ae4645..95c5f44845 100644 --- a/gr-trellis/lib/metrics_X_impl.h.t +++ b/gr-trellis/lib/metrics_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,38 +20,38 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef METRICS_IMPL_H +#define METRICS_IMPL_H -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/metrics.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ +template<class T> + class metrics_impl : public metrics<T> { private: int d_O; int d_D; digital::trellis_metric_type_t d_TYPE; - std::vector<@I_TYPE@> d_TABLE; + std::vector<T> d_TABLE; public: - @IMPL_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + metrics_impl(int O, int D, const std::vector<T> &TABLE, digital::trellis_metric_type_t TYPE); - ~@IMPL_NAME@(); + ~metrics_impl(); int O() const { return d_O; } int D() const { return d_D; } digital::trellis_metric_type_t TYPE() const { return d_TYPE; } - std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + std::vector<T> TABLE() const { return d_TABLE; } void set_O(int O); void set_D(int D); void set_TYPE(digital::trellis_metric_type_t type); - void set_TABLE(const std::vector<@I_TYPE@> &table); + void set_TABLE(const std::vector<T> &table); void forecast(int noutput_items, gr_vector_int &ninput_items_required); @@ -65,4 +65,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* METRICS_IMPL_H */ diff --git a/gr-trellis/lib/pccc_decoder_X_impl.cc.t b/gr-trellis/lib/pccc_decoder_blk_impl.cc index 4f80598540..3cadff97ea 100644 --- a/gr-trellis/lib/pccc_decoder_X_impl.cc.t +++ b/gr-trellis/lib/pccc_decoder_blk_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,12 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "pccc_decoder_blk_impl.h" #include <gnuradio/io_signature.h> #include <iostream> #include <gnuradio/trellis/core_algorithms.h> @@ -34,8 +33,9 @@ namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSM1, int ST10, int ST1K, + template <class T> + typename pccc_decoder_blk<T>::sptr + pccc_decoder_blk<T>::make(const fsm &FSM1, int ST10, int ST1K, const fsm &FSM2, int ST20, int ST2K, const interleaver &INTERLEAVER, int blocklength, @@ -43,7 +43,7 @@ namespace gr { siso_type_t SISO_TYPE) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSM1, ST10, ST1K, + (new pccc_decoder_blk_impl<T>(FSM1, ST10, ST1K, FSM2, ST20, ST2K, INTERLEAVER, blocklength, @@ -51,15 +51,16 @@ namespace gr { SISO_TYPE)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM1, int ST10, int ST1K, + template <class T> + pccc_decoder_blk_impl<T>::pccc_decoder_blk_impl(const fsm &FSM1, int ST10, int ST1K, const fsm &FSM2, int ST20, int ST2K, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE) - : block("@BASE_NAME@", + : block("pccc_decoder_blk", io_signature::make(1, 1, sizeof(float)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), + io_signature::make(1, 1, sizeof(T))), d_FSM1(FSM1), d_ST10(ST10), d_ST1K(ST1K), d_FSM2(FSM2), d_ST20(ST20), d_ST2K(ST2K), d_INTERLEAVER(INTERLEAVER), @@ -67,16 +68,18 @@ namespace gr { d_repetitions(repetitions), d_SISO_TYPE(SISO_TYPE) { - set_relative_rate (1.0 / ((double) d_FSM1.O() * d_FSM2.O())); - set_output_multiple (d_blocklength); + this->set_relative_rate (1.0 / ((double) d_FSM1.O() * d_FSM2.O())); + this->set_output_multiple (d_blocklength); } - @IMPL_NAME@::~@IMPL_NAME@() + template <class T> + pccc_decoder_blk_impl<T>::~pccc_decoder_blk_impl() { } + template <class T> void - @IMPL_NAME@::forecast(int noutput_items, + pccc_decoder_blk_impl<T>::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int input_required = d_FSM1.O() * d_FSM2.O() * noutput_items; @@ -85,8 +88,9 @@ namespace gr { //=========================================================== + template <class T> int - @IMPL_NAME@::general_work(int noutput_items, + pccc_decoder_blk_impl<T>::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) @@ -100,7 +104,7 @@ namespace gr { p2min = &min_star; const float *in = (const float *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; + T *out = (T *) output_items[0]; for(int n=0;n<nblocks;n++) { pccc_decoder(d_FSM1, d_ST10, d_ST1K, d_FSM2, d_ST20, d_ST2K, @@ -110,9 +114,12 @@ namespace gr { &(out[n*d_blocklength])); } - consume_each(d_FSM1.O() * d_FSM2.O() * noutput_items); + this->consume_each(d_FSM1.O() * d_FSM2.O() * noutput_items); return noutput_items; } +template class pccc_decoder_blk<std::uint8_t>; +template class pccc_decoder_blk<std::int16_t>; +template class pccc_decoder_blk<std::int32_t>; } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/pccc_decoder_X_impl.h.t b/gr-trellis/lib/pccc_decoder_blk_impl.h index 43a7257fc5..ed4e2d24a6 100644 --- a/gr-trellis/lib/pccc_decoder_X_impl.h.t +++ b/gr-trellis/lib/pccc_decoder_blk_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,17 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef PCCC_DECODER_BLK_IMPL_H +#define PCCC_DECODER_BLK_IMPL_H -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/pccc_decoder_blk.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ +template<class T> + class pccc_decoder_blk_impl : public pccc_decoder_blk<T> { private: fsm d_FSM1; @@ -46,13 +46,13 @@ namespace gr { std::vector<float> d_buffer; public: - @IMPL_NAME@(const fsm &FSM1, int ST10, int ST1K, + pccc_decoder_blk_impl(const fsm &FSM1, int ST10, int ST1K, const fsm &FSM2, int ST20, int ST2K, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE); - ~@IMPL_NAME@(); + ~pccc_decoder_blk_impl(); fsm FSM1() const { return d_FSM1; } fsm FSM2() const { return d_FSM2; } @@ -77,4 +77,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* PCCC_DECODER_BLK_IMPL_H */ diff --git a/gr-trellis/lib/pccc_decoder_combined_XX_impl.cc.t b/gr-trellis/lib/pccc_decoder_combined_blk_impl.cc index 6841066416..a985c0d9c0 100644 --- a/gr-trellis/lib/pccc_decoder_combined_XX_impl.cc.t +++ b/gr-trellis/lib/pccc_decoder_combined_blk_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,11 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "pccc_decoder_combined_blk_impl.h" #include <gnuradio/io_signature.h> #include <iostream> #include <gnuradio/trellis/core_algorithms.h> @@ -34,37 +32,39 @@ namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSMo, int STo0, int SToK, + template <class IN_T,class OUT_T> + typename pccc_decoder_combined_blk<IN_T,OUT_T>::sptr + pccc_decoder_combined_blk<IN_T,OUT_T>::make(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling) { return gnuradio::get_initial_sptr - (new @NAME@(FSMo, STo0, SToK, FSMi, STi0, STiK, + (new pccc_decoder_combined_blk_impl<IN_T,OUT_T>(FSMo, STo0, SToK, FSMi, STi0, STiK, INTERLEAVER, blocklength, repetitions, SISO_TYPE, D, TABLE,METRIC_TYPE, scaling)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + template <class IN_T,class OUT_T> + pccc_decoder_combined_blk_impl<IN_T,OUT_T>::pccc_decoder_combined_blk_impl(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling) - : block("@BASE_NAME@", - io_signature::make(1, 1, sizeof(@I_TYPE@)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), + : block("pccc_decoder_combined_blk<IN_T,OUT_T>", + io_signature::make(1, 1, sizeof(IN_T)), + io_signature::make(1, 1, sizeof(OUT_T))), d_FSMo(FSMo), d_STo0(STo0), d_SToK(SToK), d_FSMi(FSMi), d_STi0(STi0), d_STiK(STiK), d_INTERLEAVER(INTERLEAVER), @@ -77,23 +77,26 @@ namespace gr { d_scaling(scaling) { assert(d_FSMo.I() == d_FSMi.I()); - set_relative_rate (1.0 / ((double) d_D)); - set_output_multiple (d_blocklength); + this->set_relative_rate (1.0 / ((double) d_D)); + this->set_output_multiple (d_blocklength); } - @IMPL_NAME@::~@IMPL_NAME@() + template <class IN_T,class OUT_T> + pccc_decoder_combined_blk_impl<IN_T,OUT_T>::~pccc_decoder_combined_blk_impl() { } + template <class IN_T,class OUT_T> void - @IMPL_NAME@::set_scaling(float scaling) + pccc_decoder_combined_blk_impl<IN_T,OUT_T>::set_scaling(float scaling) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_scaling = scaling; } + template <class IN_T,class OUT_T> void - @IMPL_NAME@::forecast(int noutput_items, + pccc_decoder_combined_blk_impl<IN_T,OUT_T>::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int input_required = d_D * noutput_items; @@ -102,13 +105,14 @@ namespace gr { //=========================================================== + template <class IN_T,class OUT_T> int - @IMPL_NAME@::general_work(int noutput_items, + pccc_decoder_combined_blk_impl<IN_T,OUT_T>::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); int nblocks = noutput_items / d_blocklength; float (*p2min)(float, float) = NULL; @@ -117,8 +121,8 @@ namespace gr { else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) p2min = &min_star; - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; + const IN_T *in = (const IN_T *) input_items[0]; + OUT_T *out = (OUT_T *) output_items[0]; for (int n=0;n<nblocks;n++) { pccc_decoder_combined(d_FSMo, d_STo0, d_SToK, d_FSMi, d_STi0, d_STiK, @@ -131,9 +135,16 @@ namespace gr { &(out[n*d_blocklength])); } - consume_each(d_D * noutput_items); + this->consume_each(d_D * noutput_items); return noutput_items; } + template class pccc_decoder_combined_blk<float, std::uint8_t>; + template class pccc_decoder_combined_blk<float, std::int16_t>; + template class pccc_decoder_combined_blk<float, std::int32_t>; + template class pccc_decoder_combined_blk<gr_complex, std::uint8_t>; + template class pccc_decoder_combined_blk<gr_complex, std::int16_t>; + template class pccc_decoder_combined_blk<gr_complex, std::int32_t>; + } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/pccc_decoder_combined_XX_impl.h.t b/gr-trellis/lib/pccc_decoder_combined_blk_impl.h index 7606017547..544a965607 100644 --- a/gr-trellis/lib/pccc_decoder_combined_XX_impl.h.t +++ b/gr-trellis/lib/pccc_decoder_combined_blk_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +#ifndef PCCC_DECODER_COMBINED_BLK_IMPL_H +#define PCCC_DECODER_COMBINED_BLK_IMPL_H -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/pccc_decoder_combined_blk.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ + template <class IN_T,class OUT_T> + class pccc_decoder_combined_blk_impl : public pccc_decoder_combined_blk<IN_T,OUT_T> { private: fsm d_FSMo; @@ -44,23 +43,23 @@ namespace gr { int d_repetitions; siso_type_t d_SISO_TYPE; int d_D; - std::vector<@I_TYPE@> d_TABLE; + std::vector<IN_T> d_TABLE; digital::trellis_metric_type_t d_METRIC_TYPE; float d_scaling; std::vector<float> d_buffer; public: - @IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + pccc_decoder_combined_blk_impl(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling); - ~@IMPL_NAME@(); + ~pccc_decoder_combined_blk_impl(); fsm FSM1() const { return d_FSMo; } fsm FSM2() const { return d_FSMi; } @@ -72,7 +71,7 @@ namespace gr { int blocklength() const { return d_blocklength; } int repetitions() const { return d_repetitions; } int D() const { return d_D; } - std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + std::vector<IN_T> TABLE() const { return d_TABLE; } digital::trellis_metric_type_t METRIC_TYPE() const { return d_METRIC_TYPE; } siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } float scaling() const { return d_scaling; } @@ -90,4 +89,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* PCCC_DECODER_COMBINED_BLK_IMPL_H */ diff --git a/gr-trellis/lib/pccc_encoder_XX_impl.cc.t b/gr-trellis/lib/pccc_encoder_impl.cc index 8fd143ca9d..2804f4b39c 100644 --- a/gr-trellis/lib/pccc_encoder_XX_impl.cc.t +++ b/gr-trellis/lib/pccc_encoder_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,58 +20,60 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "pccc_encoder_impl.h" #include <gnuradio/io_signature.h> #include <iostream> namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSM1, int ST1, + template <class IN_T, class OUT_T> + typename pccc_encoder<IN_T,OUT_T>::sptr + pccc_encoder<IN_T,OUT_T>::make(const fsm &FSM1, int ST1, const fsm &FSM2, int ST2, const interleaver &INTERLEAVER, int blocklength) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSM1, ST1, FSM2, ST2, INTERLEAVER, blocklength)); + (new pccc_encoder_impl<IN_T,OUT_T>(FSM1, ST1, FSM2, ST2, INTERLEAVER, blocklength)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM1, int ST1, + template <class IN_T, class OUT_T> + pccc_encoder_impl<IN_T,OUT_T>::pccc_encoder_impl(const fsm &FSM1, int ST1, const fsm &FSM2, int ST2, const interleaver &INTERLEAVER, int blocklength) - : sync_block("@BASE_NAME@", - io_signature::make(1, 1, sizeof(@I_TYPE@)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), + : sync_block("pccc_encoder<IN_T,OUT_T>", + io_signature::make(1, 1, sizeof(IN_T)), + io_signature::make(1, 1, sizeof(OUT_T))), d_FSM1(FSM1), d_ST1(ST1), d_FSM2(FSM2), d_ST2(ST2), d_INTERLEAVER(INTERLEAVER), d_blocklength(blocklength) { assert(d_FSM1.I() == d_FSM2.I()); - set_output_multiple(d_blocklength); + this->set_output_multiple(d_blocklength); d_buffer.resize(d_blocklength); } - @IMPL_NAME@::~@IMPL_NAME@() + template <class IN_T, class OUT_T> + pccc_encoder_impl<IN_T,OUT_T>::~pccc_encoder_impl() { } + template <class IN_T, class OUT_T> int - @NAME@::work(int noutput_items, + pccc_encoder_impl<IN_T,OUT_T>::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { for(int b = 0 ; b<noutput_items/d_blocklength; b++) { - const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]+b*d_blocklength; - @O_TYPE@ *out = (@O_TYPE@*)output_items[0]+b*d_blocklength; + const IN_T *in = (const IN_T*)input_items[0]+b*d_blocklength; + OUT_T *out = (OUT_T*)output_items[0]+b*d_blocklength; int ST1_tmp = d_ST1; int ST2_tmp = d_ST2; @@ -81,11 +83,17 @@ namespace gr { ST1_tmp = (int) d_FSM1.NS()[ST1_tmp*d_FSM1.I()+in[i]]; int o2 = d_FSM2.OS()[ST2_tmp*d_FSM2.I()+in[k]]; ST2_tmp = (int) d_FSM2.NS()[ST2_tmp*d_FSM2.I()+in[k]]; - out[i] = (@O_TYPE@) (o1*d_FSM2.O() + o2); + out[i] = (OUT_T) (o1*d_FSM2.O() + o2); } } return noutput_items; } + template class pccc_encoder<std::uint8_t, std::uint8_t>; + template class pccc_encoder<std::uint8_t, std::int16_t>; + template class pccc_encoder<std::uint8_t, std::int32_t>; + template class pccc_encoder<std::int16_t, std::int16_t>; + template class pccc_encoder<std::int16_t, std::int32_t>; + template class pccc_encoder<std::int32_t, std::int32_t>; } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/pccc_encoder_XX_impl.h.t b/gr-trellis/lib/pccc_encoder_impl.h index 5561b716d3..834e8986c4 100644 --- a/gr-trellis/lib/pccc_encoder_XX_impl.h.t +++ b/gr-trellis/lib/pccc_encoder_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +#ifndef PCCC_ENCODER_IMPL_H +#define PCCC_ENCODER_IMPL_H -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/pccc_encoder.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ + template <class IN_T, class OUT_T> + class pccc_encoder_impl : public pccc_encoder<IN_T,OUT_T> { private: fsm d_FSM1; @@ -42,11 +41,11 @@ namespace gr { std::vector<int> d_buffer; public: - @IMPL_NAME@(const fsm &FSM1, int ST1, + pccc_encoder_impl(const fsm &FSM1, int ST1, const fsm &FSM2, int ST2, const interleaver &INTERLEAVER, int blocklength); - ~@IMPL_NAME@(); + ~pccc_encoder_impl(); fsm FSM1() const { return d_FSM1; } int ST1() const { return d_ST1; } @@ -63,4 +62,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* PCCC_ENCODER_IMPL_H */ diff --git a/gr-trellis/lib/sccc_decoder_X_impl.cc.t b/gr-trellis/lib/sccc_decoder_blk_impl.cc index 6f1bac585a..7855f9f0fe 100644 --- a/gr-trellis/lib/sccc_decoder_X_impl.cc.t +++ b/gr-trellis/lib/sccc_decoder_blk_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,12 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "sccc_decoder_blk_impl.h" #include <gnuradio/io_signature.h> #include <iostream> #include <gnuradio/trellis/core_algorithms.h> @@ -34,8 +33,9 @@ namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSMo, int STo0, int SToK, + template <class T> + typename sccc_decoder_blk<T>::sptr + sccc_decoder_blk<T>::make(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, @@ -43,20 +43,21 @@ namespace gr { siso_type_t SISO_TYPE) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSMo, STo0, SToK, FSMi, STi0, STiK, + (new sccc_decoder_blk_impl<T>(FSMo, STo0, SToK, FSMi, STi0, STiK, INTERLEAVER, blocklength, repetitions, SISO_TYPE)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + template <class T> + sccc_decoder_blk_impl<T>::sccc_decoder_blk_impl(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE) - : block("@BASE_NAME@", + : block("sccc_decoder_blk", io_signature::make(1, 1, sizeof(float)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), + io_signature::make(1, 1, sizeof(T))), d_FSMo(FSMo), d_STo0(STo0), d_SToK(SToK), d_FSMi(FSMi), d_STi0(STi0), d_STiK(STiK), d_INTERLEAVER(INTERLEAVER), @@ -64,16 +65,18 @@ namespace gr { d_repetitions(repetitions), d_SISO_TYPE(SISO_TYPE) { - set_relative_rate(1.0 / ((double) d_FSMi.O())); - set_output_multiple(d_blocklength); + this->set_relative_rate(1.0 / ((double) d_FSMi.O())); + this->set_output_multiple(d_blocklength); } - @IMPL_NAME@::~@IMPL_NAME@() + template <class T> + sccc_decoder_blk_impl<T>::~sccc_decoder_blk_impl() { } + template <class T> void - @IMPL_NAME@::forecast(int noutput_items, + sccc_decoder_blk_impl<T>::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int input_required = d_FSMi.O() * noutput_items ; @@ -82,8 +85,9 @@ namespace gr { //=========================================================== + template <class T> int - @IMPL_NAME@::general_work(int noutput_items, + sccc_decoder_blk_impl<T>::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) @@ -97,7 +101,7 @@ namespace gr { p2min = &min_star; const float *in = (const float*)input_items[0]; - @O_TYPE@ *out = (@O_TYPE@*)output_items[0]; + T *out = (T*)output_items[0]; for(int n = 0; n < nblocks; n++) { sccc_decoder(d_FSMo, d_STo0, d_SToK, @@ -108,9 +112,12 @@ namespace gr { &(out[n*d_blocklength])); } - consume_each(d_FSMi.O() * noutput_items ); + this->consume_each(d_FSMi.O() * noutput_items ); return noutput_items; } +template class sccc_decoder_blk<std::uint8_t>; +template class sccc_decoder_blk<std::int16_t>; +template class sccc_decoder_blk<std::int32_t>; } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/sccc_decoder_X_impl.h.t b/gr-trellis/lib/sccc_decoder_blk_impl.h index c79e6ebbab..0c3e2d9310 100644 --- a/gr-trellis/lib/sccc_decoder_X_impl.h.t +++ b/gr-trellis/lib/sccc_decoder_blk_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,17 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef SCCC_DECODER_BLK_IMPL_H +#define SCCC_DECODER_BLK_IMPL_H -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/sccc_decoder_blk.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ +template<class T> + class sccc_decoder_blk_impl : public sccc_decoder_blk<T> { private: fsm d_FSMo; @@ -46,13 +46,13 @@ namespace gr { std::vector<float> d_buffer; public: - @IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + sccc_decoder_blk_impl(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE); - ~@IMPL_NAME@(); + ~sccc_decoder_blk_impl(); fsm FSMo() const { return d_FSMo; } fsm FSMi() const { return d_FSMi; } @@ -77,4 +77,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* SCCC_DECODER_BLK_IMPL_H */ diff --git a/gr-trellis/lib/sccc_decoder_combined_XX_impl.cc.t b/gr-trellis/lib/sccc_decoder_combined_blk_impl.cc index 224c5f8027..bf8845ce52 100644 --- a/gr-trellis/lib/sccc_decoder_combined_XX_impl.cc.t +++ b/gr-trellis/lib/sccc_decoder_combined_blk_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,11 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "sccc_decoder_combined_blk_impl.h" #include <gnuradio/io_signature.h> #include <iostream> #include <gnuradio/trellis/core_algorithms.h> @@ -34,37 +32,39 @@ namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSMo, int STo0, int SToK, + template <class IN_T, class OUT_T> + typename sccc_decoder_combined_blk<IN_T,OUT_T>::sptr + sccc_decoder_combined_blk<IN_T,OUT_T>::make(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSMo, STo0, SToK, FSMi, STi0, STiK, + (new sccc_decoder_combined_blk_impl<IN_T,OUT_T>(FSMo, STo0, SToK, FSMi, STi0, STiK, INTERLEAVER, blocklength, repetitions, SISO_TYPE, D, TABLE,METRIC_TYPE, scaling)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + template <class IN_T, class OUT_T> + sccc_decoder_combined_blk_impl<IN_T,OUT_T>::sccc_decoder_combined_blk_impl(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling) - : block("@BASE_NAME@", - io_signature::make(1, 1, sizeof(@I_TYPE@)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), + : block("sccc_decoder_combined_blk<IN_T,OUT_T>", + io_signature::make(1, 1, sizeof(IN_T)), + io_signature::make(1, 1, sizeof(OUT_T))), d_FSMo(FSMo), d_STo0(STo0), d_SToK(SToK), d_FSMi(FSMi), d_STi0(STi0), d_STiK(STiK), d_INTERLEAVER(INTERLEAVER), @@ -76,23 +76,26 @@ namespace gr { d_METRIC_TYPE(METRIC_TYPE), d_scaling(scaling) { - set_relative_rate(1.0 / ((double) d_D)); - set_output_multiple(d_blocklength); + this->set_relative_rate(1.0 / ((double) d_D)); + this->set_output_multiple(d_blocklength); } - @IMPL_NAME@::~@IMPL_NAME@() + template <class IN_T, class OUT_T> + sccc_decoder_combined_blk_impl<IN_T,OUT_T>::~sccc_decoder_combined_blk_impl() { } + template <class IN_T, class OUT_T> void - @IMPL_NAME@::set_scaling(float scaling) + sccc_decoder_combined_blk_impl<IN_T,OUT_T>::set_scaling(float scaling) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_scaling = scaling; } + template <class IN_T, class OUT_T> void - @IMPL_NAME@::forecast(int noutput_items, + sccc_decoder_combined_blk_impl<IN_T,OUT_T>::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int input_required = d_D * noutput_items ; @@ -101,13 +104,14 @@ namespace gr { //=========================================================== + template <class IN_T, class OUT_T> int - @IMPL_NAME@::general_work(int noutput_items, + sccc_decoder_combined_blk_impl<IN_T,OUT_T>::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); int nblocks = noutput_items / d_blocklength; float (*p2min)(float, float) = NULL; @@ -116,8 +120,8 @@ namespace gr { else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) p2min = &min_star; - const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]; - @O_TYPE@ *out = (@O_TYPE@*)output_items[0]; + const IN_T *in = (const IN_T*)input_items[0]; + OUT_T *out = (OUT_T*)output_items[0]; for(int n = 0; n < nblocks; n++) { sccc_decoder_combined(d_FSMo, d_STo0, d_SToK, @@ -131,9 +135,17 @@ namespace gr { &(out[n*d_blocklength])); } - consume_each(d_D * noutput_items); + this->consume_each(d_D * noutput_items); return noutput_items; } + template class sccc_decoder_combined_blk<float, std::uint8_t>; + template class sccc_decoder_combined_blk<float, std::int16_t>; + template class sccc_decoder_combined_blk<float, std::int32_t>; + template class sccc_decoder_combined_blk<gr_complex, std::uint8_t>; + template class sccc_decoder_combined_blk<gr_complex, std::int16_t>; + template class sccc_decoder_combined_blk<gr_complex, std::int32_t>; + + } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/sccc_decoder_combined_XX_impl.h.t b/gr-trellis/lib/sccc_decoder_combined_blk_impl.h index 6a38f0114f..8236c79a49 100644 --- a/gr-trellis/lib/sccc_decoder_combined_XX_impl.h.t +++ b/gr-trellis/lib/sccc_decoder_combined_blk_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +#ifndef SCCC_DECODER_COMBINED_BLK_IMPL_H +#define SCCC_DECODER_COMBINED_BLK_IMPL_H -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/sccc_decoder_combined_blk.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ + template <class IN_T, class OUT_T> + class sccc_decoder_combined_blk_impl : public sccc_decoder_combined_blk<IN_T,OUT_T> { private: fsm d_FSMo; @@ -44,23 +43,23 @@ namespace gr { int d_repetitions; siso_type_t d_SISO_TYPE; int d_D; - std::vector<@I_TYPE@> d_TABLE; + std::vector<IN_T> d_TABLE; digital::trellis_metric_type_t d_METRIC_TYPE; float d_scaling; std::vector<float> d_buffer; public: - @IMPL_NAME@(const fsm &FSMo, int STo0, int SToK, + sccc_decoder_combined_blk_impl(const fsm &FSMo, int STo0, int SToK, const fsm &FSMi, int STi0, int STiK, const interleaver &INTERLEAVER, int blocklength, int repetitions, siso_type_t SISO_TYPE, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t METRIC_TYPE, float scaling); - ~@IMPL_NAME@(); + ~sccc_decoder_combined_blk_impl(); fsm FSMo() const { return d_FSMo; } fsm FSMi() const { return d_FSMi; } @@ -72,7 +71,7 @@ namespace gr { int blocklength() const { return d_blocklength; } int repetitions() const { return d_repetitions; } int D() const { return d_D; } - std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + std::vector<IN_T> TABLE() const { return d_TABLE; } digital::trellis_metric_type_t METRIC_TYPE() const { return d_METRIC_TYPE; } siso_type_t SISO_TYPE() const { return d_SISO_TYPE; } float scaling() const { return d_scaling; } @@ -90,4 +89,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* SCCC_DECODER_COMBINED_BLK_IMPL_H */ diff --git a/gr-trellis/lib/sccc_encoder_XX_impl.cc.t b/gr-trellis/lib/sccc_encoder_impl.cc index 9924b3c7d2..9c3e1da2d5 100644 --- a/gr-trellis/lib/sccc_encoder_XX_impl.cc.t +++ b/gr-trellis/lib/sccc_encoder_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,57 +20,59 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "sccc_encoder_impl.h" #include <gnuradio/io_signature.h> #include <iostream> namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSMo, int STo, + template <class IN_T, class OUT_T> + typename sccc_encoder<IN_T,OUT_T>::sptr + sccc_encoder<IN_T,OUT_T>::make(const fsm &FSMo, int STo, const fsm &FSMi, int STi, const interleaver &INTERLEAVER, int blocklength) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSMo, STo, FSMi, STi, INTERLEAVER, blocklength)); + (new sccc_encoder_impl<IN_T,OUT_T>(FSMo, STo, FSMi, STi, INTERLEAVER, blocklength)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSMo, int STo, + template <class IN_T, class OUT_T> + sccc_encoder_impl<IN_T,OUT_T>::sccc_encoder_impl(const fsm &FSMo, int STo, const fsm &FSMi, int STi, const interleaver &INTERLEAVER, int blocklength) - : sync_block("@BASE_NAME@", - io_signature::make(1, 1, sizeof(@I_TYPE@)), - io_signature::make(1, 1, sizeof(@O_TYPE@))), + : sync_block("sccc_encoder<IN_T,OUT_T>", + io_signature::make(1, 1, sizeof(IN_T)), + io_signature::make(1, 1, sizeof(OUT_T))), d_FSMo(FSMo), d_STo(STo), d_FSMi(FSMi), d_STi(STi), d_INTERLEAVER(INTERLEAVER), d_blocklength(blocklength) { - set_output_multiple(d_blocklength); + this->set_output_multiple(d_blocklength); d_buffer.resize(d_blocklength); } - @IMPL_NAME@::~@IMPL_NAME@() + template <class IN_T, class OUT_T> + sccc_encoder_impl<IN_T,OUT_T>::~sccc_encoder_impl() { } + template <class IN_T, class OUT_T> int - @IMPL_NAME@::work(int noutput_items, + sccc_encoder_impl<IN_T,OUT_T>::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { for(int b = 0; b < noutput_items/d_blocklength; b++) { - const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]+b*d_blocklength; - @O_TYPE@ *out = (@O_TYPE@*)output_items[0]+b*d_blocklength; + const IN_T *in = (const IN_T*)input_items[0]+b*d_blocklength; + OUT_T *out = (OUT_T*)output_items[0]+b*d_blocklength; int STo_tmp = d_STo; for(int i = 0; i < d_blocklength; i++) { @@ -81,13 +83,19 @@ namespace gr { int STi_tmp = d_STi; for(int i = 0; i < d_blocklength; i++) { int k = d_INTERLEAVER.INTER()[i]; - out[i] = (@O_TYPE@) d_FSMi.OS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; + out[i] = (OUT_T) d_FSMi.OS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; STi_tmp = (int) d_FSMi.NS()[STi_tmp*d_FSMi.I()+d_buffer[k]]; } } return noutput_items; } + template class sccc_encoder<std::uint8_t, std::uint8_t>; + template class sccc_encoder<std::uint8_t, std::int16_t>; + template class sccc_encoder<std::uint8_t, std::int32_t>; + template class sccc_encoder<std::int16_t, std::int16_t>; + template class sccc_encoder<std::int16_t, std::int32_t>; + template class sccc_encoder<std::int32_t, std::int32_t>; + } /* namespace trellis */ } /* namespace gr */ - diff --git a/gr-trellis/lib/sccc_encoder_XX_impl.h.t b/gr-trellis/lib/sccc_encoder_impl.h index fc64f2ade8..40968906dc 100644 --- a/gr-trellis/lib/sccc_encoder_XX_impl.h.t +++ b/gr-trellis/lib/sccc_encoder_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +#ifndef SCCC_ENCODER_IMPL_H +#define SCCC_ENCODER_IMPL_H -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/sccc_encoder.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ + template <class IN_T, class OUT_T> + class sccc_encoder_impl : public sccc_encoder<IN_T,OUT_T> { private: fsm d_FSMo; @@ -42,11 +41,11 @@ namespace gr { std::vector<int> d_buffer; public: - @IMPL_NAME@(const fsm &FSMo, int STo, + sccc_encoder_impl(const fsm &FSMo, int STo, const fsm &FSMi, int STi, const interleaver &INTERLEAVER, int blocklength); - ~@IMPL_NAME@(); + ~sccc_encoder_impl(); fsm FSMo() const { return d_FSMo; } int STo() const { return d_STo; } @@ -63,4 +62,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* SCCC_ENCODER_IMPL_H */ diff --git a/gr-trellis/lib/viterbi_combined_XX_impl.cc.t b/gr-trellis/lib/viterbi_combined_XX_impl.cc.t deleted file mode 100644 index 6d83dc4402..0000000000 --- a/gr-trellis/lib/viterbi_combined_XX_impl.cc.t +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,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. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "@NAME@.h" -#include <gnuradio/io_signature.h> -#include <iostream> - -namespace gr { - namespace trellis { - - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSM, int K, - int S0, int SK, int D, - const std::vector<@I_TYPE@> &TABLE, - digital::trellis_metric_type_t TYPE) - { - return gnuradio::get_initial_sptr - (new @NAME@(FSM, K, S0, SK, D, TABLE,TYPE)); - } - - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM, int K, - int S0, int SK, int D, - const std::vector<@I_TYPE@> &TABLE, - digital::trellis_metric_type_t TYPE) - : block("@BASE_NAME@", - io_signature::make(1, -1, sizeof(@I_TYPE@)), - io_signature::make(1, -1, sizeof(@O_TYPE@))), - d_FSM(FSM), d_K(K), d_S0(S0), d_SK(SK), d_D(D), - d_TABLE(TABLE), d_TYPE(TYPE)//, - //d_trace(FSM.S()*K) - { - set_relative_rate(1.0 / ((double)d_D)); - set_output_multiple(d_K); - } - - void - @IMPL_NAME@::set_K(int K) - { - gr::thread::scoped_lock guard(d_setlock); - d_K = K; - set_output_multiple(d_K); - } - - void - @IMPL_NAME@::set_D(int D) - { - gr::thread::scoped_lock guard(d_setlock); - d_D = D; - set_relative_rate(1.0 / ((double)d_D)); - } - - void @IMPL_NAME@::set_FSM(const fsm &FSM) - { - gr::thread::scoped_lock guard(d_setlock); - d_FSM = FSM; - } - - void @IMPL_NAME@::set_S0(int S0) - { - gr::thread::scoped_lock guard(d_setlock); - d_S0 = S0; - } - - void @IMPL_NAME@::set_SK(int SK) - { - gr::thread::scoped_lock guard(d_setlock); - d_SK = SK; - } - - void - @IMPL_NAME@::set_TYPE(digital::trellis_metric_type_t type) - { - gr::thread::scoped_lock guard(d_setlock); - d_TYPE = type; - } - - void - @IMPL_NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) - { - gr::thread::scoped_lock guard(d_setlock); - d_TABLE = table; - } - - @IMPL_NAME@::~@IMPL_NAME@() - { - } - - void - @IMPL_NAME@::forecast(int noutput_items, - gr_vector_int &ninput_items_required) - { - int input_required = d_D * noutput_items; - unsigned ninputs = ninput_items_required.size(); - for(unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = input_required; - } - } - - int - @IMPL_NAME@::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - gr::thread::scoped_lock guard(d_setlock); - int nstreams = input_items.size(); - int nblocks = noutput_items / d_K; - - for(int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (const @I_TYPE@*)input_items[m]; - @O_TYPE@ *out = (@O_TYPE@*)output_items[m]; - - for(int n=0;n<nblocks;n++) { - viterbi_algorithm_combined(d_FSM.I(), d_FSM.S(), d_FSM.O(), - d_FSM.NS(), d_FSM.OS(), d_FSM.PS(), - d_FSM.PI(), d_K,d_S0, d_SK, d_D, - d_TABLE, d_TYPE, - &(in[n*d_K*d_D]), &(out[n*d_K])); - } - } - - consume_each(d_D * noutput_items); - return noutput_items; - } - - } /* namespace trellis */ -} /* namespace gr */ - diff --git a/gr-trellis/lib/viterbi_combined_impl.cc b/gr-trellis/lib/viterbi_combined_impl.cc new file mode 100644 index 0000000000..e552f5a9b9 --- /dev/null +++ b/gr-trellis/lib/viterbi_combined_impl.cc @@ -0,0 +1,176 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012,2018 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 "viterbi_combined_impl.h" +#include <gnuradio/io_signature.h> +#include <iostream> + +namespace gr { + namespace trellis { + + template <class IN_T,class OUT_T> + typename viterbi_combined<IN_T,OUT_T>::sptr + viterbi_combined<IN_T,OUT_T>::make(const fsm &FSM, int K, + int S0, int SK, int D, + const std::vector<IN_T> &TABLE, + digital::trellis_metric_type_t TYPE) + { + return gnuradio::get_initial_sptr + (new viterbi_combined_impl<IN_T,OUT_T>(FSM, K, S0, SK, D, TABLE,TYPE)); + } + + template <class IN_T,class OUT_T> + viterbi_combined_impl<IN_T,OUT_T>::viterbi_combined_impl(const fsm &FSM, int K, + int S0, int SK, int D, + const std::vector<IN_T> &TABLE, + digital::trellis_metric_type_t TYPE) + : block("viterbi_combined<IN_T,OUT_T>", + io_signature::make(1, -1, sizeof(IN_T)), + io_signature::make(1, -1, sizeof(OUT_T))), + d_FSM(FSM), d_K(K), d_S0(S0), d_SK(SK), d_D(D), + d_TABLE(TABLE), d_TYPE(TYPE)//, + //d_trace(FSM.S()*K) + { + this->set_relative_rate(1.0 / ((double)d_D)); + this->set_output_multiple(d_K); + } + + template <class IN_T,class OUT_T> + void + viterbi_combined_impl<IN_T,OUT_T>::set_K(int K) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_K = K; + this->set_output_multiple(d_K); + } + + template <class IN_T,class OUT_T> + void + viterbi_combined_impl<IN_T,OUT_T>::set_D(int D) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_D = D; + this->set_relative_rate(1.0 / ((double)d_D)); + } + + template <class IN_T,class OUT_T> + void viterbi_combined_impl<IN_T,OUT_T>::set_FSM(const fsm &FSM) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_FSM = FSM; + } + + template <class IN_T,class OUT_T> + void viterbi_combined_impl<IN_T,OUT_T>::set_S0(int S0) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_S0 = S0; + } + + template <class IN_T,class OUT_T> + void viterbi_combined_impl<IN_T,OUT_T>::set_SK(int SK) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_SK = SK; + } + + template <class IN_T,class OUT_T> + void + viterbi_combined_impl<IN_T,OUT_T>::set_TYPE(digital::trellis_metric_type_t type) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_TYPE = type; + } + + template <class IN_T,class OUT_T> + void + viterbi_combined_impl<IN_T,OUT_T>::set_TABLE(const std::vector<IN_T> &table) + { + gr::thread::scoped_lock guard(this->d_setlock); + d_TABLE = table; + } + + template <class IN_T,class OUT_T> + viterbi_combined_impl<IN_T,OUT_T>::~viterbi_combined_impl() + { + } + + template <class IN_T,class OUT_T> + void + viterbi_combined_impl<IN_T,OUT_T>::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + int input_required = d_D * noutput_items; + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) { + ninput_items_required[i] = input_required; + } + } + + template <class IN_T,class OUT_T> + int + viterbi_combined_impl<IN_T,OUT_T>::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr::thread::scoped_lock guard(this->d_setlock); + int nstreams = input_items.size(); + int nblocks = noutput_items / d_K; + + for(int m=0;m<nstreams;m++) { + const IN_T *in = (const IN_T*)input_items[m]; + OUT_T *out = (OUT_T*)output_items[m]; + + for(int n=0;n<nblocks;n++) { + viterbi_algorithm_combined(d_FSM.I(), d_FSM.S(), d_FSM.O(), + d_FSM.NS(), d_FSM.OS(), d_FSM.PS(), + d_FSM.PI(), d_K,d_S0, d_SK, d_D, + d_TABLE, d_TYPE, + &(in[n*d_K*d_D]), &(out[n*d_K])); + } + } + + this->consume_each(d_D * noutput_items); + return noutput_items; + } + + template class viterbi_combined<std::int16_t, std::uint8_t>; + template class viterbi_combined<std::int16_t, std::int16_t>; + template class viterbi_combined<std::int16_t, std::int32_t>; + template class viterbi_combined<std::int32_t, std::uint8_t>; + template class viterbi_combined<std::int32_t, std::int16_t>; + template class viterbi_combined<std::int32_t, std::int32_t>; + template class viterbi_combined<float, std::uint8_t>; + template class viterbi_combined<float, std::int16_t>; + template class viterbi_combined<float, std::int32_t>; + template class viterbi_combined<gr_complex, std::uint8_t>; + template class viterbi_combined<gr_complex, std::int16_t>; + template class viterbi_combined<gr_complex, std::int32_t>; + + + } /* namespace trellis */ +} /* namespace gr */ diff --git a/gr-trellis/lib/viterbi_combined_XX_impl.h.t b/gr-trellis/lib/viterbi_combined_impl.h index 788e609895..e83114673f 100644 --- a/gr-trellis/lib/viterbi_combined_XX_impl.h.t +++ b/gr-trellis/lib/viterbi_combined_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +#ifndef VITERBI_COMBINED_IMPL_H +#define VITERBI_COMBINED_IMPL_H -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/viterbi_combined.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ + template <class IN_T,class OUT_T> + class viterbi_combined_impl : public viterbi_combined<IN_T,OUT_T> { private: fsm d_FSM; @@ -38,23 +37,23 @@ namespace gr { int d_S0; int d_SK; int d_D; - std::vector<@I_TYPE@> d_TABLE; + std::vector<IN_T> d_TABLE; digital::trellis_metric_type_t d_TYPE; //std::vector<int> d_trace; public: - @IMPL_NAME@(const fsm &FSM, int K, + viterbi_combined_impl(const fsm &FSM, int K, int S0, int SK, int D, - const std::vector<@I_TYPE@> &TABLE, + const std::vector<IN_T> &TABLE, digital::trellis_metric_type_t TYPE); - ~@IMPL_NAME@(); + ~viterbi_combined_impl(); fsm FSM() const { return d_FSM; } int K() const { return d_K; } int S0() const { return d_S0; } int SK() const { return d_SK; } int D() const { return d_D; } - std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + std::vector<IN_T> TABLE() const { return d_TABLE; } digital::trellis_metric_type_t TYPE() const { return d_TYPE; } //std::vector<int> trace() const { return d_trace; } @@ -63,7 +62,7 @@ namespace gr { void set_S0(int S0); void set_SK(int SK); void set_D(int D); - void set_TABLE(const std::vector<@I_TYPE@> &table); + void set_TABLE(const std::vector<IN_T> &table); void set_TYPE(digital::trellis_metric_type_t type); void forecast(int noutput_items, @@ -78,4 +77,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* VITERBI_COMBINED_IMPL_H */ diff --git a/gr-trellis/lib/viterbi_X_impl.cc.t b/gr-trellis/lib/viterbi_impl.cc index d5949f0321..4b5f428d60 100644 --- a/gr-trellis/lib/viterbi_X_impl.cc.t +++ b/gr-trellis/lib/viterbi_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,71 +20,78 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "@NAME@.h" +#include "viterbi_impl.h" #include <gnuradio/io_signature.h> #include <iostream> namespace gr { namespace trellis { - @BASE_NAME@::sptr - @BASE_NAME@::make(const fsm &FSM, int K, + template <class T> + typename viterbi<T>::sptr + viterbi<T>::make(const fsm &FSM, int K, int S0, int SK) { return gnuradio::get_initial_sptr - (new @IMPL_NAME@(FSM, K, S0, SK)); + (new viterbi_impl<T>(FSM, K, S0, SK)); } - @IMPL_NAME@::@IMPL_NAME@(const fsm &FSM, int K, + template <class T> + viterbi_impl<T>::viterbi_impl(const fsm &FSM, int K, int S0, int SK) - : block("@BASE_NAME@", + : block("viterbi", io_signature::make(1, -1, sizeof(float)), - io_signature::make(1, -1, sizeof(@TYPE@))), + io_signature::make(1, -1, sizeof(T))), d_FSM(FSM), d_K(K), d_S0(S0), d_SK(SK)//, //d_trace(FSM.S()*K) { - set_relative_rate(1.0 / ((double)d_FSM.O())); - set_output_multiple(d_K); + this->set_relative_rate(1.0 / ((double)d_FSM.O())); + this->set_output_multiple(d_K); } - void @IMPL_NAME@::set_FSM(const fsm &FSM) + template <class T> + void viterbi_impl<T>::set_FSM(const fsm &FSM) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_FSM = FSM; - set_relative_rate(1.0 / ((double)d_FSM.O())); + this->set_relative_rate(1.0 / ((double)d_FSM.O())); } - void @IMPL_NAME@::set_K(int K) + template <class T> + void viterbi_impl<T>::set_K(int K) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_K = K; - set_output_multiple(d_K); + this->set_output_multiple(d_K); } - void @IMPL_NAME@::set_S0(int S0) + template <class T> + void viterbi_impl<T>::set_S0(int S0) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_S0 = S0; } - void @IMPL_NAME@::set_SK(int SK) + template <class T> + void viterbi_impl<T>::set_SK(int SK) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); d_SK = SK; } - @IMPL_NAME@::~@IMPL_NAME@() + template <class T> + viterbi_impl<T>::~viterbi_impl() { } + template <class T> void - @IMPL_NAME@::forecast(int noutput_items, + viterbi_impl<T>::forecast(int noutput_items, gr_vector_int &ninput_items_required) { int input_required = d_FSM.O() * noutput_items; @@ -94,19 +101,20 @@ namespace gr { } } + template <class T> int - @IMPL_NAME@::general_work(int noutput_items, + viterbi_impl<T>::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr::thread::scoped_lock guard(d_setlock); + gr::thread::scoped_lock guard(this->d_setlock); int nstreams = input_items.size(); int nblocks = noutput_items / d_K; for(int m = 0; m < nstreams; m++) { const float *in = (const float*)input_items[m]; - @TYPE@ *out = (@TYPE@*)output_items[m]; + T *out = (T*)output_items[m]; for(int n = 0; n < nblocks; n++) { viterbi_algorithm(d_FSM.I(), d_FSM.S(), d_FSM.O(), @@ -116,9 +124,12 @@ namespace gr { } } - consume_each(d_FSM.O() * noutput_items); + this->consume_each(d_FSM.O() * noutput_items); return noutput_items; } +template class viterbi<std::uint8_t>; +template class viterbi<std::int16_t>; +template class viterbi<std::int32_t>; } /* namespace trellis */ } /* namespace gr */ diff --git a/gr-trellis/lib/viterbi_X_impl.h.t b/gr-trellis/lib/viterbi_impl.h index 1479ad5a3f..c9f40a0b79 100644 --- a/gr-trellis/lib/viterbi_X_impl.h.t +++ b/gr-trellis/lib/viterbi_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,17 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ +#ifndef VITERBI_IMPL_H +#define VITERBI_IMPL_H -#include <gnuradio/trellis/@BASE_NAME@.h> +#include <gnuradio/trellis/viterbi.h> namespace gr { namespace trellis { - class @IMPL_NAME@ : public @BASE_NAME@ +template<class T> + class viterbi_impl : public viterbi<T> { private: fsm d_FSM; @@ -40,9 +40,9 @@ namespace gr { //std::vector<int> d_trace; public: - @IMPL_NAME@(const fsm &FSM, int K, + viterbi_impl(const fsm &FSM, int K, int S0, int SK); - ~@IMPL_NAME@(); + ~viterbi_impl(); fsm FSM() const { return d_FSM; } int K() const { return d_K; } @@ -66,4 +66,4 @@ namespace gr { } /* namespace trellis */ } /* namespace gr */ -#endif /* @GUARD_NAME@ */ +#endif /* VITERBI_IMPL_H */ diff --git a/gr-trellis/swig/CMakeLists.txt b/gr-trellis/swig/CMakeLists.txt index 14012abad5..1f9b7679df 100644 --- a/gr-trellis/swig/CMakeLists.txt +++ b/gr-trellis/swig/CMakeLists.txt @@ -59,7 +59,6 @@ foreach(swigfile ${GR_SWIG_TRELLIS_IFILES}) ${CMAKE_CURRENT_BINARY_DIR}/../include/gnuradio/trellis ) set(GR_SWIG_DOCS_TARGET_DEPS runtime_swig_swig_doc) - set(GR_SWIG_TARGET_DEPS trellis_generated_includes) set(GR_SWIG_LIBRARIES gnuradio-trellis gnuradio-digital) GR_SWIG_MAKE(${swigfile} ${swigfile}.i) diff --git a/gr-trellis/swig/trellis_swig0.i b/gr-trellis/swig/trellis_swig0.i index 9f309c5ca3..596a043db4 100644 --- a/gr-trellis/swig/trellis_swig0.i +++ b/gr-trellis/swig/trellis_swig0.i @@ -38,80 +38,44 @@ #include "gnuradio/trellis/permutation.h" #include "gnuradio/trellis/siso_combined_f.h" #include "gnuradio/trellis/siso_f.h" -#include "gnuradio/trellis/encoder_bb.h" -#include "gnuradio/trellis/encoder_bs.h" -#include "gnuradio/trellis/encoder_bi.h" -#include "gnuradio/trellis/encoder_ss.h" -#include "gnuradio/trellis/encoder_si.h" -#include "gnuradio/trellis/encoder_ii.h" -#include "gnuradio/trellis/sccc_encoder_bb.h" -#include "gnuradio/trellis/sccc_encoder_bs.h" -#include "gnuradio/trellis/sccc_encoder_bi.h" -#include "gnuradio/trellis/sccc_encoder_ss.h" -#include "gnuradio/trellis/sccc_encoder_si.h" -#include "gnuradio/trellis/sccc_encoder_ii.h" -#include "gnuradio/trellis/pccc_encoder_bb.h" -#include "gnuradio/trellis/pccc_encoder_bs.h" -#include "gnuradio/trellis/pccc_encoder_bi.h" -#include "gnuradio/trellis/pccc_encoder_ss.h" -#include "gnuradio/trellis/pccc_encoder_si.h" -#include "gnuradio/trellis/pccc_encoder_ii.h" -#include "gnuradio/trellis/metrics_s.h" -#include "gnuradio/trellis/metrics_i.h" -#include "gnuradio/trellis/metrics_f.h" -#include "gnuradio/trellis/metrics_c.h" +#include "gnuradio/trellis/encoder.h" +#include "gnuradio/trellis/sccc_encoder.h" +#include "gnuradio/trellis/pccc_encoder.h" +#include "gnuradio/trellis/metrics.h" %} %include "gnuradio/trellis/constellation_metrics_cf.h" %include "gnuradio/trellis/permutation.h" %include "gnuradio/trellis/siso_combined_f.h" %include "gnuradio/trellis/siso_f.h" -%include "gnuradio/trellis/encoder_bb.h" -%include "gnuradio/trellis/encoder_bs.h" -%include "gnuradio/trellis/encoder_bi.h" -%include "gnuradio/trellis/encoder_ss.h" -%include "gnuradio/trellis/encoder_si.h" -%include "gnuradio/trellis/encoder_ii.h" -%include "gnuradio/trellis/sccc_encoder_bb.h" -%include "gnuradio/trellis/sccc_encoder_bs.h" -%include "gnuradio/trellis/sccc_encoder_bi.h" -%include "gnuradio/trellis/sccc_encoder_ss.h" -%include "gnuradio/trellis/sccc_encoder_si.h" -%include "gnuradio/trellis/sccc_encoder_ii.h" -%include "gnuradio/trellis/pccc_encoder_bb.h" -%include "gnuradio/trellis/pccc_encoder_bs.h" -%include "gnuradio/trellis/pccc_encoder_bi.h" -%include "gnuradio/trellis/pccc_encoder_ss.h" -%include "gnuradio/trellis/pccc_encoder_si.h" -%include "gnuradio/trellis/pccc_encoder_ii.h" -%include "gnuradio/trellis/metrics_s.h" -%include "gnuradio/trellis/metrics_i.h" -%include "gnuradio/trellis/metrics_f.h" -%include "gnuradio/trellis/metrics_c.h" +%include "gnuradio/trellis/encoder.h" +%include "gnuradio/trellis/sccc_encoder.h" +%include "gnuradio/trellis/pccc_encoder.h" +%include "gnuradio/trellis/metrics.h" GR_SWIG_BLOCK_MAGIC2(trellis, constellation_metrics_cf); GR_SWIG_BLOCK_MAGIC2(trellis, permutation); GR_SWIG_BLOCK_MAGIC2(trellis, siso_combined_f); GR_SWIG_BLOCK_MAGIC2(trellis, siso_f); -GR_SWIG_BLOCK_MAGIC2(trellis, encoder_bb); -GR_SWIG_BLOCK_MAGIC2(trellis, encoder_bs); -GR_SWIG_BLOCK_MAGIC2(trellis, encoder_bi); -GR_SWIG_BLOCK_MAGIC2(trellis, encoder_ss); -GR_SWIG_BLOCK_MAGIC2(trellis, encoder_si); -GR_SWIG_BLOCK_MAGIC2(trellis, encoder_ii); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_bb); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_bs); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_bi); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_ss); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_si); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_encoder_ii); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_bb); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_bs); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_bi); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_ss); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_si); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_encoder_ii); -GR_SWIG_BLOCK_MAGIC2(trellis, metrics_s); -GR_SWIG_BLOCK_MAGIC2(trellis, metrics_i); -GR_SWIG_BLOCK_MAGIC2(trellis, metrics_f); -GR_SWIG_BLOCK_MAGIC2(trellis, metrics_c); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, encoder_bb, encoder<std::uint8_t,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, encoder_bs, encoder<std::uint8_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, encoder_bi, encoder<std::uint8_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, encoder_ss, encoder<std::int16_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, encoder_si, encoder<std::int16_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, encoder_ii, encoder<std::int32_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_encoder_bb, sccc_encoder<std::uint8_t,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_encoder_bs, sccc_encoder<std::uint8_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_encoder_bi, sccc_encoder<std::uint8_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_encoder_ss, sccc_encoder<std::int16_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_encoder_si, sccc_encoder<std::int16_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_encoder_ii, sccc_encoder<std::int32_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_encoder_bb, pccc_encoder<std::uint8_t,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_encoder_bs, pccc_encoder<std::uint8_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_encoder_bi, pccc_encoder<std::uint8_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_encoder_ss, pccc_encoder<std::int16_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_encoder_si, pccc_encoder<std::int16_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_encoder_ii, pccc_encoder<std::int32_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, metrics_s, metrics<std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, metrics_i, metrics<std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, metrics_f, metrics<float>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, metrics_c, metrics<gr_complex>); diff --git a/gr-trellis/swig/trellis_swig1.i b/gr-trellis/swig/trellis_swig1.i index 6481aee245..7a8728efd2 100644 --- a/gr-trellis/swig/trellis_swig1.i +++ b/gr-trellis/swig/trellis_swig1.i @@ -33,105 +33,52 @@ %include "gnuradio/trellis/interleaver.h" %{ -#include "gnuradio/trellis/pccc_decoder_b.h" -#include "gnuradio/trellis/pccc_decoder_s.h" -#include "gnuradio/trellis/pccc_decoder_i.h" -#include "gnuradio/trellis/pccc_decoder_combined_fb.h" -#include "gnuradio/trellis/pccc_decoder_combined_fs.h" -#include "gnuradio/trellis/pccc_decoder_combined_fi.h" -#include "gnuradio/trellis/pccc_decoder_combined_cb.h" -#include "gnuradio/trellis/pccc_decoder_combined_cs.h" -#include "gnuradio/trellis/pccc_decoder_combined_ci.h" -#include "gnuradio/trellis/viterbi_b.h" -#include "gnuradio/trellis/viterbi_s.h" -#include "gnuradio/trellis/viterbi_i.h" -#include "gnuradio/trellis/viterbi_combined_sb.h" -#include "gnuradio/trellis/viterbi_combined_ss.h" -#include "gnuradio/trellis/viterbi_combined_si.h" -#include "gnuradio/trellis/viterbi_combined_ib.h" -#include "gnuradio/trellis/viterbi_combined_is.h" -#include "gnuradio/trellis/viterbi_combined_ii.h" -#include "gnuradio/trellis/viterbi_combined_fb.h" -#include "gnuradio/trellis/viterbi_combined_fs.h" -#include "gnuradio/trellis/viterbi_combined_fi.h" -#include "gnuradio/trellis/viterbi_combined_cb.h" -#include "gnuradio/trellis/viterbi_combined_cs.h" -#include "gnuradio/trellis/viterbi_combined_ci.h" -#include "gnuradio/trellis/sccc_decoder_b.h" -#include "gnuradio/trellis/sccc_decoder_s.h" -#include "gnuradio/trellis/sccc_decoder_i.h" -#include "gnuradio/trellis/sccc_decoder_combined_fb.h" -#include "gnuradio/trellis/sccc_decoder_combined_fs.h" -#include "gnuradio/trellis/sccc_decoder_combined_fi.h" -#include "gnuradio/trellis/sccc_decoder_combined_cb.h" -#include "gnuradio/trellis/sccc_decoder_combined_cs.h" -#include "gnuradio/trellis/sccc_decoder_combined_ci.h" +#include "gnuradio/trellis/pccc_decoder_blk.h" +#include "gnuradio/trellis/pccc_decoder_combined_blk.h" +#include "gnuradio/trellis/viterbi.h" +#include "gnuradio/trellis/viterbi_combined.h" +#include "gnuradio/trellis/sccc_decoder_blk.h" +#include "gnuradio/trellis/sccc_decoder_combined_blk.h" %} -%include "gnuradio/trellis/pccc_decoder_b.h" -%include "gnuradio/trellis/pccc_decoder_s.h" -%include "gnuradio/trellis/pccc_decoder_i.h" -%include "gnuradio/trellis/pccc_decoder_combined_fb.h" -%include "gnuradio/trellis/pccc_decoder_combined_fs.h" -%include "gnuradio/trellis/pccc_decoder_combined_fi.h" -%include "gnuradio/trellis/pccc_decoder_combined_cb.h" -%include "gnuradio/trellis/pccc_decoder_combined_cs.h" -%include "gnuradio/trellis/pccc_decoder_combined_ci.h" -%include "gnuradio/trellis/viterbi_b.h" -%include "gnuradio/trellis/viterbi_s.h" -%include "gnuradio/trellis/viterbi_i.h" -%include "gnuradio/trellis/viterbi_combined_sb.h" -%include "gnuradio/trellis/viterbi_combined_ss.h" -%include "gnuradio/trellis/viterbi_combined_si.h" -%include "gnuradio/trellis/viterbi_combined_ib.h" -%include "gnuradio/trellis/viterbi_combined_is.h" -%include "gnuradio/trellis/viterbi_combined_ii.h" -%include "gnuradio/trellis/viterbi_combined_fb.h" -%include "gnuradio/trellis/viterbi_combined_fs.h" -%include "gnuradio/trellis/viterbi_combined_fi.h" -%include "gnuradio/trellis/viterbi_combined_cb.h" -%include "gnuradio/trellis/viterbi_combined_cs.h" -%include "gnuradio/trellis/viterbi_combined_ci.h" -%include "gnuradio/trellis/sccc_decoder_b.h" -%include "gnuradio/trellis/sccc_decoder_s.h" -%include "gnuradio/trellis/sccc_decoder_i.h" -%include "gnuradio/trellis/sccc_decoder_combined_fb.h" -%include "gnuradio/trellis/sccc_decoder_combined_fs.h" -%include "gnuradio/trellis/sccc_decoder_combined_fi.h" -%include "gnuradio/trellis/sccc_decoder_combined_cb.h" -%include "gnuradio/trellis/sccc_decoder_combined_cs.h" -%include "gnuradio/trellis/sccc_decoder_combined_ci.h" +%include "gnuradio/trellis/pccc_decoder_blk.h" +%include "gnuradio/trellis/pccc_decoder_combined_blk.h" +%include "gnuradio/trellis/viterbi.h" +%include "gnuradio/trellis/viterbi_combined.h" +%include "gnuradio/trellis/sccc_decoder_blk.h" +%include "gnuradio/trellis/sccc_decoder_combined_blk.h" -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_b); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_s); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_i); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_fb); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_fs); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_fi); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_cb); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_cs); -GR_SWIG_BLOCK_MAGIC2(trellis, pccc_decoder_combined_ci); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_b); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_s); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_i); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_sb); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ss); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_si); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ib); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_is); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ii); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_fb); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_fs); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_fi); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_cb); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_cs); -GR_SWIG_BLOCK_MAGIC2(trellis, viterbi_combined_ci); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_b); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_s); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_i); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_fb); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_fs); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_fi); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_cb); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_cs); -GR_SWIG_BLOCK_MAGIC2(trellis, sccc_decoder_combined_ci); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_b, pccc_decoder_blk<std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_s, pccc_decoder_blk<std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_i, pccc_decoder_blk<std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_b, viterbi<std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_s, viterbi<std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_i, viterbi<std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_sb, viterbi_combined<std::int16_t,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_ss, viterbi_combined<std::int16_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_si, viterbi_combined<std::int16_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_ib, viterbi_combined<std::int32_t,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_is, viterbi_combined<std::int32_t,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_ii, viterbi_combined<std::int32_t,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_fb, viterbi_combined<float,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_fs, viterbi_combined<float,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_fi, viterbi_combined<float,std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_cb, viterbi_combined<gr_complex,std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_cs, viterbi_combined<gr_complex,std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, viterbi_combined_ci, viterbi_combined<gr_complex,std::int32_t>); + +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_b, sccc_decoder_blk<std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_s, sccc_decoder_blk<std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_i, sccc_decoder_blk<std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_combined_fb, sccc_decoder_combined_blk<float, std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_combined_fs, sccc_decoder_combined_blk<float, std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_combined_fi, sccc_decoder_combined_blk<float, std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_combined_cb, sccc_decoder_combined_blk<gr_complex, std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_combined_cs, sccc_decoder_combined_blk<gr_complex, std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, sccc_decoder_combined_ci, sccc_decoder_combined_blk<gr_complex, std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_combined_fb, pccc_decoder_combined_blk<float, std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_combined_fs, pccc_decoder_combined_blk<float, std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_combined_fi, pccc_decoder_combined_blk<float, std::int32_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_combined_cb, pccc_decoder_combined_blk<gr_complex, std::uint8_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_combined_cs, pccc_decoder_combined_blk<gr_complex, std::int16_t>); +GR_SWIG_BLOCK_MAGIC2_TMPL(trellis, pccc_decoder_combined_ci, pccc_decoder_combined_blk<gr_complex, std::int32_t>); |