From a20c127a9469aeac9ec60bf432c4128c49349f34 Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Wed, 3 Nov 2010 20:53:07 -0700 Subject: Generation of python docstrings from doxygen xml. swig_doc.i is a swig interface file containing all the docstrings. It is generated using swig_doc.py and included by gnuradio.i. Minor changes to the swig make files have been made so that the generation of swig_doc.i occurs. --- gr-trellis/src/lib/Makefile.swig.gen | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.swig.gen b/gr-trellis/src/lib/Makefile.swig.gen index 1a9656b8f..edc7d6f72 100644 --- a/gr-trellis/src/lib/Makefile.swig.gen +++ b/gr-trellis/src/lib/Makefile.swig.gen @@ -107,11 +107,12 @@ trellis_python_PYTHON = \ ## Entry rule for running SWIG -trellis.h trellis.py trellis.cc: trellis.i +trellis.h trellis.py trellis.cc: trellis.i $(top_srcdir)/gnuradio-core/src/lib/swig/swig_doc.i ## This rule will get called only when MAKE decides that one of the ## targets needs to be created or re-created, because: ## -## * The .i file is newer than any or all of the generated files; +## * The .i file or the swig_doc.i are newer than any or all of the +## generated files; ## ## * Any or all of the .cc, .h, or .py files does not exist and is ## needed (in the case this file is not needed, the rule for it is -- cgit From 19f4afaa4e3871e4a709e2774393bba6b6f6759a Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 23 Jan 2011 21:43:42 -0700 Subject: Fixed minor bug in fsm.cc for fsms with 1 state. --- gr-trellis/src/lib/fsm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index 5950b56b9..889a3918b 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -417,7 +417,7 @@ void fsm::generate_TM() done = find_es(s); attempts ++; } - if (done == false) { + if (done == false and d_S > 1) { //throw std::runtime_error ("fsm::generate_TM(): FSM appears to be disconnected\n"); printf("fsm::generate_TM(): FSM appears to be disconnected\n"); printf("state %d cannot be reached from all other states\n",s); -- cgit From 44ad2b33d0b86f0ffe95d025fefa2c774cf80c85 Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 30 Jan 2011 13:36:24 -0700 Subject: Fixed Makefiles to generate swig_doc.i --- gr-trellis/src/lib/Makefile.swig.gen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.swig.gen b/gr-trellis/src/lib/Makefile.swig.gen index 784c146cf..6f57642f2 100644 --- a/gr-trellis/src/lib/Makefile.swig.gen +++ b/gr-trellis/src/lib/Makefile.swig.gen @@ -105,7 +105,7 @@ _trellis_la_CXXFLAGS = \ $(trellis_la_swig_cxxflags) python/trellis.cc: trellis.py -trellis.py: trellis.i +trellis.py: trellis.i $(top_srcdir)/gnuradio-core/src/lib/swig/swig_doc.i # Include the python dependencies for this file -include python/trellis.d -- cgit From 4b42ab554e45e4326466976028ed25123746205f Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 6 Feb 2011 14:02:44 -0700 Subject: Added trellis_constellation_metrics_cf. It is equivalent to trellis_metrics_c but it uses the constellation object's calc_metric method. This method is also added here. trellis_metric_type.h is moved to gr_metric_type since constellation object is now dependent on it. --- gr-trellis/src/lib/Makefile.am | 4 +- gr-trellis/src/lib/trellis.i | 12 ++- gr-trellis/src/lib/trellis_calc_metric.h | 2 +- .../src/lib/trellis_constellation_metrics_cf.cc | 85 ++++++++++++++++++++++ .../src/lib/trellis_constellation_metrics_cf.h | 60 +++++++++++++++ .../src/lib/trellis_constellation_metrics_cf.i | 33 +++++++++ gr-trellis/src/lib/trellis_metric_type.h | 31 -------- 7 files changed, 193 insertions(+), 34 deletions(-) create mode 100644 gr-trellis/src/lib/trellis_constellation_metrics_cf.cc create mode 100644 gr-trellis/src/lib/trellis_constellation_metrics_cf.h create mode 100644 gr-trellis/src/lib/trellis_constellation_metrics_cf.i delete mode 100644 gr-trellis/src/lib/trellis_metric_type.h (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index 08e75291a..d6926f2a0 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -66,12 +66,12 @@ grinclude_HEADERS = \ quicksort_index.h \ base.h \ interleaver.h \ - trellis_metric_type.h \ trellis_calc_metric.h \ trellis_permutation.h \ trellis_siso_type.h \ trellis_siso_f.h \ trellis_siso_combined_f.h \ + trellis_constellation_metrics_cf.h \ $(GENERATED_H) lib_LTLIBRARIES = libgnuradio-trellis.la @@ -85,6 +85,7 @@ libgnuradio_trellis_la_SOURCES = \ trellis_permutation.cc \ trellis_siso_f.cc \ trellis_siso_combined_f.cc \ + trellis_constellation_metrics_cf.cc \ $(GENERATED_CC) libgnuradio_trellis_la_LIBADD = \ @@ -119,6 +120,7 @@ trellis_swiginclude_headers = \ trellis_permutation.i \ trellis_siso_f.i \ trellis_siso_combined_f.i \ + trellis_constellation_metrics_cf.i \ trellis_generated.i # Do creation and inclusion of other Makefiles last diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i index d035cea54..fe74c8d9f 100644 --- a/gr-trellis/src/lib/trellis.i +++ b/gr-trellis/src/lib/trellis.i @@ -28,8 +28,11 @@ #include "trellis_permutation.h" #include "trellis_siso_f.h" #include "trellis_siso_combined_f.h" +#include "trellis_constellation_metrics_cf.h" +#include "gr_constellation.h" %} + // ---------------------------------------------------------------- %include "fsm.i" @@ -38,12 +41,19 @@ %include "trellis_siso_f.i" %include "trellis_siso_combined_f.i" -%include "trellis_metric_type.h" %include "trellis_siso_type.h" +%include "trellis_constellation_metrics_cf.i" %include "trellis_generated.i" +%import "gr_metric_type.h" +%import "gr_constellation.i" + +%pythoncode %{ + from gnuradio.gr import TRELLIS_EUCLIDEAN, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT + %} + #if SWIGGUILE %scheme %{ (load-extension-global "libguile-gnuradio-trellis" "scm_init_gnuradio_trellis_module") diff --git a/gr-trellis/src/lib/trellis_calc_metric.h b/gr-trellis/src/lib/trellis_calc_metric.h index fabf4e145..b9eacb086 100644 --- a/gr-trellis/src/lib/trellis_calc_metric.h +++ b/gr-trellis/src/lib/trellis_calc_metric.h @@ -25,7 +25,7 @@ #include #include -#include +#include template diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc new file mode 100644 index 000000000..73e848259 --- /dev/null +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010 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: this file is machine generated. Edits will be over written + +#ifndef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + + + +trellis_constellation_metrics_cf_sptr +trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE) +{ + return gnuradio::get_initial_sptr (new trellis_constellation_metrics_cf (constellation, TYPE)); +} + + + +trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE) + : gr_block ("constellation_metrics_cf", + gr_make_io_signature (1, -1, sizeof (gr_complex)), + gr_make_io_signature (1, -1, sizeof (float))), + d_constellation (constellation), + d_TYPE (TYPE), + d_O (constellation->arity()) +{ + set_relative_rate (d_O); + set_output_multiple (d_O); +} + +void +trellis_constellation_metrics_cf::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + assert (noutput_items % d_O == 0); + int input_required = noutput_items / d_O; + ninput_items_required[0] = input_required; +} + + + +int +trellis_constellation_metrics_cf::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + + assert (noutput_items % d_O == 0); + + const gr_complex *in = (gr_complex *) input_items[0]; + float *out = (float *) output_items[0]; + + for (int i = 0; i < noutput_items / d_O ; i++){ + d_constellation->calc_metric(in[i], &(out[i*d_O]), d_TYPE); + } + + consume_each (noutput_items / d_O); + return noutput_items; +} diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h new file mode 100644 index 000000000..a50e92841 --- /dev/null +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004, 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H +#define INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H + +#include +#include +#include + +class trellis_constellation_metrics_cf; +typedef boost::shared_ptr trellis_constellation_metrics_cf_sptr; + +trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + +/*! + * \brief Evaluate metrics for use by the Viterbi algorithm. + * \ingroup coding_blk + */ +class trellis_constellation_metrics_cf : public gr_block +{ + public: + void forecast (int noutput_items, + gr_vector_int &ninput_items_required); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + protected: + trellis_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + + private: + gr_constellation_sptr d_constellation; + trellis_metric_type_t d_TYPE; + unsigned int d_O; + friend trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + +}; + + +#endif diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i new file mode 100644 index 000000000..b4a5bbbb7 --- /dev/null +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i @@ -0,0 +1,33 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 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: this file is machine generated. Edits will be over written + +GR_SWIG_BLOCK_MAGIC(trellis,constellation_metrics_cf); + +trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + +class trellis_constellation_metrics_cf : public gr_block +{ +private: + trellis_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); +}; diff --git a/gr-trellis/src/lib/trellis_metric_type.h b/gr-trellis/src/lib/trellis_metric_type.h deleted file mode 100644 index a1040f108..000000000 --- a/gr-trellis/src/lib/trellis_metric_type.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_TRELLIS_METRIC_TYPE_H -#define INCLUDED_TRELLIS_METRIC_TYPE_H - -typedef enum { - TRELLIS_EUCLIDEAN = 200, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT -} trellis_metric_type_t; - -#endif - -- cgit From d10b330e60e62ff031785d96ec98c455c5c562eb Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 6 Feb 2011 16:39:26 -0700 Subject: Added comments to fsm.h --- gr-trellis/src/lib/fsm.h | 100 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h index 0a90b2cd3..e5f717af0 100644 --- a/gr-trellis/src/lib/fsm.h +++ b/gr-trellis/src/lib/fsm.h @@ -27,31 +27,114 @@ #include /*! - * \brief FSM class + * \brief Finite State Machine Specification class. + * + * An instance of this class represents a finite state machine specification (FSMS) + * rather than the FSM itself. It particular the state of the FSM + * is not stored within an instance of this class. */ class fsm { private: + // Input alphabet cardinality. int d_I; + // Number of states. int d_S; + // Output alphabet cardinality. int d_O; + // NS means Next State. + // next_state = d_NS[current_state * d_I + input_symbol] std::vector d_NS; + // OS means Output Symbol. + // output_symbol = d_OS[current_state * d_I + input_symbol] std::vector d_OS; + // PS means Previous State. std::vector< std::vector > d_PS; + // PI means Previous Input Symbol. + // d_PS[current_state][k] and d_PI[current_state][k], is a pair of the form + // (previous_state, previous_input_symbol) that could have produced the + // current state. std::vector< std::vector > d_PI; - std::vector d_TMi; + // TM means Termination matrix. + // d_TMl[s*d_S+es] is the shortest number of steps to get from state s to + // state es. std::vector d_TMl; + // d_TMi[s*d_S+es] is the input symbol required to set off on the shortest + // path from state s to es. + std::vector d_TMi; void generate_PS_PI (); void generate_TM (); bool find_es(int es); public: + /*! + * \brief Constructor to create an uninitialized FSMS. + */ fsm(); + /*! + * \brief Constructor to copy an FSMS. + */ fsm(const fsm &FSM); + /*! + * \brief Constructor to to create an FSMS. + * + * \param I The number of possible input symbols. + * \param S The number of possible FSM states. + * \param O The number of possible output symbols. + * \param NS A mapping from (current state, input symbol) to next state. + * next_state = NS[current_state * I + input_symbol] + * \param OS A mapping from (current state, input symbol) to output symbol. + * output_symbol = OS[current_state * I + input_symbol] + * + */ fsm(int I, int S, int O, const std::vector &NS, const std::vector &OS); + /*! + * \brief Constructor to create an FSMS from file contents. + * + * \param name filename + * + */ fsm(const char *name); + /*! + * \brief Creates an FSMS from the generator matrix of a (n, k) binary convolutional code. + * + * \param k ??? + * \param n ??? + * \param G ??? + * + */ fsm(int k, int n, const std::vector &G); + /*! + * \brief Creates an FSMS describing ISI. + * + * \param mod_size modulation size + * \param ch_lenth channel length + * + */ fsm(int mod_size, int ch_length); + /*! + * \brief Creates an FSMS describing the trellis for a CPM. + * + * \param P ???? h=K/P (relatively prime) + * \param M alphabet size + * \param L pulse duration + * + * This FSM is based on the paper by B. Rimoldi + * "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 + * See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf + */ fsm(int P, int M, int L); + /*! + * \brief Creates an FSMS describing the joint trellis of two FSMs. + * + * \param fsm1 first FSMS + * \param fsm2 second FSMS + */ fsm(const fsm &FSM1, const fsm &FSM2); + /*! + * \brief Creates an FSMS representing n stages through the originial FSM (AKA radix-n FSM). + * + * \param original FSMS + * \param n Number of stages. + */ fsm(const fsm &FSM, int n); int I () const { return d_I; } int S () const { return d_S; } @@ -62,7 +145,20 @@ public: const std::vector< std::vector > & PI () const { return d_PI; } const std::vector & TMi () const { return d_TMi; } const std::vector & TMl () const { return d_TMl; } + /*! + * \brief Creates an svg image of the trellis representation. + * + * \param filename filename + * \param number_stages ???? + * + */ void write_trellis_svg(std::string filename ,int number_stages); + /*! + * \brief Write the FSMS to a file. + * + * \param filename filename + * + */ void write_fsm_txt(std::string filename); }; -- cgit From 765c9f6e947d6dd765d1f33f3d4668f0c69486ee Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 6 Feb 2011 16:42:36 -0700 Subject: Added tests to qa_trellis.py. --- gr-trellis/src/python/qa_trellis.py | 119 +++++++++++++++++++++++++++--------- 1 file changed, 91 insertions(+), 28 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/python/qa_trellis.py b/gr-trellis/src/python/qa_trellis.py index cfeefea06..ba415e6c9 100755 --- a/gr-trellis/src/python/qa_trellis.py +++ b/gr-trellis/src/python/qa_trellis.py @@ -20,46 +20,45 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gr_unittest +import math + + +from gnuradio import gr, gr_unittest, blks2 +# It's pretty ugly that we can't import trellis from gnuradio in this test +# but because it runs on the non-installed python code it's all a mess. import trellis -class test_trellis (gr_unittest.TestCase): +fsm_args = {"awgn1o2_4": (2, 4, 4, + (0, 2, 0, 2, 1, 3, 1, 3), + (0, 3, 3, 0, 1, 2, 2, 1), + ), + "rep2": (2, 1, 4, (0, 0), (0, 3)), + "nothing": (2, 1, 2, (0, 0), (0, 1)), + } - def setUp (self): - self.tb = gr.top_block () +constells = {2: blks2.bpsk_constellation(), + 4: blks2.qpsk_constellation(), + } - def tearDown (self): - self.tb = None +class test_trellis (gr_unittest.TestCase): def test_001_fsm (self): - I = 2 - S = 4 - O = 4 - NS = (0, 2, 0, 2, 1, 3, 1, 3) - OS = (0, 3, 3, 0, 1, 2, 2, 1) - f = trellis.fsm(I,S,O,NS,OS) - self.assertEqual((I,S,O,NS,OS),(f.I(),f.S(),f.O(),f.NS(),f.OS())) + f = trellis.fsm(*fsm_args["awgn1o2_4"]) + self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS())) def test_002_fsm (self): - I = 2 - S = 4 - O = 4 - NS = (0, 2, 0, 2, 1, 3, 1, 3) - OS = (0, 3, 3, 0, 1, 2, 2, 1) - f = trellis.fsm(I,S,O,NS,OS) + f = trellis.fsm(*fsm_args["awgn1o2_4"]) g = trellis.fsm(f) self.assertEqual((g.I(),g.S(),g.O(),g.NS(),g.OS()),(f.I(),f.S(),f.O(),f.NS(),f.OS())) def test_003_fsm (self): - I = 2 - S = 4 - O = 4 - NS = (0, 2, 0, 2, 1, 3, 1, 3) - OS = (0, 3, 3, 0, 1, 2, 2, 1) - #f = trellis.fsm("awgn1o2_4.fsm") - #self.assertEqual((I,S,O,NS,OS),(f.I(),f.S(),f.O(),f.NS(),f.OS())) - # temporary fix so that make distcheck does not fail on this - self.assertEqual(0,0) + f = trellis.fsm("awgn1o2_4.fsm") + self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS())) + + def test_004_fsm(self): + """ Test to make sure fsm works with a single state fsm.""" + # Just checking that it initializes properly. + f = trellis.fsm(*fsm_args["rep2"]) def test_001_interleaver (self): K = 5 @@ -68,5 +67,69 @@ class test_trellis (gr_unittest.TestCase): i = trellis.interleaver(K,IN) self.assertEqual((K,IN,DIN),(i.K(),i.INTER(),i.DEINTER())) + def test_001_viterbi(self): + """ + Runs some coding/decoding tests with a few different FSM + specs. + """ + for name, args in fsm_args.items(): + constellation = constells[args[2]] + fsms = trellis.fsm(*args) + noise = 0.1 + tb = trellis_tb(constellation, fsms, noise) + tb.run() + # Make sure all packets succesfully transmitted. + self.assertEqual(tb.dst.ntotal(), tb.dst.nright()) + + +class trellis_tb(gr.top_block): + """ + A simple top block for use testing gr-trellis. + """ + def __init__(self, constellation, f, N0=0.25, seed=-666L): + """ + constellation - a constellation object used for modulation. + f - a finite state machine specification used for coding. + N0 - noise level + seed - random seed + """ + super(trellis_tb, self).__init__() + # packet size in bits (make it multiple of 16 so it can be packed in a short) + packet_size = 1024*16 + # bits per FSM input symbol + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + # packet size in trellis steps + K = packet_size/bitspersymbol + + # TX + src = gr.lfsr_32k_source_s() + # packet size in shorts + src_head = gr.head (gr.sizeof_short, packet_size/16) + # unpack shorts to symbols compatible with the FSM input cardinality + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol, gr.GR_MSB_FIRST) + # initial FSM state = 0 + enc = trellis.encoder_ss(f, 0) + mod = gr.chunks_to_symbols_sc(constellation.points(), 1) + + # CHANNEL + add = gr.add_cc() + noise = gr.noise_source_c(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + # data preprocessing to generate metrics for Viterbi + metrics = trellis.constellation_metrics_cf(constellation.base(), trellis.TRELLIS_EUCLIDEAN) + # Put -1 if the Initial/Final states are not set. + va = trellis.viterbi_s(f, K, 0, -1) + # pack FSM input symbols to shorts + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol, gr.GR_MSB_FIRST) + # check the output + self.dst = gr.check_lfsr_32k_s() + + self.connect (src, src_head, s2fsmi, enc, mod) + self.connect (mod, (add, 0)) + self.connect (noise, (add, 1)) + self.connect (add, metrics, va, fsmi2s, self.dst) + + if __name__ == '__main__': gr_unittest.run(test_trellis, "test_trellis.xml") -- cgit From 38fe2e1ba02029998f8feb46fccd0608eb181def Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 20 Feb 2011 09:13:55 -0700 Subject: Constellation objects accept n-dimensional points. (i.e. n complex numbers correspond to one symbol value.) --- .../src/lib/trellis_constellation_metrics_cf.cc | 27 ++++++++++++++-------- .../src/lib/trellis_constellation_metrics_cf.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc index 73e848259..2d6f0ebf2 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc @@ -48,18 +48,21 @@ trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (gr_constella gr_make_io_signature (1, -1, sizeof (float))), d_constellation (constellation), d_TYPE (TYPE), - d_O (constellation->arity()) + d_O (constellation->arity()), + d_D (constellation->dimensionality()) { - set_relative_rate (d_O); - set_output_multiple (d_O); + set_relative_rate (1.0 * d_O / ((double) d_D)); + set_output_multiple ((int)d_O); } void trellis_constellation_metrics_cf::forecast (int noutput_items, gr_vector_int &ninput_items_required) { assert (noutput_items % d_O == 0); - int input_required = noutput_items / d_O; - ninput_items_required[0] = input_required; + unsigned int input_required = d_D * noutput_items / d_O; + unsigned int ninputs = ninput_items_required.size(); + for (unsigned int i = 0; i < ninputs; i++) + ninput_items_required[i] = input_required; } @@ -72,14 +75,18 @@ trellis_constellation_metrics_cf::general_work (int noutput_items, { assert (noutput_items % d_O == 0); + assert (input_items.size() == output_items.size()); + unsigned int nstreams = input_items.size(); - const gr_complex *in = (gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; +for (unsigned int m=0;mcalc_metric(in[i], &(out[i*d_O]), d_TYPE); + for (unsigned int i = 0; i < noutput_items / d_O ; i++){ + d_constellation->calc_metric(&(in[i*d_D]), &(out[i*d_O]), d_TYPE); } +} - consume_each (noutput_items / d_O); + consume_each (d_D * noutput_items / d_O); return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h index a50e92841..eb24ad352 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -52,6 +52,7 @@ class trellis_constellation_metrics_cf : public gr_block gr_constellation_sptr d_constellation; trellis_metric_type_t d_TYPE; unsigned int d_O; + unsigned int d_D; friend trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); }; -- cgit From 315f45c234e2fa84fc83641c8404cc5fcdb8412e Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 27 Feb 2011 13:40:48 -0700 Subject: Removing docstring generation from this branch. --- gr-trellis/src/lib/Makefile.swig.gen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.swig.gen b/gr-trellis/src/lib/Makefile.swig.gen index 6f57642f2..2d014b946 100644 --- a/gr-trellis/src/lib/Makefile.swig.gen +++ b/gr-trellis/src/lib/Makefile.swig.gen @@ -105,7 +105,7 @@ _trellis_la_CXXFLAGS = \ $(trellis_la_swig_cxxflags) python/trellis.cc: trellis.py -trellis.py: trellis.i $(top_srcdir)/gnuradio-core/src/lib/swig/swig_doc.i +trellis.py: trellis.i # Include the python dependencies for this file -include python/trellis.d -- cgit From 1aa94c0ddbe9f610ed3a431a0980084d85e7311e Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Sun, 27 Feb 2011 17:04:18 -0700 Subject: Updated copyright notice dates. --- gr-trellis/src/lib/fsm.h | 2 +- gr-trellis/src/lib/trellis_constellation_metrics_cf.cc | 2 +- gr-trellis/src/lib/trellis_constellation_metrics_cf.h | 2 +- gr-trellis/src/lib/trellis_constellation_metrics_cf.i | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h index e5f717af0..8bae91754 100644 --- a/gr-trellis/src/lib/fsm.h +++ b/gr-trellis/src/lib/fsm.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc index 2d6f0ebf2..fb529aaa7 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h index eb24ad352..df35f16d2 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004, 2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i index b4a5bbbb7..f863453f2 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * -- cgit From f6c10234d42f5b6913002ca3cd5723b9c5270f7c Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Tue, 10 May 2011 23:14:30 -0700 Subject: Modifying gr_trellis for gr_constellation -> digital_constellation change. --- gr-trellis/src/lib/Makefile.am | 10 ++++++++-- gr-trellis/src/lib/trellis.i | 4 ++-- gr-trellis/src/lib/trellis_constellation_metrics_cf.cc | 4 ++-- gr-trellis/src/lib/trellis_constellation_metrics_cf.h | 10 +++++----- gr-trellis/src/lib/trellis_constellation_metrics_cf.i | 4 ++-- 5 files changed, 19 insertions(+), 13 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index d6926f2a0..d48486448 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -29,8 +29,9 @@ EXTRA_DIST += \ trellis.test -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) - +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) \ + -I$(abs_top_builddir)/gr-digital/lib + # ---------------------------------------------------------------- # these scripts generate trellis codes from template files @@ -142,6 +143,11 @@ include $(top_srcdir)/Makefile.par.gen BUILT_SOURCES += $(python_built_sources) +# Location of non-standard SWIG interface files +trellis_swig_args = \ + -I$(abs_top_builddir)/gr-digital/lib \ + -I$(abs_top_builddir)/gr-digital/swig + if GUILE TESTS += run_guile_tests endif diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i index fe74c8d9f..7e379a918 100644 --- a/gr-trellis/src/lib/trellis.i +++ b/gr-trellis/src/lib/trellis.i @@ -29,7 +29,7 @@ #include "trellis_siso_f.h" #include "trellis_siso_combined_f.h" #include "trellis_constellation_metrics_cf.h" -#include "gr_constellation.h" +#include "digital_constellation.h" %} @@ -48,7 +48,7 @@ %include "trellis_generated.i" %import "gr_metric_type.h" -%import "gr_constellation.i" +%import "digital_constellation.i" %pythoncode %{ from gnuradio.gr import TRELLIS_EUCLIDEAN, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc index fb529aaa7..1d03886f1 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc @@ -35,14 +35,14 @@ trellis_constellation_metrics_cf_sptr -trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE) +trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE) { return gnuradio::get_initial_sptr (new trellis_constellation_metrics_cf (constellation, TYPE)); } -trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE) +trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE) : gr_block ("constellation_metrics_cf", gr_make_io_signature (1, -1, sizeof (gr_complex)), gr_make_io_signature (1, -1, sizeof (float))), diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h index df35f16d2..1a0eb72ee 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -24,13 +24,13 @@ #define INCLUDED_TRELLIS_CONSTELLATION_METRICS_CF_H #include -#include +#include #include class trellis_constellation_metrics_cf; typedef boost::shared_ptr trellis_constellation_metrics_cf_sptr; -trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); +trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -46,14 +46,14 @@ class trellis_constellation_metrics_cf : public gr_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); protected: - trellis_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); private: - gr_constellation_sptr d_constellation; + digital_constellation_sptr d_constellation; trellis_metric_type_t d_TYPE; unsigned int d_O; unsigned int d_D; - friend trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + friend trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); }; diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i index f863453f2..c17522b11 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i @@ -24,10 +24,10 @@ GR_SWIG_BLOCK_MAGIC(trellis,constellation_metrics_cf); -trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); +trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); class trellis_constellation_metrics_cf : public gr_block { private: - trellis_constellation_metrics_cf (gr_constellation_sptr constellation, trellis_metric_type_t TYPE); + trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); }; -- cgit From 233621d6bbc3c68109998d0e68ffc7df7de69eb4 Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Tue, 21 Jun 2011 15:51:40 -0700 Subject: gr-digital, gr-trellis: Fixing gr-trellis to work with constellation now that it is in gr-digital. --- gr-trellis/src/lib/Makefile.am | 1 - gr-trellis/src/lib/calc_metric.h | 2 +- gr-trellis/src/lib/core_algorithms.h | 2 +- gr-trellis/src/lib/metric_type.h | 31 ---------------------- gr-trellis/src/lib/trellis.i | 3 +-- .../src/lib/trellis_constellation_metrics_cf.h | 2 +- 6 files changed, 4 insertions(+), 37 deletions(-) delete mode 100644 gr-trellis/src/lib/metric_type.h (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index 2f249f62f..e81490089 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -82,7 +82,6 @@ grinclude_HEADERS = \ quicksort_index.h \ base.h \ interleaver.h \ - metric_type.h \ calc_metric.h \ core_algorithms.h \ trellis_permutation.h \ diff --git a/gr-trellis/src/lib/calc_metric.h b/gr-trellis/src/lib/calc_metric.h index d628f44e0..fd20f8d36 100644 --- a/gr-trellis/src/lib/calc_metric.h +++ b/gr-trellis/src/lib/calc_metric.h @@ -25,7 +25,7 @@ #include #include -#include +#include template diff --git a/gr-trellis/src/lib/core_algorithms.h b/gr-trellis/src/lib/core_algorithms.h index fdb5f398e..fd45844c0 100644 --- a/gr-trellis/src/lib/core_algorithms.h +++ b/gr-trellis/src/lib/core_algorithms.h @@ -26,7 +26,7 @@ #include #include //#include -#include "metric_type.h" +#include "digital_metric_type.h" #include "fsm.h" #include "interleaver.h" diff --git a/gr-trellis/src/lib/metric_type.h b/gr-trellis/src/lib/metric_type.h deleted file mode 100644 index a1040f108..000000000 --- a/gr-trellis/src/lib/metric_type.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_TRELLIS_METRIC_TYPE_H -#define INCLUDED_TRELLIS_METRIC_TYPE_H - -typedef enum { - TRELLIS_EUCLIDEAN = 200, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT -} trellis_metric_type_t; - -#endif - diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i index 84b77a286..a030ab906 100644 --- a/gr-trellis/src/lib/trellis.i +++ b/gr-trellis/src/lib/trellis.i @@ -41,14 +41,13 @@ %include "trellis_siso_f.i" %include "trellis_siso_combined_f.i" -%include "metric_type.h" %include "siso_type.h" %include "trellis_constellation_metrics_cf.i" %include "trellis_generated.i" -%import "gr_metric_type.h" +%import "digital_metric_type.h" %import "digital_constellation.i" %pythoncode %{ diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h index 1a0eb72ee..a34c335ec 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -25,7 +25,7 @@ #include #include -#include +#include class trellis_constellation_metrics_cf; typedef boost::shared_ptr trellis_constellation_metrics_cf_sptr; -- cgit From 7efeff11a41392c55d2e2a620c17b9e1bda21205 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 10 Jul 2011 20:30:25 -0400 Subject: digital: work on build to make gr-trellis dependent on gr-digital. --- gr-trellis/src/lib/Makefile.am | 8 ++++---- gr-trellis/src/lib/trellis.i | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index e81490089..795ac28b4 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -30,8 +30,8 @@ EXTRA_DIST += \ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) \ - -I$(abs_top_builddir)/gr-digital/lib - + -I$(abs_top_srcdir)/gr-digital/lib -I/home + # ---------------------------------------------------------------- # these scripts generate trellis codes from template files @@ -162,8 +162,8 @@ BUILT_SOURCES += $(python_built_sources) # Location of non-standard SWIG interface files trellis_swig_args = \ - -I$(abs_top_builddir)/gr-digital/lib \ - -I$(abs_top_builddir)/gr-digital/swig + -I$(top_srcdir)/gr-digital/lib \ + -I$(top_srcdir)/gr-digital/swig if GUILE TESTS += run_guile_tests diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i index a030ab906..d01ab529a 100644 --- a/gr-trellis/src/lib/trellis.i +++ b/gr-trellis/src/lib/trellis.i @@ -50,9 +50,9 @@ %import "digital_metric_type.h" %import "digital_constellation.i" -%pythoncode %{ - from gnuradio.gr import TRELLIS_EUCLIDEAN, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT - %} + //%pythoncode %{ + // from gnuradio.gr import TRELLIS_EUCLIDEAN, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT + // %} #if SWIGGUILE %scheme %{ -- cgit From 04409d2ba42ac5b372a7b6bb7e9c8de5722d76d7 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 12 Jul 2011 23:05:25 -0400 Subject: trellis: fixing trellis build and qa structure. run_tests.in adds gr-digital to the PYTHONPATH so that the QA code can import digital_swig. --- gr-trellis/src/python/qa_trellis.py | 15 ++++++++++----- gr-trellis/src/python/run_tests.in | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'gr-trellis') diff --git a/gr-trellis/src/python/qa_trellis.py b/gr-trellis/src/python/qa_trellis.py index ba415e6c9..b50679f27 100755 --- a/gr-trellis/src/python/qa_trellis.py +++ b/gr-trellis/src/python/qa_trellis.py @@ -28,6 +28,9 @@ from gnuradio import gr, gr_unittest, blks2 # but because it runs on the non-installed python code it's all a mess. import trellis +import os +import digital_swig + fsm_args = {"awgn1o2_4": (2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), (0, 3, 3, 0, 1, 2, 2, 1), @@ -36,8 +39,8 @@ fsm_args = {"awgn1o2_4": (2, 4, 4, "nothing": (2, 1, 2, (0, 0), (0, 1)), } -constells = {2: blks2.bpsk_constellation(), - 4: blks2.qpsk_constellation(), +constells = {2: digital_swig.constellation_bpsk(), + 4: digital_swig.constellation_qpsk(), } class test_trellis (gr_unittest.TestCase): @@ -52,8 +55,10 @@ class test_trellis (gr_unittest.TestCase): self.assertEqual((g.I(),g.S(),g.O(),g.NS(),g.OS()),(f.I(),f.S(),f.O(),f.NS(),f.OS())) def test_003_fsm (self): - f = trellis.fsm("awgn1o2_4.fsm") - self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS())) + # FIXME: no file "awgn1o2_4.fsm" + #f = trellis.fsm("awgn1o2_4.fsm") + #self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS())) + pass def test_004_fsm(self): """ Test to make sure fsm works with a single state fsm.""" @@ -117,7 +122,7 @@ class trellis_tb(gr.top_block): # RX # data preprocessing to generate metrics for Viterbi - metrics = trellis.constellation_metrics_cf(constellation.base(), trellis.TRELLIS_EUCLIDEAN) + metrics = trellis.constellation_metrics_cf(constellation.base(), digital_swig.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set. va = trellis.viterbi_s(f, K, 0, -1) # pack FSM input symbols to shorts diff --git a/gr-trellis/src/python/run_tests.in b/gr-trellis/src/python/run_tests.in index 0da3fc1f1..fcb078663 100644 --- a/gr-trellis/src/python/run_tests.in +++ b/gr-trellis/src/python/run_tests.in @@ -4,6 +4,8 @@ # 2nd parameter is absolute path to component build directory # 3rd parameter is path to Python QA directory +PYTHONPATH=@top_builddir@/gr-digital/swig:@top_builddir@/gr-digital/swig/.libs:@top_srcdir@/gr-digital/swig:$PYTHONPATH + @top_builddir@/run_tests.sh \ @abs_top_srcdir@/gr-trellis \ @abs_top_builddir@/gr-trellis \ -- cgit