/* -*- c++ -*- */ /* * Copyright 2002 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #include #include #include #include "base.h" #include "fsm.h" fsm::fsm() { d_I=0; d_S=0; d_O=0; d_NS.resize(0); d_OS.resize(0); d_PS.resize(0); d_PI.resize(0); d_TMi.resize(0); d_TMl.resize(0); } fsm::fsm(const fsm &FSM) { d_I=FSM.I(); d_S=FSM.S(); d_O=FSM.O(); d_NS=FSM.NS(); d_OS=FSM.OS(); d_PS=FSM.PS(); // is this going to make a deep copy? d_PI=FSM.PI(); d_TMi=FSM.TMi(); d_TMl=FSM.TMl(); } fsm::fsm(int I, int S, int O, const std::vector &NS, const std::vector &OS) { d_I=I; d_S=S; d_O=O; d_NS=NS; d_OS=OS; generate_PS_PI(); generate_TM(); } //###################################################################### //# Read an FSM specification from a file. //# Format (hopefully will become more flexible in the future...): //# I S O (in the first line) //# blank line //# Next state matrix (S lines, each with I integers separated by spaces) //# blank line //# output symbol matrix (S lines, each with I integers separated by spaces) //# optional comments //###################################################################### fsm::fsm(const char *name) { FILE *fsmfile; if((fsmfile=fopen(name,"r"))==NULL) throw std::runtime_error ("fsm::fsm(const char *name): file open error\n"); //printf("file open error in fsm()\n"); fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O); d_NS.resize(d_I*d_S); d_OS.resize(d_I*d_S); for(int i=0;i &G) { // calculate maximum memory requirements for each input stream std::vector max_mem_x(k,-1); int max_mem = -1; for(int i=0;imax_mem_x[i]) max_mem_x[i]=mem; if(mem>max_mem) max_mem=mem; } } //printf("max_mem_x\n"); //for(int j=0;j > Gb(k*n); for(int j=0;j bases_x(k); for(int j=0;j sx(k); std::vector nsx(k); std::vector tx(k); std::vector > tb(k); for(int j=0;j inb(k); std::vector outb(n); for(int s=0;s