turbo.h
Go to the documentation of this file.
#ifndef TURBO_H
#define TURBO_H
#include <itpp/comm/rec_syst_conv_code.h>
#include <itpp/comm/interleave.h>
#include <itpp/comm/llr.h>
#include <itpp/itexports.h>
namespace itpp
{
#if (defined(_MSC_VER) && defined (ITPP_SHARED_LIB))
//MSVC explicitely instantiate required template while building the shared library
template class ITPP_EXPORT Sequence_Interleaver<bin>;
template class ITPP_EXPORT Sequence_Interleaver<double>;
#endif
class ITPP_EXPORT Turbo_Codec
{
public:
Turbo_Codec(void) {}
virtual ~Turbo_Codec(void) {}
void set_parameters(ivec gen1, ivec gen2, int constraint_length,
const ivec &interleaver_sequence, int in_iterations = 8,
const std::string &in_metric = "LOGMAX", double in_logmax_scale_factor = 1.0,
bool in_adaptive_stop = false, LLR_calc_unit lcalc = LLR_calc_unit());
void set_interleaver(const ivec &interleaver_sequence);
void set_metric(std::string in_metric = "LOGMAX", double in_logmax_scale_factor = 1.0,
LLR_calc_unit lcalc = LLR_calc_unit());
void set_iterations(int in_iterations = 8);
void set_adaptive_stop(bool in_adaptive_stop = true);
void set_awgn_channel_parameters(double in_Ec, double in_N0);
void set_scaling_factor(double in_Lc);
void encode(const bvec &input, bvec &output);
virtual void decode(const vec &received_signal, bvec &decoded_bits, const bvec &true_bits = "0");
virtual void decode(const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations,
const bvec &true_bits = "0");
void encode_block(const bvec &input, bvec &in1, bvec &in2, bmat &parity1, bmat &parity2);
virtual void decode_block(const vec &rec_syst1, const vec &rec_syst2, const mat &rec_parity1, const mat &rec_parity2,
bmat &decoded_bits_i, int &nrof_used_iterations_i, const bvec &true_bits = "0");
int get_Ncoded() const { return Ncoded; }
int get_Nuncoded() const { return Nuncoded; }
protected:
void decode_n3(const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations,
const bvec &true_bits = "0");
//Scalars:
int interleaver_size;
int Ncoded, Nuncoded;
int m_tail, n1, n2, n_tot, iterations;
double Ec, N0, Lc, R, logmax_scale_factor;
bool adaptive_stop;
struct ITPP_EXPORT Metric
{
enum Type {Unknown, LOGMAX, LOGMAP, MAP, TABLE};
Metric() : _t(Unknown) {}
Metric(Type t) : _t(t) {}
operator Type () const {return _t;}
private:
Type _t;
template<typename T> operator T () const;
};
Metric metric;
//Vectors:
bvec decoded_bits_previous_iteration;
//Classes:
Rec_Syst_Conv_Code rscc1, rscc2;
Sequence_Interleaver<bin> bit_interleaver;
Sequence_Interleaver<double> float_interleaver;
static std::string string_from_metric(const Metric& m);
};
class ITPP_EXPORT Punctured_Turbo_Codec : public Turbo_Codec
{
public:
Punctured_Turbo_Codec(void) { Period = 0; };
virtual ~Punctured_Turbo_Codec(void) {}
void set_parameters(ivec gen1, ivec gen2, int constraint_length, const ivec &interleaver_sequence, bmat &pmatrix, int in_iterations = 8, std::string in_metric = "LOGMAX", double in_logmax_scale_factor = 1.0, bool in_adaptive_stop = false, itpp::LLR_calc_unit lcalc = itpp::LLR_calc_unit());
void set_puncture_matrix(const bmat &pmatrix);
bmat get_puncture_matrix(void) { return puncture_matrix; };
int get_puncture_period(void) { return Period; };
int get_punctured_size(void) { it_assert(Period != 0, "Punctured_Turbo_Codec: puncture matrix is not set"); return pNcoded; };
double get_rate(bool nominal = true);
int get_coded_size(void) { return Ncoded; };
void encode(const bvec &input, bvec &output);
bvec encode(const bvec &input);
virtual void decode(const vec &received_signal, bvec &decoded_bits, const bvec &true_bits = "0");
virtual bvec decode(const vec &received_signal);
virtual void decode(const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations,
const bvec &true_bits = "0");
friend int calculate_uncoded_size(Punctured_Turbo_Codec &tc, int punctured_size, int &fill_bits);
protected:
void calculate_punctured_size(void);
//Scalars:
int Period;
long pNcoded;
int punct_total, punct_total1, punct_total2;
double rate;
bmat puncture_matrix;
};
ITPP_EXPORT ivec wcdma_turbo_interleaver_sequence(int interleaver_size);
ITPP_EXPORT ivec lte_turbo_interleaver_sequence(int interleaver_size);
} // namespace itpp
#endif // #ifndef TURBO_H
itpp::Punctured_Turbo_Codec::get_puncture_period
int get_puncture_period(void)
Returns Period (number of columns) of the puncturing matrix.
Definition: turbo.h:385
itpp::Turbo_Codec::get_Ncoded
int get_Ncoded() const
Get number of coded bits.
Definition: turbo.h:272
itpp::Turbo_Codec
Turbo encoder/decoder Class.
Definition: turbo.h:66
interleave.h
Definitions of interleaver classes.
itpp::Punctured_Turbo_Codec::Punctured_Turbo_Codec
Punctured_Turbo_Codec(void)
Class constructor.
Definition: turbo.h:336
itpp::Punctured_Turbo_Codec::get_coded_size
int get_coded_size(void)
Returns size of a single block prior to the puncturing.
Definition: turbo.h:407
bmat
Mat< bin > bmat
bin matrix
Definition: mat.h:508
itpp::Turbo_Codec::get_Nuncoded
int get_Nuncoded() const
Get number of uncoded bits.
Definition: turbo.h:275
itpp::Punctured_Turbo_Codec::~Punctured_Turbo_Codec
virtual ~Punctured_Turbo_Codec(void)
Class destructor.
Definition: turbo.h:339
itpp
itpp namespace
Definition: itmex.h:36
itpp::lte_turbo_interleaver_sequence
ivec lte_turbo_interleaver_sequence(int interleaver_size)
Generates the interleaver sequence for the internal turbo encoder interleaver used in LTE.
Definition: turbo.cpp:1135
llr.h
Class for numerically efficient log-likelihood algebra.
itpp::Punctured_Turbo_Codec
Punctured turbo encoder/decoder Class.
Definition: turbo.h:331
itpp::Punctured_Turbo_Codec::get_punctured_size
int get_punctured_size(void)
Returns size of a single punctured block.
Definition: turbo.h:392
itpp::LLR_calc_unit
Log-likelihood algebra calculation unit.
Definition: llr.h:124
itpp::wcdma_turbo_interleaver_sequence
ivec wcdma_turbo_interleaver_sequence(int interleaver_size)
Generates the interleaver sequence for the internal turbo encoder interleaver used in WCDMA.
Definition: turbo.cpp:933
rec_syst_conv_code.h
Definitions of a Recursive Systematic Convolutional codec class.
itpp::Turbo_Codec::Turbo_Codec
Turbo_Codec(void)
Class constructor.
Definition: turbo.h:71
itpp::LOGMAP
@ LOGMAP
Log-MAP full calculation.
Definition: modulator.h:48
itpp::Turbo_Codec::~Turbo_Codec
virtual ~Turbo_Codec(void)
Class destructor.
Definition: turbo.h:74
itpp::Punctured_Turbo_Codec::Period
int Period
Number of columns in the puncturing matrix.
Definition: turbo.h:505
itpp::calculate_uncoded_size
int calculate_uncoded_size(Punctured_Turbo_Codec &tc, int punctured_size, int &fill_bits)
Definition: turbo.cpp:874
itpp::Punctured_Turbo_Codec::get_puncture_matrix
bmat get_puncture_matrix(void)
Returns puncturing matrix.
Definition: turbo.h:380
it_assert
#define it_assert(t, s)
Abort if t is not true.
Definition: itassert.h:94

Generated on Mon Mar 23 2020 06:18:03 for IT++ by Doxygen 1.8.17