diff options
Diffstat (limited to 'gr-trellis')
-rwxr-xr-x | gr-trellis/src/examples/fsm_utils.py | 27 | ||||
-rw-r--r-- | gr-trellis/src/lib/fsm.cc | 42 | ||||
-rw-r--r-- | gr-trellis/src/lib/fsm.h | 1 | ||||
-rw-r--r-- | gr-trellis/src/lib/fsm.i | 1 |
4 files changed, 44 insertions, 27 deletions
diff --git a/gr-trellis/src/examples/fsm_utils.py b/gr-trellis/src/examples/fsm_utils.py index ab7b4e946..e3426637c 100755 --- a/gr-trellis/src/examples/fsm_utils.py +++ b/gr-trellis/src/examples/fsm_utils.py @@ -61,33 +61,6 @@ def base2dec(s,base): -###################################################################### -# 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 diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index 550674ad5..c65b13456 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -315,6 +315,48 @@ fsm::fsm(const fsm &FSM1, const fsm &FSM2) } + + +//###################################################################### +//# 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 //###################################################################### diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h index b91dc2ab1..0a90b2cd3 100644 --- a/gr-trellis/src/lib/fsm.h +++ b/gr-trellis/src/lib/fsm.h @@ -52,6 +52,7 @@ public: 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; } diff --git a/gr-trellis/src/lib/fsm.i b/gr-trellis/src/lib/fsm.i index e9db804a0..1e9c7ad8f 100644 --- a/gr-trellis/src/lib/fsm.i +++ b/gr-trellis/src/lib/fsm.i @@ -42,6 +42,7 @@ public: 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; } |