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