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