diff options
author | anastas | 2009-02-26 00:29:51 +0000 |
---|---|---|
committer | anastas | 2009-02-26 00:29:51 +0000 |
commit | 436f3744f211b396b68fd58699063047899b7281 (patch) | |
tree | 2505fb981bc452f867b4633a11e57b188a565d01 /gr-trellis/src/lib | |
parent | 4d192c227e6c7a00b82aef4aca71a3a77ac0dbd1 (diff) | |
download | gnuradio-436f3744f211b396b68fd58699063047899b7281.tar.gz gnuradio-436f3744f211b396b68fd58699063047899b7281.tar.bz2 gnuradio-436f3744f211b396b68fd58699063047899b7281.zip |
Added support for Continuous Phase Modulation in gr-trellis + an example
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10514 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-trellis/src/lib')
-rw-r--r-- | gr-trellis/src/lib/fsm.cc | 51 | ||||
-rw-r--r-- | gr-trellis/src/lib/fsm.h | 1 | ||||
-rw-r--r-- | gr-trellis/src/lib/fsm.i | 1 | ||||
-rw-r--r-- | gr-trellis/src/lib/trellis_calc_metric.cc | 3 |
4 files changed, 54 insertions, 2 deletions
diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index 50598a94c..550674ad5 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -170,7 +170,7 @@ fsm::fsm(int k, int n, const std::vector<int> &G) for(int s=0;s<d_S;s++) { - dec2bases(s,bases_x,sx); // split s into k values, each representing on of the k shift registers + dec2bases(s,bases_x,sx); // split s into k values, each representing one of the k shift registers //printf("state = %d \nstates = ",s); //for(int j=0;j<sx.size();j++) printf("%d ",sx[j]); printf("\n"); for(int i=0;i<d_I;i++) { @@ -239,6 +239,53 @@ fsm::fsm(int mod_size, int ch_length) } + + +//###################################################################### +//# Automatically generate an FSM specification describing the +//# the trellis for a CPM with h=K/P (relatively prime), +//# alphabet size M, and frequency pulse duration L symbols +//# +//# 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::fsm(int P, int M, int L) +{ + d_I=M; + d_S=(int)(pow(1.0*M,1.0*L-1)+0.5)*P; + d_O=(int)(pow(1.0*M,1.0*L)+0.5)*P; + + d_NS.resize(d_I*d_S); + d_OS.resize(d_I*d_S); + int nv; + for(int s=0;s<d_S;s++) { + for(int i=0;i<d_I;i++) { + int s1=s/P; + int v=s%P; + int ns1= (i*(int)(pow(1.0*M,1.0*(L-1))+0.5)+s1)/M; + if (L==1) + nv=(i+v)%P; + else + nv=(s1%M+v)%P; + d_NS[s*d_I+i] = ns1*P+nv; + d_OS[s*d_I+i] = i*d_S+s; + } + } + + generate_PS_PI(); + generate_TM(); +} + + + + + + + + + + //###################################################################### //# Automatically generate an FSM specification describing the //# the joint trellis of fsm1 and fsm2 @@ -419,7 +466,7 @@ void fsm::write_trellis_svg( std::string filename ,int number_stages) //###################################################################### -//# Write trellis specification to a text files, +//# Write trellis specification to a text file, //# in the same format used when reading FSM files //###################################################################### void fsm::write_fsm_txt(std::string filename) diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h index e9ebb91ec..b91dc2ab1 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(int P, int M, int L); fsm(const fsm &FSM1, const fsm &FSM2); int I () const { return d_I; } int S () const { return d_S; } diff --git a/gr-trellis/src/lib/fsm.i b/gr-trellis/src/lib/fsm.i index ac00d40e3..e9db804a0 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(int P, int M, int L); fsm(const fsm &FSM1, const fsm &FSM2); int I () const { return d_I; } int S () const { return d_S; } diff --git a/gr-trellis/src/lib/trellis_calc_metric.cc b/gr-trellis/src/lib/trellis_calc_metric.cc index 676f53fd7..0d03fd1a7 100644 --- a/gr-trellis/src/lib/trellis_calc_metric.cc +++ b/gr-trellis/src/lib/trellis_calc_metric.cc @@ -31,6 +31,7 @@ void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, float * { float minm = FLT_MAX; int minmi = 0; + switch (type){ case TRELLIS_EUCLIDEAN: @@ -213,6 +214,7 @@ void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_co float minm = FLT_MAX; int minmi = 0; + switch (type){ case TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { @@ -222,6 +224,7 @@ void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_co metric[o]+=s.real()*s.real()+s.imag()*s.imag(); } } + break; case TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { metric[o]=0.0; |