GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
puncture_bb.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_FEC_PUNCTURE_BB_H
12 #define INCLUDED_FEC_PUNCTURE_BB_H
13 
14 #include <gnuradio/block.h>
15 #include <gnuradio/fec/api.h>
16 
17 namespace gr {
18 namespace fec {
19 
20 /*!
21  * \brief Puncture a stream of unpacked bits.
22  * \ingroup error_coding_blk
23  *
24  * \details
25  * Puncture a given block of input samples of \p puncsize. The
26  * items produced is based on pattern \p puncpat. Basically, if:
27  *
28  * \code
29  * k = 0
30  * if _puncpat[i] == 1:
31  * out[k++] = input[i]
32  * \endcode
33  *
34  * This block is designed for unpacked bits - that is, every
35  * input sample is a bit, either a 1 or 0. It's possible to use
36  * packed bits as symbols, but the puncturing will be done on
37  * the symbol level, not the bit level.
38  *
39  * \p puncpat is specified as a 32-bit integer that we can
40  * convert into the vector _puncpat used in the algorithm above:
41  *
42  * \code
43  * _puncpat = [0,...]
44  * for i in puncsize:
45  * _puncpat[i] = puncpat >> (puncsize-1-i)
46  * \endcode
47  *
48  * Example:
49  * \code
50  * puncsize = 8
51  * puncpat = 0xEF --> [1,1,1,0,1,1,1,1]
52  * input = [a, b, c, d, e, f, g, h]
53  * output = [a, b, c, e, f, g, h]
54  * \endcode
55  *
56  * The gr.fec Python module provides a read_bitlist function
57  * that can turn a string of a puncture pattern into the correct
58  * integer form. The pattern of 0xEF could be specified as
59  * fec.readbitlist("11101111"). Also, this allows us to use
60  * puncsize=len("11101111") to make sure that our sizes are set
61  * up correctly for the pattern we want.
62  *
63  * The fec.extended_encoder takes in the puncture pattern
64  * directly as a string and uses the readbitlist inside to do
65  * the conversion.
66  *
67  * Note that due to the above concept, the default setting in the
68  * extended encoder of '11' translates into no puncturing.
69  *
70  * The \p delay parameter delays the application of the puncture
71  * pattern. This is equivalent to circularly rotating the \p
72  * puncpat by \p delay. Note that because of the circular shift,
73  * the delay should be between 0 and \p puncsize, but this is
74  * not enforced; the effective delay will simply be \p delay mod
75  * \p puncsize. A negative value here is ignored.
76  */
77 class FEC_API puncture_bb : virtual public block
78 {
79 public:
80  // gr::fec::puncture_bb::sptr
81  typedef std::shared_ptr<puncture_bb> sptr;
82 
83  /*!
84  * \brief Constructs a puncture block for unpacked bits.
85  *
86  * \param puncsize Size of block of bits to puncture
87  * \param puncpat The puncturing pattern
88  * \param delay Delayed the puncturing pattern by shifting it
89  */
90  static sptr make(int puncsize, int puncpat, int delay = 0);
91 };
92 
93 } /* namespace fec */
94 } /* namespace gr */
95 
96 #endif /* INCLUDED_FEC_PUNCTURE_BB_H */
The abstract base class for all 'terminal' processing blocks.
Definition: gnuradio-runtime/include/gnuradio/block.h:63
Puncture a stream of unpacked bits.
Definition: puncture_bb.h:78
static sptr make(int puncsize, int puncpat, int delay=0)
Constructs a puncture block for unpacked bits.
std::shared_ptr< puncture_bb > sptr
Definition: puncture_bb.h:81
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29