commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10673 - in gnuradio/trunk/gr-trellis/src: examples li


From: anastas
Subject: [Commit-gnuradio] r10673 - in gnuradio/trunk/gr-trellis/src: examples lib
Date: Tue, 24 Mar 2009 07:11:18 -0600 (MDT)

Author: anastas
Date: 2009-03-24 07:11:18 -0600 (Tue, 24 Mar 2009)
New Revision: 10673

Modified:
   gnuradio/trunk/gr-trellis/src/examples/fsm_utils.py
   gnuradio/trunk/gr-trellis/src/lib/fsm.cc
   gnuradio/trunk/gr-trellis/src/lib/fsm.h
   gnuradio/trunk/gr-trellis/src/lib/fsm.i
Log:
added a radix-n fsm constructor

Modified: gnuradio/trunk/gr-trellis/src/examples/fsm_utils.py
===================================================================
--- gnuradio/trunk/gr-trellis/src/examples/fsm_utils.py 2009-03-23 20:17:32 UTC 
(rev 10672)
+++ gnuradio/trunk/gr-trellis/src/examples/fsm_utils.py 2009-03-24 13:11:18 UTC 
(rev 10673)
@@ -61,34 +61,7 @@
 
 
 
-######################################################################
-# Generate a new FSM representing n stages through the original FSM
-######################################################################
-def fsm_radix(f,n):
-    I=f.I()**n
-    S=f.S()
-    O=f.O()**n
-    nsm=list([0]*I*S)
-    osm=list([0]*I*S)
-    for s in range(f.S()):
-        for i in range(I):
-            ii=dec2base(i,f.I(),n) 
-            oo=list([0]*n)
-            ns=s
-            for k in range(n):
-                oo[k]=f.OS()[ns*f.I()+ii[k]]
-                ns=f.NS()[ns*f.I()+ii[k]]
 
-            nsm[s*I+i]=ns
-            osm[s*I+i]=base2dec(oo,f.O())
-
-
-    f=trellis.fsm(I,S,O,nsm,osm)
-    return f
-
-
-
-
 ######################################################################
 # Automatically generate the lookup table that maps the FSM outputs
 # to channel inputs corresponding to a channel 'channel' and a modulation

Modified: gnuradio/trunk/gr-trellis/src/lib/fsm.cc
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/fsm.cc    2009-03-23 20:17:32 UTC (rev 
10672)
+++ gnuradio/trunk/gr-trellis/src/lib/fsm.cc    2009-03-24 13:11:18 UTC (rev 
10673)
@@ -315,7 +315,49 @@
 }
 
 
+
+
 //######################################################################
+//# Generate a new FSM representing n stages through the original FSM
+//# AKA radix-n FSM
+//######################################################################
+fsm::fsm(const fsm &FSM, int n)
+{
+  d_I=(int) (pow(1.0*FSM.I(),1.0*n)+0.5);
+  d_S=FSM.S();
+  d_O=(int) (pow(1.0*FSM.O(),1.0*n)+0.5);
+
+  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++ ) {
+      std::vector<int> ii(n);
+      dec2base(i,FSM.I(),ii);
+      std::vector<int> oo(n);
+      int ns=s;
+      for(int k=0;k<n;k++) {
+        oo[k]=FSM.OS()[ns*FSM.I()+ii[k]];
+        ns=FSM.NS()[ns*FSM.I()+ii[k]];
+      }
+      d_NS[s*d_I+i]=ns;
+      d_OS[s*d_I+i]=base2dec(oo,FSM.O());
+    }
+  }
+
+  generate_PS_PI();
+  generate_TM();
+}
+
+
+
+
+
+
+
+
+
+//######################################################################
 //# generate the PS and PI tables for later use
 //######################################################################
 void fsm::generate_PS_PI()

Modified: gnuradio/trunk/gr-trellis/src/lib/fsm.h
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/fsm.h     2009-03-23 20:17:32 UTC (rev 
10672)
+++ gnuradio/trunk/gr-trellis/src/lib/fsm.h     2009-03-24 13:11:18 UTC (rev 
10673)
@@ -52,6 +52,7 @@
   fsm(int mod_size, int ch_length);
   fsm(int P, int M, int L);
   fsm(const fsm &FSM1, const fsm &FSM2);
+  fsm(const fsm &FSM, int n);
   int I () const { return d_I; }
   int S () const { return d_S; }
   int O () const { return d_O; }

Modified: gnuradio/trunk/gr-trellis/src/lib/fsm.i
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/fsm.i     2009-03-23 20:17:32 UTC (rev 
10672)
+++ gnuradio/trunk/gr-trellis/src/lib/fsm.i     2009-03-24 13:11:18 UTC (rev 
10673)
@@ -42,6 +42,7 @@
   fsm(int mod_size, int ch_length);
   fsm(int P, int M, int L);
   fsm(const fsm &FSM1, const fsm &FSM2);
+  fsm(const fsm &FSM, int n);
   int I () const { return d_I; }
   int S () const { return d_S; }
   int O () const { return d_O; }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]