GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
tpc_decoder.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 #ifndef INCLUDED_TPC_DECODER_H
12 #define INCLUDED_TPC_DECODER_H
13 
14 typedef float INPUT_DATATYPE;
15 typedef unsigned char OUTPUT_DATATYPE;
16 
17 #include <gnuradio/fec/decoder.h>
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 namespace gr {
23 namespace fec {
24 
25 
26 #define MAXLOG 1e7
27 
29 {
30  // private constructor
31  tpc_decoder(std::vector<int> row_polys,
32  std::vector<int> col_polys,
33  int krow,
34  int kcol,
35  int bval,
36  int qval,
37  int max_iter,
38  int decoder_type);
39 
40  // plug into the generic fec api
41  int get_history() override;
42  float get_shift() override;
43  int get_input_item_size() override;
44  int get_output_item_size() override;
45  const char* get_conversion();
46  void generic_work(void* inBuffer, void* outbuffer) override;
47  int get_output_size() override;
48  int get_input_size() override;
49 
50  std::vector<int> d_rowpolys;
51  std::vector<int> d_colpolys;
52 
53  unsigned int d_krow;
54  unsigned int d_kcol;
55 
56  int d_bval;
57  int d_qval;
58 
59  int d_max_iter;
60  int d_decoder_type;
61 
62  // store the state transitions & outputs
63  int rowNumStates;
64  std::vector<std::vector<int>> rowOutputs;
65  std::vector<std::vector<int>> rowNextStates;
66  int colNumStates;
67  std::vector<std::vector<int>> colOutputs;
68  std::vector<std::vector<int>> colNextStates;
69 
70  int rowEncoder_K;
71  int rowEncoder_n;
72  int rowEncoder_m;
73  int colEncoder_K;
74  int colEncoder_n;
75  int colEncoder_m;
76  int outputSize;
77  int inputSize;
78 
79  uint32_t codeword_M;
80  uint32_t codeword_N;
81 
82  int mInit, nInit;
83 
84  // memory allocated for processing
85  int inputSizeWithPad;
86 
87  std::vector<std::vector<float>> channel_llr;
88  std::vector<std::vector<float>> Z;
89  std::vector<float> extrinsic_info;
90  std::vector<float> input_u_rows;
91  std::vector<float> input_u_cols;
92  std::vector<float> input_c_rows;
93  std::vector<float> input_c_cols;
94  std::vector<float> output_u_rows;
95  std::vector<float> output_u_cols;
96  std::vector<float> output_c_rows;
97  std::vector<float> output_c_cols;
98 
99  uint32_t numInitLoadIter;
100  int numInitRemaining;
101  int output_c_col_idx;
102 
103  bool earlyExit;
104 
105  FILE* fp;
106 
107  // soft input soft output decoding
108  int mm_row, max_states_row, num_symbols_row;
109  std::vector<std::vector<float>> beta_row;
110  std::vector<float> alpha_prime_row;
111  std::vector<float> alpha_row;
112  std::vector<float> metric_c_row;
113  std::vector<float> rec_array_row;
114  std::vector<float> num_llr_c_row;
115  std::vector<float> den_llr_c_row;
116  void siso_decode_row();
117 
118  int mm_col, max_states_col, num_symbols_col;
119  std::vector<std::vector<float>> beta_col;
120  std::vector<float> alpha_prime_col;
121  std::vector<float> alpha_col;
122  std::vector<float> metric_c_col;
123  std::vector<float> rec_array_col;
124  std::vector<float> num_llr_c_col;
125  std::vector<float> den_llr_c_col;
126  void siso_decode_col();
127 
128  // Computes the branch metric used for decoding, returning a metric between the
129  // hypothetical symbol and received vector
130  float gamma(const std::vector<float> rec_array, const int symbol);
131 
132  float (tpc_decoder::*max_star)(const float, const float);
133 
134  float linear_log_map(const float delta1, const float delta2);
135  float max_log_map(const float delta1, const float delta2);
136  float constant_log_map(const float delta1, const float delta2);
137  float log_map_lut_correction(const float delta1, const float delta2);
138  float log_map_cfunction_correction(const float delta1, const float delta2);
139 
140  template <typename T>
141  static int sgn(T val);
142 
143 public:
144  static generic_decoder::sptr make(std::vector<int> row_poly,
145  std::vector<int> col_poly,
146  int krow,
147  int kcol,
148  int bval,
149  int qval,
150  int max_iter,
151  int decoder_type);
152  ~tpc_decoder() override;
153  double rate() override { return (1.0 * get_output_size() / get_input_size()); }
154  bool set_frame_size(unsigned int frame_size) override { return false; }
155 };
156 
157 } // namespace fec
158 } // namespace gr
159 
160 #endif /* INCLUDED_TPC_DECODER_H */
Parent class for FECAPI objects.
Definition: generic_decoder.h:48
std::shared_ptr< generic_decoder > sptr
Definition: generic_decoder.h:62
Definition: tpc_decoder.h:29
static generic_decoder::sptr make(std::vector< int > row_poly, std::vector< int > col_poly, int krow, int kcol, int bval, int qval, int max_iter, int decoder_type)
~tpc_decoder() override
double rate() override
Definition: tpc_decoder.h:153
bool set_frame_size(unsigned int frame_size) override
Definition: tpc_decoder.h:154
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:18
FEC_API int get_history(generic_decoder::sptr my_decoder)
FEC_API float get_shift(generic_decoder::sptr my_decoder)
GNU Radio logging wrapper.
Definition: basic_block.h:29
float INPUT_DATATYPE
Definition: tpc_decoder.h:14
unsigned char OUTPUT_DATATYPE
Definition: tpc_decoder.h:15