GNU Radio Manual and C++ API Reference  3.8.1.0
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,
56  int num_info_bits,
57  std::vector<int> frozen_bit_positions,
58  std::vector<char> frozen_bit_values);
60 
61  // FECAPI
62  double rate() { return (1.0 * get_output_size() / get_input_size()); };
63  int get_input_size() { return block_size(); };
64  int get_output_size() { return num_info_bits(); };
65  bool set_frame_size(unsigned int frame_size) { return false; };
66 
67 private:
68  static const float D_LLR_FACTOR;
69  unsigned int d_frozen_bit_counter;
70 
71 protected:
72  // calculate LLRs for stage
73  float llr_odd(const float la, const float lb) const;
74  float llr_even(const float la, const float lb, const unsigned char f) const;
75  unsigned char llr_bit_decision(const float llr) const
76  {
77  return (llr < 0.0f) ? 1 : 0;
78  };
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(
89  float* llrs, unsigned char* u, const int stage, const int u_num, const int row);
90  void butterfly_volk(
91  float* llrs, unsigned char* u, const int stage, const int u_num, const int row);
92  void butterfly_generic(
93  float* llrs, unsigned char* u, const int stage, const int u_num, const int row);
94  void even_u_values(unsigned char* u_even, const unsigned char* u, const int u_num);
95  void
96  odd_xor_even_values(unsigned char* u_xor, const unsigned char* u, const int u_num);
97  void extract_info_bits(unsigned char* output, const unsigned char* input) const;
98 
99  // helper functions.
100  void print_pretty_llr_vector(const float* llr_vec) const;
101 };
102 
103 } // namespace code
104 } // namespace fec
105 } // namespace gr
106 
107 #endif /* INCLUDED_FEC_POLAR_DECODER_COMMON_H */
unsigned char llr_bit_decision(const float llr) const
Definition: polar_decoder_common.h:75
int get_input_size()
Definition: polar_decoder_common.h:63
int get_output_size()
Definition: polar_decoder_common.h:64
Parent class for FECAPI objects.
Definition: generic_decoder.h:60
bool set_frame_size(unsigned int frame_size)
Definition: polar_decoder_common.h:65
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
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:62
POLAR code common operations and attributes.
Definition: polar_common.h:58