GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
polar_encoder.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_ENCODER_H
25#define INCLUDED_FEC_POLAR_ENCODER_H
26
27#include <gnuradio/fec/api.h>
30
31namespace gr {
32namespace fec {
33namespace code {
34
35/*!
36 * \brief POLAR encoder
37 * for basic details see 'polar_common' class.
38 * \ingroup error_coding_blk
39 *
40 * \details
41 * expects values with MSB first. It needs a full information word and encodes it in one
42 * pass. Output is a codeword of block_size.
43 */
45{
46public:
47 /*!
48 * Factory for a polar code encoder object.
49 *
50 * \param block_size defines the codeword size. It MUST be a
51 * power of 2.
52 * \param num_info_bits represents the number of information
53 * bits in a block. Also called frame_size.
54 * \param frozen_bit_positions is an integer vector which
55 * defines the position of all frozen bits in a block.
56 * Its size MUST be equal to block_size - num_info_bits.
57 * Also it must be sorted and every position must only
58 * occur once.
59 * \param frozen_bit_values holds an unpacked byte for every
60 * frozen bit position. It defines if a frozen bit is
61 * fixed to '0' or '1'. Defaults to all ZERO.
62 * \param is_packed choose 1 active bit/byte or 8 active
63 * bit/byte. if false, VOLK polar encoder is used.
64 */
65 static generic_encoder::sptr make(int block_size,
66 int num_info_bits,
67 std::vector<int> frozen_bit_positions,
68 std::vector<char> frozen_bit_values,
69 bool is_packed = false);
71
72 // FECAPI
73 void generic_work(void* in_buffer, void* out_buffer);
74 double rate() { return (1.0 * get_input_size() / get_output_size()); };
75 int get_input_size() { return num_info_bits() / (d_is_packed ? 8 : 1); };
76 int get_output_size() { return block_size() / (d_is_packed ? 8 : 1); };
77 bool set_frame_size(unsigned int frame_size) { return false; };
78 const char* get_input_conversion() { return d_is_packed ? "pack" : "none"; };
79 const char* get_output_conversion() { return d_is_packed ? "packed_bits" : "none"; };
80
81private:
82 polar_encoder(int block_size,
83 int num_info_bits,
84 std::vector<int>& frozen_bit_positions,
85 std::vector<char>& frozen_bit_values,
86 bool is_packed);
87 bool d_is_packed;
88
89 // c'tor method for packed algorithm setup.
90 void setup_frozen_bit_inserter();
91
92 // methods insert input bits and frozen bits into packed array for encoding
93 unsigned char* d_frozen_bit_prototype; // packed frozen bits are written onto it and
94 // later copies are used.
95 void insert_packed_frozen_bits_and_reverse(unsigned char* target,
96 const unsigned char* input) const;
97 void insert_unpacked_bit_into_packed_array_at_position(unsigned char* target,
98 const unsigned char bit,
99 const int pos) const;
100 void insert_packet_bit_into_packed_array_at_position(unsigned char* target,
101 const unsigned char bit,
102 const int target_pos,
103 const int bit_pos) const;
104
105 // packed encoding methods
106 void encode_vector_packed(unsigned char* target) const;
107 void encode_vector_packed_subbyte(unsigned char* target) const;
108 void encode_packed_byte(unsigned char* target) const;
109 void encode_vector_packed_interbyte(unsigned char* target) const;
110};
111
112} // namespace code
113} // namespace fec
114} // namespace gr
115
116#endif /* INCLUDED_FEC_POLAR_ENCODER_H */
POLAR code common operations and attributes.
Definition polar_common.h:59
POLAR encoder for basic details see 'polar_common' class.
Definition polar_encoder.h:45
bool set_frame_size(unsigned int frame_size)
Definition polar_encoder.h:77
const char * get_input_conversion()
Definition polar_encoder.h:78
int get_output_size()
Definition polar_encoder.h:76
const char * get_output_conversion()
Definition polar_encoder.h:79
void generic_work(void *in_buffer, void *out_buffer)
double rate()
Definition polar_encoder.h:74
static generic_encoder::sptr make(int block_size, int num_info_bits, std::vector< int > frozen_bit_positions, std::vector< char > frozen_bit_values, bool is_packed=false)
int get_input_size()
Definition polar_encoder.h:75
Definition generic_encoder.h:35
boost::shared_ptr< generic_encoder > sptr
Definition generic_encoder.h:49
#define FEC_API
Definition gr-fec/include/gnuradio/fec/api.h:30
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46