diff options
author | Achilleas Anastasopoulos | 2011-02-20 10:13:46 -0500 |
---|---|---|
committer | Achilleas Anastasopoulos | 2011-02-20 10:13:46 -0500 |
commit | 6454b7f23db35e87d7ab9a6d7a266e846277191e (patch) | |
tree | 6a62a9f0bf16e7ae9d8688f28ba55de3494d42bf /gr-trellis/src/lib | |
parent | 9bc24753ce556492bb222ca4b91e15fb1fcf0f32 (diff) | |
download | gnuradio-6454b7f23db35e87d7ab9a6d7a266e846277191e.tar.gz gnuradio-6454b7f23db35e87d7ab9a6d7a266e846277191e.tar.bz2 gnuradio-6454b7f23db35e87d7ab9a6d7a266e846277191e.zip |
added sccc_decoder block (without the metrics part)
Diffstat (limited to 'gr-trellis/src/lib')
-rw-r--r-- | gr-trellis/src/lib/.gitignore | 9 | ||||
-rw-r--r-- | gr-trellis/src/lib/Makefile.am | 3 | ||||
-rw-r--r-- | gr-trellis/src/lib/core_algorithms.cc | 134 | ||||
-rw-r--r-- | gr-trellis/src/lib/core_algorithms.h | 9 | ||||
-rw-r--r-- | gr-trellis/src/lib/generate_trellis.py | 2 | ||||
-rw-r--r-- | gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t | 123 | ||||
-rw-r--r-- | gr-trellis/src/lib/trellis_sccc_decoder_X.h.t | 102 | ||||
-rw-r--r-- | gr-trellis/src/lib/trellis_sccc_decoder_X.i.t | 60 |
8 files changed, 442 insertions, 0 deletions
diff --git a/gr-trellis/src/lib/.gitignore b/gr-trellis/src/lib/.gitignore index 1ded7cffe..2a544a56f 100644 --- a/gr-trellis/src/lib/.gitignore +++ b/gr-trellis/src/lib/.gitignore @@ -131,6 +131,15 @@ /trellis_sccc_decoder_combined_ci.h /trellis_sccc_decoder_combined_ci.i /trellis_sccc_decoder_combined_ci.cc +/trellis_sccc_decoder_b.h +/trellis_sccc_decoder_b.i +/trellis_sccc_decoder_b.cc +/trellis_sccc_decoder_s.h +/trellis_sccc_decoder_s.i +/trellis_sccc_decoder_s.cc +/trellis_sccc_decoder_i.h +/trellis_sccc_decoder_i.i +/trellis_sccc_decoder_i.cc /trellis_generated.i /generate-stamp /stamp-* diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index 809efdcb3..5b47c5a32 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -44,6 +44,9 @@ core_generator = \ trellis_sccc_decoder_combined_XX.cc.t \ trellis_sccc_decoder_combined_XX.h.t \ trellis_sccc_decoder_combined_XX.i.t \ + trellis_sccc_decoder_X.cc.t \ + trellis_sccc_decoder_X.h.t \ + trellis_sccc_decoder_X.i.t \ trellis_viterbi_X.cc.t \ trellis_viterbi_X.h.t \ trellis_viterbi_X.i.t diff --git a/gr-trellis/src/lib/core_algorithms.cc b/gr-trellis/src/lib/core_algorithms.cc index c1bafa379..b7037926e 100644 --- a/gr-trellis/src/lib/core_algorithms.cc +++ b/gr-trellis/src/lib/core_algorithms.cc @@ -963,3 +963,137 @@ void sccc_decoder_combined<gr_complex,int>( const gr_complex *observations, int *data ); + + +//========================================================= + +template<class T> +void sccc_decoder( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int repetitions, + float (*p2mymin)(float,float), + const float *iprioro, T *data +) +{ + +//allocate space for priori, and posti of inner FSM +std::vector<float> ipriori(blocklength*FSMi.I(),0.0); +std::vector<float> iposti(blocklength*FSMi.I()); + +//allocate space for priori, prioro and posto of outer FSM +std::vector<float> opriori(blocklength*FSMo.I(),0.0); +std::vector<float> oprioro(blocklength*FSMo.O()); +std::vector<float> oposti(blocklength*FSMo.I()); +std::vector<float> oposto(blocklength*FSMo.O()); + +for(int rep=0;rep<repetitions;rep++) { + // run inner SISO + siso_algorithm(FSMi.I(),FSMi.S(),FSMi.O(), + FSMi.NS(), FSMi.OS(), FSMi.PS(), FSMi.PI(), + blocklength, + STi0,STiK, + true, false, + p2mymin, + &(ipriori[0]), &(iprioro[0]), &(iposti[0]) + ); + + //interleave soft info inner -> outer + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.DEINTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //oprioro[k*FSMi.I()+i]=iposti[ki*FSMi.I()+i]; + //} + memcpy(&(oprioro[k*FSMi.I()]),&(iposti[ki*FSMi.I()]),FSMi.I()*sizeof(float)); + } + + // run outer SISO + + if(rep<repetitions-1) { // do not produce posti + siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + false, true, + p2mymin, + &(opriori[0]), &(oprioro[0]), &(oposto[0]) + ); + + //interleave soft info outer --> inner + for(int k=0;k<blocklength;k++) { + int ki = INTERLEAVER.DEINTER()[k]; + //for(int i=0;i<FSMi.I();i++) { + //ipriori[ki*FSMi.I()+i]=oposto[k*FSMi.I()+i]; + //} + memcpy(&(ipriori[ki*FSMi.I()]),&(oposto[k*FSMi.I()]),FSMi.I()*sizeof(float)); + } + } + else // produce posti but not posto + + siso_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + true, false, + p2mymin, + &(opriori[0]), &(oprioro[0]), &(oposti[0]) + ); + + /* + viterbi_algorithm(FSMo.I(),FSMo.S(),FSMo.O(), + FSMo.NS(), FSMo.OS(), FSMo.PS(), FSMo.PI(), + blocklength, + STo0,SToK, + &(oprioro[0]), data + ); + */ + +} + + +// generate hard decisions +for(int k=0;k<blocklength;k++) { + float min=INF; + int mini=0; + for(int i=0;i<FSMo.I();i++) { + if(oposti[k*FSMo.I()+i]<min) { + min=oposti[k*FSMo.I()+i]; + mini=i; + } + } + data[k]=(T)mini; +} + + + +} + +//------- + +template +void sccc_decoder<unsigned char>( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int repetitions, + float (*p2mymin)(float,float), + const float *iprioro, unsigned char *data +); + +template +void sccc_decoder<short>( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int repetitions, + float (*p2mymin)(float,float), + const float *iprioro, short *data +); + +template +void sccc_decoder<int>( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int repetitions, + float (*p2mymin)(float,float), + const float *iprioro, int *data +); + diff --git a/gr-trellis/src/lib/core_algorithms.h b/gr-trellis/src/lib/core_algorithms.h index 8e4ffe522..e52a22b8e 100644 --- a/gr-trellis/src/lib/core_algorithms.h +++ b/gr-trellis/src/lib/core_algorithms.h @@ -104,6 +104,15 @@ void sccc_decoder_combined( ); +template<class T> +void sccc_decoder( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, int blocklength, int repetitions, + float (*p2mymin)(float,float), + const float *iprioro, T *data +); + diff --git a/gr-trellis/src/lib/generate_trellis.py b/gr-trellis/src/lib/generate_trellis.py index 691276cc8..9d2c593b4 100644 --- a/gr-trellis/src/lib/generate_trellis.py +++ b/gr-trellis/src/lib/generate_trellis.py @@ -33,6 +33,7 @@ other_roots = [ 'trellis_viterbi_X', 'trellis_viterbi_combined_XX', 'trellis_sccc_decoder_combined_XX', + 'trellis_sccc_decoder_X', ] other_signatures = ( @@ -42,6 +43,7 @@ other_signatures = ( ['b','s','i'], ['sb','ss','si','ib','is','ii','fb','fs','fi','cb','cs','ci'], ['fb','fs','fi','cb','cs','ci'], + ['b','s','i'], ) diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t new file mode 100644 index 000000000..da853f2ea --- /dev/null +++ b/gr-trellis/src/lib/trellis_sccc_decoder_X.cc.t @@ -0,0 +1,123 @@ +/* -*- 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@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME@.h> +#include <gr_io_signature.h> +#include <assert.h> +#include <iostream> +#include "core_algorithms.h" + + +static const float INF = 1.0e9; + +@SPTR_NAME@ +trellis_make_@BASE_NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE +) +{ + return gnuradio::get_initial_sptr (new @NAME@ ( + FSMo, STo0, SToK, + FSMi, STi0, STiK, + INTERLEAVER, + blocklength, + repetitions, + SISO_TYPE + )); +} + +@NAME@::@NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE +) + : gr_block ("@BASE_NAME@", + gr_make_io_signature (1, 1, sizeof (float)), + gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), + d_FSMo (FSMo), d_STo0 (STo0), d_SToK (SToK), + d_FSMi (FSMi), d_STi0 (STi0), d_STiK (STiK), + d_INTERLEAVER (INTERLEAVER), + d_blocklength (blocklength), + d_repetitions (repetitions), + d_SISO_TYPE (SISO_TYPE) +{ + set_relative_rate (1.0 / ((double) d_FSMi.O())); + set_output_multiple (d_blocklength); +} + + +void +@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + assert (noutput_items % d_blocklength == 0); + int input_required = d_FSMi.O() * noutput_items ; + ninput_items_required[0] = input_required; +} + + + +//=========================================================== + +int +@NAME@::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_blocklength == 0); + int nblocks = noutput_items / d_blocklength; + + float (*p2min)(float, float) = NULL; + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + + const float *in = (const float *) input_items[0]; + @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; + for (int n=0;n<nblocks;n++) { + sccc_decoder( + d_FSMo, d_STo0, d_SToK, + d_FSMi, d_STi0, d_STiK, + d_INTERLEAVER, d_blocklength, d_repetitions, + p2min, + &(in[n*d_blocklength*d_FSMi.O()]),&(out[n*d_blocklength]) + ); + } + + consume_each (d_FSMi.O() * noutput_items ); + return noutput_items; +} diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t new file mode 100644 index 000000000..3adb8a5b7 --- /dev/null +++ b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t @@ -0,0 +1,102 @@ +/* -*- 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@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include "fsm.h" +#include "interleaver.h" +#include <gr_block.h> +#include <vector> +#include "siso_type.h" + +class @NAME@; +typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; + +@SPTR_NAME@ trellis_make_@BASE_NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE // perform "min-sum" or "sum-product" combining +); + + +/*! + * \ingroup coding_blk + */ +class @NAME@ : public gr_block +{ + fsm d_FSMo; + fsm d_FSMi; + int d_STo0; + int d_SToK; + int d_STi0; + int d_STiK; + interleaver d_INTERLEAVER; + int d_blocklength; + int d_repetitions; + trellis_siso_type_t d_SISO_TYPE; + std::vector<float> d_buffer; + + friend @SPTR_NAME@ trellis_make_@BASE_NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE + ); + + @NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE + ); + +public: + fsm FSMo () const { return d_FSMo; } + fsm FSMi () const { return d_FSMi; } + int STo0 () const { return d_STo0; } + int SToK () const { return d_SToK; } + int STi0 () const { return d_STi0; } + int STiK () const { return d_STiK; } + interleaver INTERLEAVER () const { return d_INTERLEAVER; } + int blocklength () const { return d_blocklength; } + int repetitions () const { return d_repetitions; } + trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } + + 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); +}; + +#endif diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.i.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.i.t new file mode 100644 index 000000000..a4392ee6f --- /dev/null +++ b/gr-trellis/src/lib/trellis_sccc_decoder_X.i.t @@ -0,0 +1,60 @@ +/* -*- 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@ + +GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); + +@SPTR_NAME@ trellis_make_@BASE_NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE +); + + +class @NAME@ : public gr_block +{ +private: + @NAME@ ( + const fsm &FSMo, int STo0, int SToK, + const fsm &FSMi, int STi0, int STiK, + const interleaver &INTERLEAVER, + int blocklength, + int repetitions, + trellis_siso_type_t SISO_TYPE + ); + +public: + fsm FSMo () const { return d_FSMo; } + fsm FSMi () const { return d_FSMi; } + int STo0 () const { return d_STo0; } + int SToK () const { return d_SToK; } + int STi0 () const { return d_STi0; } + int STiK () const { return d_STiK; } + interleaver INTERLEAVER () const { return d_INTERLEAVER; } + int blocklength () const { return d_blocklength; } + int repetitions () const { return d_repetitions; } + trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } +}; |