GNU Radio Manual and C++ API Reference 3.7.14.0
The Free & Open Software Radio Ecosystem
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
27#include <assert.h>
28#include <vector>
29
30/*!
31 * \brief template class for generic convolutional interleaver
32 */
33
34template <class symbol_type>
36{
37public:
38 convolutional_interleaver(bool interleave_p, int nbanks, int fifo_size_incr);
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 /
48 //! deinterleaver)
50
51 //! transform a single symbol
52 symbol_type transform(symbol_type input)
53 {
54 symbol_type retval = m_fifo[m_commutator]->stuff(input);
57 m_commutator = 0;
58 return retval;
59 }
60
61 //! transform a bunch of symbols
62 void transform(symbol_type* out, const symbol_type* in, int nsymbols);
63
64protected:
68 std::vector<interleaver_fifo<symbol_type>*> m_fifo;
69};
70
71template <class symbol_type>
73 int nbanks,
74 int fifo_size_incr)
75{
76 assert(nbanks >= 1);
77 assert(fifo_size_incr >= 1);
78
79 m_nbanks = nbanks;
80 m_fifo_size_incr = fifo_size_incr;
81
82 m_fifo.resize(nbanks);
83
84 if (interleave_p) { // configure as interleaver
85 for (int i = 0; i < nbanks; i++)
86 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] =
90 new interleaver_fifo<symbol_type>(i * fifo_size_incr);
91 }
92 sync();
93}
94
95template <class symbol_type>
97{
98 for (int i = 0; i < m_nbanks; i++)
99 delete m_fifo[i];
100}
101
102template <class symbol_type>
104{
105 sync();
106 for (int i = 0; i < m_nbanks; i++)
107 m_fifo[i]->reset();
108}
109
110template <class symbol_type>
112{
113 int m = m_nbanks * m_fifo_size_incr;
114 return m * (m_nbanks - 1);
115}
116
117template <class symbol_type>
119 const symbol_type* in,
120 int nsymbols)
121{
122 // we may want to unroll this a couple of times...
123 for (int i = 0; i < nsymbols; i++)
124 out[i] = transform(in[i]);
125}
126
127#endif /* _CONVOLUTIONAL_INTERLEAVER_H_ */
template class for generic convolutional interleaver
Definition: convolutional_interleaver.h:36
int m_commutator
Definition: convolutional_interleaver.h:65
int m_nbanks
Definition: convolutional_interleaver.h:66
virtual ~convolutional_interleaver()
Definition: convolutional_interleaver.h:96
int m_fifo_size_incr
Definition: convolutional_interleaver.h:67
void reset()
reset interleaver (flushes contents and resets commutator)
Definition: convolutional_interleaver.h:103
int end_to_end_delay()
return end to end delay in symbols (delay through concatenated interleaver / deinterleaver)
Definition: convolutional_interleaver.h:111
std::vector< interleaver_fifo< symbol_type > * > m_fifo
Definition: convolutional_interleaver.h:68
convolutional_interleaver(bool interleave_p, int nbanks, int fifo_size_incr)
Definition: convolutional_interleaver.h:72
void sync()
sync interleaver (resets commutator, but doesn't flush fifos)
Definition: convolutional_interleaver.h:45
symbol_type transform(symbol_type input)
transform a single symbol
Definition: convolutional_interleaver.h:52
void transform(symbol_type *out, const symbol_type *in, int nsymbols)
transform a bunch of symbols
Definition: convolutional_interleaver.h:118
template class for interleaver fifo
Definition: interleaver_fifo.h:36