GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
convolutional_interleaver.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
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)
10  * any later version.
11  *
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.
16  *
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.
21  */
22 
23 #ifndef _CONVOLUTIONAL_INTERLEAVER_H_
24 #define _CONVOLUTIONAL_INTERLEAVER_H_
25 
26 #include <vector>
28 #include <assert.h>
29 
30 /*!
31  * \brief template class for generic convolutional interleaver
32  */
33 
34 template<class symbol_type>
36  public:
37 
38  convolutional_interleaver (bool interleave_p, int nbanks, int fifo_size_incr);
39  virtual ~convolutional_interleaver ();
40 
41  //! reset interleaver (flushes contents and resets commutator)
42  void reset ();
43 
44  //! sync interleaver (resets commutator, but doesn't flush fifos)
45  void sync () { m_commutator = 0; }
46 
47  //! return end to end delay in symbols (delay through concatenated interleaver / deinterleaver)
48  int end_to_end_delay ();
49 
50  //! transform a single symbol
51  symbol_type transform (symbol_type input){
52  symbol_type retval = m_fifo[m_commutator]->stuff (input);
53  m_commutator++;
54  if (m_commutator >= m_nbanks)
55  m_commutator = 0;
56  return retval;
57  }
58 
59  //! transform a bunch of symbols
60  void transform (symbol_type *out, const symbol_type *in, int nsymbols);
61 
62 protected:
64  int m_nbanks;
66  std::vector<interleaver_fifo<symbol_type> *> m_fifo;
67 };
68 
69 template<class symbol_type>
71  bool interleave_p,
72  int nbanks,
73  int fifo_size_incr)
74 {
75  assert (nbanks >= 1);
76  assert (fifo_size_incr >= 1);
77 
78  m_nbanks = nbanks;
79  m_fifo_size_incr = fifo_size_incr;
80 
81  m_fifo.resize (nbanks);
82 
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);
86  }
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);
90  }
91  sync ();
92 }
93 
94 template<class symbol_type>
96 {
97  for (int i = 0; i < m_nbanks; i++)
98  delete m_fifo[i];
99 }
100 
101 template<class symbol_type> void
103 {
104  sync ();
105  for (int i = 0; i < m_nbanks; i++)
106  m_fifo[i]->reset ();
107 }
108 
109 template<class symbol_type> int
111 {
112  int m = m_nbanks * m_fifo_size_incr;
113  return m * (m_nbanks - 1);
114 }
115 
116 template<class symbol_type> void
118  const symbol_type *in,
119  int nsymbols)
120 {
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]);
124 }
125 
126 #endif /* _CONVOLUTIONAL_INTERLEAVER_H_ */
int end_to_end_delay()
return end to end delay in symbols (delay through concatenated interleaver / deinterleaver) ...
Definition: convolutional_interleaver.h:110
template class for generic convolutional interleaver
Definition: convolutional_interleaver.h:35
int m_nbanks
Definition: convolutional_interleaver.h:64
template class for interleaver fifo
Definition: interleaver_fifo.h:35
void reset()
reset interleaver (flushes contents and resets commutator)
Definition: convolutional_interleaver.h:102
void sync()
sync interleaver (resets commutator, but doesn't flush fifos)
Definition: convolutional_interleaver.h:45
int m_fifo_size_incr
Definition: convolutional_interleaver.h:65
int m_commutator
Definition: convolutional_interleaver.h:63
convolutional_interleaver(bool interleave_p, int nbanks, int fifo_size_incr)
Definition: convolutional_interleaver.h:70
symbol_type transform(symbol_type input)
transform a single symbol
Definition: convolutional_interleaver.h:51
virtual ~convolutional_interleaver()
Definition: convolutional_interleaver.h:95
std::vector< interleaver_fifo< symbol_type > * > m_fifo
Definition: convolutional_interleaver.h:66