X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gr-trellis%2Fsrc%2Flib%2Ffsm.cc;h=a27bc87daca7c3fd663559b56bf49475bf2b8745;hb=c9717248b32083565bdbdd8cbacde1dac92daf31;hp=22f7772b3c4ab98efcd206f42586e6bda860ddf6;hpb=86f5c92427b3f4bb30536d76cf63c3fca388fb2f;p=debian%2Fgnuradio diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index 22f7772b..a27bc87d 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -21,6 +21,9 @@ */ #include +#include +#include +#include #include #include #include "base.h" @@ -47,7 +50,7 @@ fsm::fsm(const fsm &FSM) d_O=FSM.O(); d_NS=FSM.NS(); d_OS=FSM.OS(); - d_PS=FSM.PS(); + d_PS=FSM.PS(); // is this going to make a deep copy? d_PI=FSM.PI(); d_TMi=FSM.TMi(); d_TMl=FSM.TMl(); @@ -100,7 +103,6 @@ fsm::fsm(const char *name) - //###################################################################### //# Automatically generate the FSM from the generator matrix //# of a (n,k) binary convolutional code @@ -241,17 +243,21 @@ fsm::fsm(int mod_size, int ch_length) //###################################################################### void fsm::generate_PS_PI() { - d_PS.resize(d_I*d_S); - d_PI.resize(d_I*d_S); + d_PS.resize(d_S); + d_PI.resize(d_S); for(int i=0;i" << std::endl; + + for( int stage_num = 0;stage_num < number_stages;stage_num ++){ + // draw states + for ( int state_num = 0;state_num < d_S ; state_num ++ ) { + trellis_fname << "" << std::endl; + //draw branches + if(stage_num != number_stages-1){ + for( int branch_num = 0;branch_num < d_I; branch_num++){ + trellis_fname << "" << std::endl; + } + } + } + } + // label the stages + trellis_fname << "" << std::endl; + for( int stage_num = 0;stage_num < number_stages ;stage_num ++){ + trellis_fname << "" << std::endl; + trellis_fname << stage_num << std::endl; + trellis_fname << "" << std::endl; + } + trellis_fname << "" << std::endl; + + // label the states + trellis_fname << "" << std::endl; + for( int state_num = 0;state_num < d_S ; state_num ++){ + trellis_fname << "" << std::endl; + trellis_fname << state_num << std::endl; + trellis_fname << "" << std::endl; + } + trellis_fname << "" << std::endl; + + + trellis_fname << "" << std::endl; +// std::cout << "################## END SVG TRELLIS PIC ##################### " << std::endl; + trellis_fname.close(); +} +//###################################################################### +//# Write trellis specification to a text files, +//# in the same format used when reading FSM files +//###################################################################### +void fsm::write_fsm_txt(std::string filename) +{ + std::ofstream trellis_fname (filename.c_str()); + if (!trellis_fname) {std::cout << "file not found " << std::endl ; exit(-1);} + trellis_fname << d_I << ' ' << d_S << ' ' << d_O << std::endl; + trellis_fname << std::endl; + for(int i=0;i