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
polar_common.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 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 
24 #ifndef INCLUDED_FEC_POLAR_COMMON_H
25 #define INCLUDED_FEC_POLAR_COMMON_H
26 
27 #include <gnuradio/fec/api.h>
28 
29 // Forward declaration for those objects. SWIG doesn't like them to be #include'd.
30 namespace gr {
31  namespace blocks {
32  namespace kernel {
33  class unpack_k_bits;
34  }
35  }
36 }
37 
38 namespace gr {
39  namespace fec {
40  namespace code {
41 
42  /*!
43  * \brief POLAR code common operations and attributes
44  * \ingroup error_coding_blk
45  *
46  * \details
47  * Polar codes are based on this paper by Erdal Arikan "Channel
48  * Polarization: A Method for Contructing Capacity-Achieving Codes
49  * for Symmetric Binary-Input Memoryless Channels", 2009 block
50  * holds common information for encoders and decoders. All polar
51  * encoder/decoders inherit from polar_common.
52  *
53  * class holds common info. It is common to all encoders and decoders.
54  */
56  {
57  public:
58  /*!
59  * \param block_size codeword size. MUST be a power of 2.
60  * \param num_info_bits represents the number of information
61  * bits in a block. Also called frame_size. <= block_size
62  * \param frozen_bit_positions is an integer vector which
63  * defines the position of all frozen bits in a block.
64  * Its size MUST be equal to block_size - num_info_bits.
65  * Also it must be sorted and every position must only
66  * occur once.
67  * \param frozen_bit_values holds an unpacked byte for every
68  * frozen bit position. It defines if a frozen bit is
69  * fixed to '0' or '1'. Defaults to all ZERO.
70  */
71  polar_common(int block_size, int num_info_bits,
72  std::vector<int> frozen_bit_positions,
73  std::vector<char> frozen_bit_values);
74  ~polar_common();
75 
76  protected:
77  const int block_size()const {return d_block_size;};
78  const int block_power()const {return d_block_power;};
79  const int num_info_bits() const {return d_num_info_bits;};
80 
81  // helper functions
82  long bit_reverse(long value, int active_bits) const;
83  void print_packed_bit_array(const unsigned char* printed_array,
84  const int num_bytes) const;
85  void print_unpacked_bit_array(const unsigned char* bits,
86  const unsigned int num_bytes) const;
87 
88  std::vector<int> d_frozen_bit_positions;
89  std::vector<char> d_frozen_bit_values;
90  std::vector<int> d_info_bit_positions;
92  void setup_info_bit_positions_reversed();
93 // std::vector<int> d_info_bit_positions_reversed;
94 
95 
96  // VOLK methods
97  void setup_volk_vectors();
98  void volk_encode(unsigned char* out_buf, const unsigned char* in_buf);
99  void volk_encode_block(unsigned char* out_buf, unsigned char* in_buf);
100  unsigned char* d_volk_temp;
101  unsigned char* d_volk_frozen_bit_mask;
102  unsigned char* d_volk_frozen_bits;
103 
104  private:
105  int d_block_size; // depending on paper called 'N' or 'm'
106  int d_block_power;
107  int d_num_info_bits; // mostly abbreviated by 'K'
108 
109  void initialize_info_bit_position_vector();
110 
111  gr::blocks::kernel::unpack_k_bits *d_unpacker; // convenience for 'print_packed_bit_array' function.
112  };
113 
114  } //namespace code
115  } // namespace fec
116 } // namespace gr
117 
118 #endif /* INCLUDED_FEC_POLAR_COMMON_H */
std::vector< int > d_info_bit_positions_reversed
Definition: polar_common.h:91
std::vector< int > d_info_bit_positions
Definition: polar_common.h:90
const int block_power() const
Definition: polar_common.h:78
unsigned char * d_volk_frozen_bits
Definition: polar_common.h:102
Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB.
Definition: unpack_k_bits.h:48
Include this header to use the message passing features.
Definition: logger.h:131
std::vector< char > d_frozen_bit_values
Definition: polar_common.h:89
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
const int num_info_bits() const
Definition: polar_common.h:79
const int block_size() const
Definition: polar_common.h:77
unsigned char * d_volk_temp
Definition: polar_common.h:100
POLAR code common operations and attributes.
Definition: polar_common.h:55
unsigned char * d_volk_frozen_bit_mask
Definition: polar_common.h:101
std::vector< int > d_frozen_bit_positions
Definition: polar_common.h:88