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_decoder_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_DECODER_COMMON_H
25 #define INCLUDED_FEC_POLAR_DECODER_COMMON_H
26 
27 #include <gnuradio/fec/api.h>
30 
31 #ifndef BOOST_CONSTEXPR_OR_CONST
32 #define BOOST_CONSTEXPR_OR_CONST const
33 #endif
34 
35 namespace gr {
36  namespace fec {
37  namespace code {
38 
39  /*!
40  * \brief Class holds common methods and attributes for different
41  * decoder implementations
42  */
44  {
45  public:
46  /*!
47  *
48  * \param block_size codeword size. MUST be a power of 2.
49  * \param num_info_bits represents the number of information bits
50  * in a block. Also called frame_size. <= block_size
51  * \param frozen_bit_positions is an integer vector which defines
52  * the position of all frozen bits in a block. Its size
53  * MUST be equal to block_size - num_info_bits. Also it
54  * must be sorted and every position must only occur once.
55  * \param frozen_bit_values holds an unpacked byte for every
56  * frozen bit position. It defines if a frozen bit is
57  * fixed to '0' or '1'. Defaults to all ZERO.
58  */
59  polar_decoder_common(int block_size, int num_info_bits,
60  std::vector<int> frozen_bit_positions,
61  std::vector<char> frozen_bit_values);
63 
64  // FECAPI
65  double rate(){return (1.0 * get_output_size() / get_input_size());};
66  int get_input_size(){return block_size();};
67  int get_output_size(){return num_info_bits();};
68  bool set_frame_size(unsigned int frame_size){return false;};
69 
70  private:
71  static BOOST_CONSTEXPR_OR_CONST float D_LLR_FACTOR = -2.19722458f;
72  unsigned int d_frozen_bit_counter;
73 
74  protected:
75  // calculate LLRs for stage
76  float llr_odd(const float la, const float lb) const;
77  float llr_even(const float la, const float lb, const unsigned char f) const;
78  unsigned char llr_bit_decision(const float llr) const {return (llr < 0.0f) ? 1 : 0;};
79 
80  // control retrieval of frozen bits.
81  const bool is_frozen_bit(const int u_num) const;
82  const unsigned char next_frozen_bit();
83 
84  // preparation for decoding
85  void initialize_decoder(unsigned char* u, float* llrs, const float* input);
86 
87  // basic algorithm methods
88  void butterfly(float* llrs, unsigned char* u, const int stage, const int u_num, const int row);
89  void butterfly_volk(float* llrs, unsigned char* u, const int stage, const int u_num, const int row);
90  void butterfly_generic(float* llrs, unsigned char* u, const int stage, const int u_num, const int row);
91  void even_u_values(unsigned char* u_even, const unsigned char* u, const int u_num);
92  void odd_xor_even_values(unsigned char* u_xor, const unsigned char* u, const int u_num);
93  void extract_info_bits(unsigned char* output, const unsigned char* input) const;
94 
95  // helper functions.
96  void print_pretty_llr_vector(const float* llr_vec) const;
97 
98  };
99 
100  } // namespace code
101  } // namespace fec
102 } // namespace gr
103 
104 #endif /* INCLUDED_FEC_POLAR_DECODER_COMMON_H */
int get_input_size()
Definition: polar_decoder_common.h:66
int get_output_size()
Definition: polar_decoder_common.h:67
Parent class for FECAPI objects.
Definition: generic_decoder.h:60
bool set_frame_size(unsigned int frame_size)
Definition: polar_decoder_common.h:68
Include this header to use the message passing features.
Definition: logger.h:131
Class holds common methods and attributes for different decoder implementations.
Definition: polar_decoder_common.h:43
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
double rate()
Definition: polar_decoder_common.h:65
#define BOOST_CONSTEXPR_OR_CONST
Definition: polar_decoder_common.h:32
unsigned char llr_bit_decision(const float llr) const
Definition: polar_decoder_common.h:78
POLAR code common operations and attributes.
Definition: polar_common.h:55