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