_trellis_la_SOURCES = \
trellis.cc \
fsm.cc \
+ interleaver.cc \
trellis_calc_metric.cc \
+ trellis_permutation.cc \
$(GENERATED_CC)
# magic flags
# These headers get installed in ${prefix}/include/gnuradio
grinclude_HEADERS = \
fsm.h \
+ interleaver.h \
trellis_metric_type.h \
trellis_calc_metric.h \
+ trellis_permutation.h \
$(GENERATED_H)
--- /dev/null
+/* -*- c++ -*- */\r
+/*\r
+ * Copyright 2002 Free Software Foundation, Inc.\r
+ *\r
+ * This file is part of GNU Radio\r
+ *\r
+ * GNU Radio is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2, or (at your option)\r
+ * any later version.\r
+ *\r
+ * GNU Radio is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with GNU Radio; see the file COPYING. If not, write to\r
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
+ * Boston, MA 02111-1307, USA.\r
+ */\r
+\r
+#include <cstdio>\r
+#include <stdexcept>\r
+#include <cmath>\r
+#include "interleaver.h"\r
+\r
+interleaver::interleaver()\r
+{\r
+ d_K=0;\r
+ d_INTER.resize(0);\r
+ d_DEINTER.resize(0);\r
+}\r
+\r
+interleaver::interleaver(const interleaver &INTERLEAVER)\r
+{\r
+ d_K=INTERLEAVER.K();\r
+ d_INTER=INTERLEAVER.INTER();\r
+ d_DEINTER=INTERLEAVER.DEINTER();\r
+}\r
+\r
+interleaver::interleaver(const int K, const std::vector<int> &INTER)\r
+{\r
+ d_K=K;\r
+ d_INTER=INTER;\r
+ d_DEINTER.resize(d_K);\r
+ \r
+ // generate DEINTER table\r
+ for(int i=0;i<d_K;i++) {\r
+ d_DEINTER[d_INTER[i]]=i;\r
+ }\r
+}\r
+\r
+//######################################################################\r
+//# Read an INTERLEAVER specification from a file.\r
+//# Format (hopefully will become more flexible in the future...):\r
+//# K\r
+//# blank line\r
+//# list of space separated K integers from 0 to K-1 in appropriate order\r
+//# optional comments\r
+//######################################################################\r
+interleaver::interleaver(const char *name) \r
+{\r
+ FILE *interleaverfile;\r
+\r
+ if((interleaverfile=fopen(name,"r"))==NULL) \r
+ throw std::runtime_error ("file open error in interleaver()");\r
+ //printf("file open error in interleaver()\n");\r
+ \r
+ fscanf(interleaverfile,"%d\n",&d_K);\r
+ d_INTER.resize(d_K);\r
+ d_DEINTER.resize(d_K);\r
+\r
+ for(int i=0;i<d_K;i++) fscanf(interleaverfile,"%d",&(d_INTER[i]));\r
+ \r
+ // generate DEINTER table\r
+ for(int i=0;i<d_K;i++) {\r
+ d_DEINTER[d_INTER[i]]=i;\r
+ }\r
+}\r
--- /dev/null
+/* -*- c++ -*- */\r
+/*\r
+ * Copyright 2002 Free Software Foundation, Inc.\r
+ *\r
+ * This file is part of GNU Radio\r
+ *\r
+ * GNU Radio is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2, or (at your option)\r
+ * any later version.\r
+ *\r
+ * GNU Radio is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with GNU Radio; see the file COPYING. If not, write to\r
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
+ * Boston, MA 02111-1307, USA.\r
+ */\r
+\r
+#ifndef INCLUDED_TRELLIS_INTERLEAVER_H\r
+#define INCLUDED_TRELLIS_INTERLEAVER_H\r
+\r
+#include <vector>\r
+\r
+/*!\r
+ * \brief INTERLEAVER class\r
+ */\r
+class interleaver {\r
+private:\r
+ int d_K;\r
+ std::vector<int> d_INTER;\r
+ std::vector<int> d_DEINTER;\r
+public:\r
+ interleaver();\r
+ interleaver(const interleaver & INTERLEAVER);\r
+ interleaver(const int K, const std::vector<int> & INTER);\r
+ interleaver(const char *name);\r
+ int K () const { return d_K; }\r
+ const std::vector<int> & INTER () const { return d_INTER; }\r
+ const std::vector<int> & DEINTER () const { return d_DEINTER; }\r
+};\r
+\r
+#endif\r
--- /dev/null
+/* -*- c++ -*- */\r
+/*\r
+ * Copyright 2002 Free Software Foundation, Inc.\r
+ *\r
+ * This file is part of GNU Radio\r
+ *\r
+ * GNU Radio is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2, or (at your option)\r
+ * any later version.\r
+ *\r
+ * GNU Radio is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with GNU Radio; see the file COPYING. If not, write to\r
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
+ * Boston, MA 02111-1307, USA.\r
+ */\r
+\r
+class interleaver {\r
+private:\r
+ int d_K;\r
+ std::vector<int> d_INTER;\r
+ std::vector<int> d_DEINTER;\r
+public:\r
+ interleaver();\r
+ interleaver(const interleaver & INTERLEAVER);\r
+ interleaver(const int K, const std::vector<int> & INTER);\r
+ interleaver(const char *name);\r
+ int K () const { return d_K; }\r
+ const std::vector<int> & INTER () const { return d_INTER; }\r
+ const std::vector<int> & DEINTER () const { return d_DEINTER; }\r
+};\r
%{
#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
#include "fsm.h"
+#include "interleaver.h"
+#include "trellis_permutation.h"
#include <stdexcept>
%}
// ----------------------------------------------------------------
%include "fsm.i"
+%include "interleaver.i"
+%include "trellis_permutation.i"
%include "trellis_metric_type.h"
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <trellis_permutation.h>
+#include <gr_io_signature.h>
+#include <iostream>
+
+trellis_permutation_sptr
+trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES)
+{
+ return trellis_permutation_sptr (new trellis_permutation (K,TABLE,NBYTES));
+}
+
+trellis_permutation::trellis_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES)
+ : gr_sync_block ("permutation",
+ gr_make_io_signature (1, -1, NBYTES),
+ gr_make_io_signature (1, -1, NBYTES)),
+ d_K (K),
+ d_TABLE (TABLE),
+ d_NBYTES (NBYTES)
+{
+ set_output_multiple (d_K);
+ //std::cout << d_K << "\n";
+}
+
+
+
+int
+trellis_permutation::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ int nstreams = input_items.size();
+ assert (input_items.size() == output_items.size());
+ assert (noutput_items % d_K ==0);
+ //std::cout << noutput_items << "\n";
+
+ for (int m=0;m<nstreams;m++) {
+ const char *in = (const char *) input_items[m];
+ char *out = (char *) output_items[m];
+
+ // per stream processing
+ for (unsigned int i = 0; i < noutput_items; i++){
+ //std::cout << i << " " << i*d_NBYTES << " " << (d_K*(i/d_K)+d_TABLE[i%d_K])*d_NBYTES << "\n";
+ memcpy(&(out[i*d_NBYTES]), &(in[(d_K*(i/d_K)+d_TABLE[i%d_K])*d_NBYTES]), d_NBYTES);
+ }
+ // end per stream processing
+ }
+ return noutput_items;
+}
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef INCLUDED_TRELLIS_PERMUTATION_H
+#define INCLUDED_TRELLIS_PERMUTATION_H
+
+#include <vector>
+#include <gr_sync_block.h>
+
+class trellis_permutation;
+typedef boost::shared_ptr<trellis_permutation> trellis_permutation_sptr;
+
+trellis_permutation_sptr trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES);
+
+/*!
+ * \brief Permutation.
+ * \ingroup block
+ *
+ *
+ */
+class trellis_permutation : public gr_sync_block
+{
+private:
+ friend trellis_permutation_sptr trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES);
+ int d_K;
+ std::vector<int> d_TABLE;
+ size_t d_NBYTES;
+ trellis_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES);
+
+public:
+ int K () const { return d_K; }
+ const std::vector<int> & TABLE () const { return d_TABLE; }
+ size_t NBYTES () const { return d_NBYTES; }
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(trellis,permutation);
+
+trellis_permutation_sptr trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES);
+
+class trellis_permutation : public gr_sync_block
+{
+private:
+ int d_K;
+ std::vector<int> d_TABLE;
+ size_t d_NBYTES;
+ trellis_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES);
+
+public:
+ int K () const { return d_K; }
+ const std::vector<int> & TABLE () const { return d_TABLE; }
+ size_t NBYTES () const { return d_NBYTES; }
+};
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {
minm=INF;
minmi=0;
for(int i=0;i<S;i++)
- if((mm=trace[(K-1)*S+i])<minm) minm=mm,minmi=i;
+ if((mm=alpha[alphai*S+i])<minm) minm=mm,minmi=i;
st=minmi;
}
else {