summaryrefslogtreecommitdiff
path: root/gr-trellis/src/lib
diff options
context:
space:
mode:
authoranastas2008-11-13 15:24:59 +0000
committeranastas2008-11-13 15:24:59 +0000
commitd2b06e6769d7500aa06239f693de8d6cb43eff29 (patch)
tree08ec8828eb1efbffbd1b07422047ed321786f6cf /gr-trellis/src/lib
parent4f8ca94b8375ff482f43a143c0055d583986e3bf (diff)
downloadgnuradio-d2b06e6769d7500aa06239f693de8d6cb43eff29.tar.gz
gnuradio-d2b06e6769d7500aa06239f693de8d6cb43eff29.tar.bz2
gnuradio-d2b06e6769d7500aa06239f693de8d6cb43eff29.zip
Several updates on gr-trellis: 1) new fsm constructor for a joint trellis, 2) Corresponding fsm file examples, 3) added set_TABLE method in viterbi_combined and metrics
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9985 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-trellis/src/lib')
-rw-r--r--gr-trellis/src/lib/fsm.cc29
-rw-r--r--gr-trellis/src/lib/fsm.h1
-rw-r--r--gr-trellis/src/lib/fsm.i1
-rw-r--r--gr-trellis/src/lib/trellis_metrics_X.cc.t5
-rw-r--r--gr-trellis/src/lib/trellis_metrics_X.h.t1
-rw-r--r--gr-trellis/src/lib/trellis_metrics_X.i.t1
-rw-r--r--gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t5
-rw-r--r--gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t1
-rw-r--r--gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t1
9 files changed, 44 insertions, 1 deletions
diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc
index cddb7e665..50598a94c 100644
--- a/gr-trellis/src/lib/fsm.cc
+++ b/gr-trellis/src/lib/fsm.cc
@@ -240,6 +240,35 @@ fsm::fsm(int mod_size, int ch_length)
//######################################################################
+//# Automatically generate an FSM specification describing the
+//# the joint trellis of fsm1 and fsm2
+//######################################################################
+fsm::fsm(const fsm &FSM1, const fsm &FSM2)
+{
+ d_I=FSM1.I()*FSM2.I();
+ d_S=FSM1.S()*FSM2.S();
+ d_O=FSM1.O()*FSM2.O();
+
+ d_NS.resize(d_I*d_S);
+ d_OS.resize(d_I*d_S);
+
+ for(int s=0;s<d_S;s++) {
+ for(int i=0;i<d_I;i++) {
+ int s1=s/FSM2.S();
+ int s2=s%FSM2.S();
+ int i1=i/FSM2.I();
+ int i2=i%FSM2.I();
+ d_NS[s*d_I+i] = FSM1.NS()[s1 * FSM1.I() + i1] * FSM2.S() + FSM2.NS()[s2 * FSM2.I() + i2];
+ d_OS[s*d_I+i] = FSM1.OS()[s1 * FSM1.I() + i1] * FSM2.O() + FSM2.OS()[s2 * FSM2.I() + i2];
+ }
+ }
+
+ generate_PS_PI();
+ generate_TM();
+}
+
+
+//######################################################################
//# generate the PS and PI tables for later use
//######################################################################
void fsm::generate_PS_PI()
diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h
index e015a37fb..e9ebb91ec 100644
--- a/gr-trellis/src/lib/fsm.h
+++ b/gr-trellis/src/lib/fsm.h
@@ -50,6 +50,7 @@ public:
fsm(const char *name);
fsm(int k, int n, const std::vector<int> &G);
fsm(int mod_size, int ch_length);
+ fsm(const fsm &FSM1, const fsm &FSM2);
int I () const { return d_I; }
int S () const { return d_S; }
int O () const { return d_O; }
diff --git a/gr-trellis/src/lib/fsm.i b/gr-trellis/src/lib/fsm.i
index b566f8aa3..ac00d40e3 100644
--- a/gr-trellis/src/lib/fsm.i
+++ b/gr-trellis/src/lib/fsm.i
@@ -40,6 +40,7 @@ public:
fsm(const char *name);
fsm(int k, int n, const std::vector<int> &G);
fsm(int mod_size, int ch_length);
+ fsm(const fsm &FSM1, const fsm &FSM2);
int I () const { return d_I; }
int S () const { return d_S; }
int O () const { return d_O; }
diff --git a/gr-trellis/src/lib/trellis_metrics_X.cc.t b/gr-trellis/src/lib/trellis_metrics_X.cc.t
index 64aa3edd8..bced13c0c 100644
--- a/gr-trellis/src/lib/trellis_metrics_X.cc.t
+++ b/gr-trellis/src/lib/trellis_metrics_X.cc.t
@@ -54,7 +54,10 @@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, tre
set_output_multiple ((int)d_O);
}
-
+void @NAME@::set_TABLE (const std::vector<@I_TYPE@> &table)
+{
+ d_TABLE = table;
+}
void
diff --git a/gr-trellis/src/lib/trellis_metrics_X.h.t b/gr-trellis/src/lib/trellis_metrics_X.h.t
index a076bb600..c46740a54 100644
--- a/gr-trellis/src/lib/trellis_metrics_X.h.t
+++ b/gr-trellis/src/lib/trellis_metrics_X.h.t
@@ -53,6 +53,7 @@ public:
int D () const { return d_D; }
trellis_metric_type_t TYPE () const { return d_TYPE; }
std::vector<@I_TYPE@> TABLE () const { return d_TABLE; }
+ void set_TABLE (const std::vector<@I_TYPE@> &table);
void forecast (int noutput_items,
gr_vector_int &ninput_items_required);
int general_work (int noutput_items,
diff --git a/gr-trellis/src/lib/trellis_metrics_X.i.t b/gr-trellis/src/lib/trellis_metrics_X.i.t
index d1c63429e..50aa7a767 100644
--- a/gr-trellis/src/lib/trellis_metrics_X.i.t
+++ b/gr-trellis/src/lib/trellis_metrics_X.i.t
@@ -35,5 +35,6 @@ public:
int O () const { return d_O; }
int D () const { return d_D; }
trellis_metric_type_t TYPE () const { return d_TYPE; }
+ void set_TABLE (const std::vector<@I_TYPE@> &table);
std::vector<@I_TYPE@> TABLE () const { return d_TABLE; }
};
diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t
index b7ab48faa..e343a4965 100644
--- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t
+++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t
@@ -71,6 +71,11 @@ trellis_make_@BASE_NAME@ (
}
+void @NAME@::set_TABLE(const std::vector<@I_TYPE@> &table)
+{
+ d_TABLE = table;
+}
+
void
@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t
index 7a7850ff5..ae5ccf841 100644
--- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t
+++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t
@@ -82,6 +82,7 @@ public:
std::vector<@I_TYPE@> TABLE () const { return d_TABLE; }
trellis_metric_type_t TYPE () const { return d_TYPE; }
//std::vector<int> trace () const { return d_trace; }
+ void set_TABLE (const std::vector<@I_TYPE@> &table);
void forecast (int noutput_items,
gr_vector_int &ninput_items_required);
int general_work (int noutput_items,
diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t
index 33af6e8bb..633ded770 100644
--- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t
+++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t
@@ -55,4 +55,5 @@ public:
std::vector<@I_TYPE@> TABLE () const { return d_TABLE; }
trellis_metric_type_t TYPE () const { return d_TYPE; }
//std::vector<short> trace () const { return d_trace; }
+ void set_TABLE (const std::vector<@I_TYPE@> &table);
};