3 * Copyright 2002 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #ifndef _CONVOLUTIONAL_INTERLEAVER_H_
24 #define _CONVOLUTIONAL_INTERLEAVER_H_
27 #include <interleaver_fifo.h>
31 * \brief template class for generic convolutional interleaver
34 template<class symbol_type>
35 class convolutional_interleaver {
38 convolutional_interleaver (bool interleave_p, int nbanks, int fifo_size_incr);
39 virtual ~convolutional_interleaver ();
41 //! reset interleaver (flushes contents and resets commutator)
44 //! sync interleaver (resets commutator, but doesn't flush fifos)
45 void sync () { m_commutator = 0; }
47 //! return end to end delay in symbols (delay through concatenated interleaver / deinterleaver)
48 int end_to_end_delay ();
50 //! transform a single symbol
51 symbol_type transform (symbol_type input){
52 symbol_type retval = m_fifo[m_commutator]->stuff (input);
54 if (m_commutator >= m_nbanks)
59 //! transform a bunch of symbols
60 void transform (symbol_type *out, const symbol_type *in, int nsymbols);
66 std::vector<interleaver_fifo<symbol_type> *> m_fifo;
69 template<class symbol_type>
70 convolutional_interleaver<symbol_type>::convolutional_interleaver (
76 assert (fifo_size_incr >= 1);
79 m_fifo_size_incr = fifo_size_incr;
81 m_fifo.resize (nbanks);
83 if (interleave_p){ // configure as interleaver
84 for (int i = 0; i < nbanks; i++)
85 m_fifo[i] = new interleaver_fifo<symbol_type>(i * fifo_size_incr);
87 else { // configure as de-interleaver
88 for (int i = 0; i < nbanks; i++)
89 m_fifo[nbanks - 1 - i] = new interleaver_fifo<symbol_type>(i * fifo_size_incr);
94 template<class symbol_type>
95 convolutional_interleaver<symbol_type>::~convolutional_interleaver ()
97 for (int i = 0; i < m_nbanks; i++)
101 template<class symbol_type> void
102 convolutional_interleaver<symbol_type>::reset ()
105 for (int i = 0; i < m_nbanks; i++)
109 template<class symbol_type> int
110 convolutional_interleaver<symbol_type>::end_to_end_delay ()
112 int m = m_nbanks * m_fifo_size_incr;
113 return m * (m_nbanks - 1);
116 template<class symbol_type> void
117 convolutional_interleaver<symbol_type>::transform (symbol_type *out,
118 const symbol_type *in,
121 // we may want to unroll this a couple of times...
122 for (int i = 0; i < nsymbols; i++)
123 out[i] = transform (in[i]);
126 #endif /* _CONVOLUTIONAL_INTERLEAVER_H_ */