IT++ Logo
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | Related Functions | List of all members
itpp::Punctured_Turbo_Codec Class Reference

Punctured turbo encoder/decoder Class. More...

#include <itpp/comm/turbo.h>

Inheritance diagram for itpp::Punctured_Turbo_Codec:
itpp::Turbo_Codec

Public Member Functions

 Punctured_Turbo_Codec (void)
 Class constructor.
 
virtual ~Punctured_Turbo_Codec (void)
 Class destructor.
 
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())
 Set parameters for the punctured turbo encoder/decoder.
 
void set_puncture_matrix (const bmat &pmatrix)
 Sets puncturing matrix for turbo code (size n_tot * Period)
 
bmat get_puncture_matrix (void)
 Returns puncturing matrix.
 
int get_puncture_period (void)
 Returns Period (number of columns) of the puncturing matrix.
 
int get_punctured_size (void)
 Returns size of a single punctured block.
 
double get_rate (bool nominal=true)
 Returns rate of the turbo code.
 
int get_coded_size (void)
 Returns size of a single block prior to the puncturing.
 
void encode (const bvec &input, bvec &output)
 Encoder function.
 
bvec encode (const bvec &input)
 Encoder function returning vector.
 
virtual void decode (const vec &received_signal, bvec &decoded_bits, const bvec &true_bits="0")
 Decoder function.
 
virtual bvec decode (const vec &received_signal)
 Decoder function returning vector.
 
virtual void decode (const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations, const bvec &true_bits="0")
 Decoder function.
 
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())
 Set parameters for the turbo encoder/decoder.
 
void set_interleaver (const ivec &interleaver_sequence)
 Set a new internal interleaver sequence for the turbo encoder/decoder.
 
void set_metric (std::string in_metric="LOGMAX", double in_logmax_scale_factor=1.0, LLR_calc_unit lcalc=LLR_calc_unit())
 Set the decoder metric.
 
void set_iterations (int in_iterations=8)
 Sets the number of decoding iterations. Default value is 8.
 
void set_adaptive_stop (bool in_adaptive_stop=true)
 Use and adaptive number of iterations.
 
void set_awgn_channel_parameters (double in_Ec, double in_N0)
 Set parameters for decoding on an AWGN channel.
 
void set_scaling_factor (double in_Lc)
 Set scaling factor for decoding on e.g. Rayleigh fading channels.
 
void encode_block (const bvec &input, bvec &in1, bvec &in2, bmat &parity1, bmat &parity2)
 Encode a single block.
 
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")
 Decode a single block.
 
int get_Ncoded () const
 Get number of coded bits.
 
int get_Nuncoded () const
 Get number of uncoded bits.
 

Protected Member Functions

void calculate_punctured_size (void)
 Calculates length of the puncturing codeword.
 
void decode_n3 (const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations, const bvec &true_bits="0")
 Special decoder function for R = 1/3 i.e. two parity bits for each systematic bit.
 

Static Protected Member Functions

static std::string string_from_metric (const Metric &m)
 

Protected Attributes

int Period
 Number of columns in the puncturing matrix.
 
long pNcoded
 
int punct_total
 
int punct_total1
 
int punct_total2
 
double rate
 
bmat puncture_matrix
 
int interleaver_size
 
int Ncoded
 
int Nuncoded
 
int m_tail
 
int n1
 
int n2
 
int n_tot
 
int iterations
 
double Ec
 
double N0
 
double Lc
 
double R
 
double logmax_scale_factor
 
bool adaptive_stop
 
Metric metric
 
bvec decoded_bits_previous_iteration
 
Rec_Syst_Conv_Code rscc1
 
Rec_Syst_Conv_Code rscc2
 
Sequence_Interleaver< binbit_interleaver
 
Sequence_Interleaver< double > float_interleaver
 

Friends

int calculate_uncoded_size (Punctured_Turbo_Codec &tc, int punctured_size, int &fill_bits)
 Calculates length of uncoded block.
 

Related Functions

(Note that these are not member functions.)

ITPP_EXPORT ivec wcdma_turbo_interleaver_sequence (int interleaver_size)
 Generates the interleaver sequence for the internal turbo encoder interleaver used in WCDMA.
 
ITPP_EXPORT ivec lte_turbo_interleaver_sequence (int interleaver_size)
 Generates the interleaver sequence for the internal turbo encoder interleaver used in LTE.
 

Detailed Description

Punctured turbo encoder/decoder Class.

Author
Zbigniew Dlugaszewski

To set up the turbo encoder rate 1/2 with random interleaver the following code can be used:

ivec gen(2);
gen(0) = 013; gen(1) = 015;
int constraint_length = 4;
int block_length = 400;
turbo.set_parameters(gen, gen, constraint_length, block_length);
bmat puncture_matrix = "1 1;1 0;0 1";
turbo.set_puncture_matrix(puncture_matrix);

Definition at line 331 of file turbo.h.

Member Function Documentation

void itpp::Punctured_Turbo_Codec::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() 
)

Set parameters for the punctured turbo encoder/decoder.

the same parameters as with Turbo_Codec :

Parameters
gen1A vector with n1 elements containing the generator polynomials for the first constituent encoder
gen2A vector with n2 elements containing the generator polynomials for the second constituent encoder
constraint_lengthThe constraint length of the two constituent encoders
interleaver_sequenceAn ivec defining the internal turbo interleaver.
in_iterationsThe number of decoding iterations. Default value is 8.
in_metricDetermines the decoder metric: "MAP", LOGMAP", "LOGMAX", or "TABLE". The default is "LOGMAX".
in_logmax_scale_factorThe extrinsic information from each constituent decoder is to optimistic when LOGMAX decoding is used. This parameter allows for a down-scaling of the extrinsic information that will be passed on to the next decoder. The default value is 1.0. This parameter is ignored for other metrics than "LOGMAX".
in_adaptive_stopIf this parameter is true, then the iterations will stop if the decoding results after one full iteration equals the previous iteration. Default value is false.
lcalcThis parameter can be used to provide a specific LLR_calc_unit which defines the resolution in the table-lookup if decoding with the metric "TABLE" is used.

additionally:

Parameters
pmatrixPuncturing matrix containing "1" for transmitted bits and "0" for punctured ones with n_tot rows and Period columns.
Note
For issues relating to the accuracy of LLR computations, please see the documentation of LLR_calc_unit

Definition at line 631 of file turbo.cpp.

References itpp::Turbo_Codec::set_parameters(), and set_puncture_matrix().

void itpp::Punctured_Turbo_Codec::set_puncture_matrix ( const bmat pmatrix)

Sets puncturing matrix for turbo code (size n_tot * Period)

Parameters
pmatrixPuncturing matrix containing "1" for transmitted bits and "0" for punctured ones with n_tot rows and Period columns.

Definition at line 637 of file turbo.cpp.

References calculate_punctured_size(), it_error_if, and Period.

Referenced by set_parameters().

int itpp::Punctured_Turbo_Codec::get_punctured_size ( void  )
inline

Returns size of a single punctured block.

Returns size of a single encoded block after puncturing.

Definition at line 392 of file turbo.h.

References it_assert.

double itpp::Punctured_Turbo_Codec::get_rate ( bool  nominal = true)

Returns rate of the turbo code.

Parameters
nominalDetermines whether the function returns nominal code rate or the actual code rate (taking into account tail bits). Default value is true, i.e. nominal rate is returned.

Definition at line 674 of file turbo.cpp.

References Period.

int itpp::Punctured_Turbo_Codec::get_coded_size ( void  )
inline

Returns size of a single block prior to the puncturing.

Returns size of a single encoded block prior to the puncturing.

Definition at line 407 of file turbo.h.

void itpp::Punctured_Turbo_Codec::encode ( const bvec &  input,
bvec &  output 
)

Encoder function.

This function can encode (using function from the parent Turbo_Codec class) and puncture several consecutive coding blocks. Encoded bits are organized as follows:

\[ s(1), p_{1,1}(1), p_{1,2}(1), \ldots , p_{1,n_1}(1), p_{2,1}(1), p_{2,2}(1), \ldots , p_{2,n_2}(1), s(2), \ldots \]

In the above expression $s(n)$ is the n-th systematic bit and $p_{l,k}(n)$ is the n-th bit from the k-th encoder polynom of the l-th constituent encoder. A tail of both systematic and parity bits is added after each coding block to force both encoder to the zero state. The tail of each encoder is structured as follows (using encoder one as an example):

\[ t_1(1), pt_{1,1}(1), pt_{1,2}(1), \ldots , pt_{1,n_1}(1), \ldots pt_{1,n_1}(m) \]

The tailbits from the first encoder are placed before the tailbits from the second encoder. Each encoded block is punctured (independenly from other blocks) according to the pncturing scheme given in the puncture_matrix

Parameters
inputThe input bits to the encoder. Must contain an integer number of code blocks
outputThe encoded bits including two tail, one from each constituent encoder, after each coding block.

Definition at line 702 of file turbo.cpp.

References itpp::Turbo_Codec::encode(), it_assert, and Period.

Referenced by encode().

bvec itpp::Punctured_Turbo_Codec::encode ( const bvec &  input)

Encoder function returning vector.

Parameters
inputThe input bits to the encoder. Must contain an integer number of code blocks

The same function as above but has only one parameter input and returns a vector containing encoded bits.

Definition at line 686 of file turbo.cpp.

References encode().

void itpp::Punctured_Turbo_Codec::decode ( const vec &  received_signal,
bvec &  decoded_bits,
const bvec &  true_bits = "0" 
)
virtual

Decoder function.

This function can decode several consecutive coding blocks that were encoded with the encode member function

Parameters
received_signalThe vector of received bits
decoded_bitsA vector of decoded bits
true_bitsIf this input vector is provided then the iterations will stop as soon as the decoded bits equals the true_bits. Note that this feature can not be used if the in_adaptive_stop parameter in the setup function is set to true.

Reimplemented from itpp::Turbo_Codec.

Definition at line 832 of file turbo.cpp.

Referenced by decode().

bvec itpp::Punctured_Turbo_Codec::decode ( const vec &  received_signal)
virtual

Decoder function returning vector.

This function can decode several consecutive coding blocks that were encoded with the encode member function

Parameters
received_signalThe vector of received bits

Function returns decoded bits.

Definition at line 694 of file turbo.cpp.

References decode().

void itpp::Punctured_Turbo_Codec::decode ( const vec &  received_signal,
bvec &  decoded_bits,
ivec &  nrof_used_iterations,
const bvec &  true_bits = "0" 
)
virtual

Decoder function.

This function can decode several consecutive coding blocks that were encoded with the encode member function

Parameters
received_signalThe vector of received bits
decoded_bitsA vector of decoded bits
nrof_used_iterationsReturns the number of used iterations for each code block.
true_bitsIf this input vector is provided then the iterations will stop as soon as the decoded bits equals the true_bits. Note that this feature can not be used if the in_adaptive_stop parameter in the setup function is set to true.

Reimplemented from itpp::Turbo_Codec.

Definition at line 762 of file turbo.cpp.

References itpp::Turbo_Codec::decode(), it_assert, and Period.

void itpp::Punctured_Turbo_Codec::calculate_punctured_size ( void  )
protected

Calculates length of the puncturing codeword.

Calculates length of punctured encoded block based on a puncture_matrix and length of the input block (size of the turbo code interleaver)

Definition at line 838 of file turbo.cpp.

References Period.

Referenced by set_puncture_matrix().

void itpp::Turbo_Codec::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() 
)
inherited

Set parameters for the turbo encoder/decoder.

Parameters
gen1A vector with n1 elements containing the generator polynomials for the first constituent encoder
gen2A vector with n2 elements containing the generator polynomials for the second constituent encoder
constraint_lengthThe constraint length of the two constituent encoders
interleaver_sequenceAn ivec defining the internal turbo interleaver.
in_iterationsThe number of decoding iterations. Default value is 8.
in_metricDetermines the decoder metric: "MAP", LOGMAP", "LOGMAX", or "TABLE". The default is "LOGMAX".
in_logmax_scale_factorThe extrinsic information from each constituent decoder is to optimistic when LOGMAX decoding is used. This parameter allows for a down-scaling of the extrinsic information that will be passed on to the next decoder. The default value is 1.0. This parameter is ignored for other metrics than "LOGMAX".
in_adaptive_stopIf this parameter is true, then the iterations will stop if the decoding results after one full iteration equals the previous iteration. Default value is false.
lcalcThis parameter can be used to provide a specific LLR_calc_unit which defines the resolution in the table-lookup if decoding with the metric "TABLE" is used.
Note
For issues relating to the accuracy of LLR computations, please see the documentation of LLR_calc_unit

Definition at line 55 of file turbo.cpp.

References it_assert, it_error, itpp::LOGMAP, itpp::Rec_Syst_Conv_Code::set_generator_polynomials(), itpp::Sequence_Interleaver< T >::set_interleaver_depth(), itpp::Sequence_Interleaver< T >::set_interleaver_sequence(), and itpp::Rec_Syst_Conv_Code::set_llrcalc().

Referenced by set_parameters().

void itpp::Turbo_Codec::set_interleaver ( const ivec &  interleaver_sequence)
inherited

Set a new internal interleaver sequence for the turbo encoder/decoder.

By changing the interleaver sequence it is possible to change the code word size of the turbo codec. Note that you still must use the set_parameters function first to set the other parameters of the turbo codec.

Definition at line 115 of file turbo.cpp.

References itpp::Sequence_Interleaver< T >::set_interleaver_depth(), and itpp::Sequence_Interleaver< T >::set_interleaver_sequence().

void itpp::Turbo_Codec::set_metric ( std::string  in_metric = "LOGMAX",
double  in_logmax_scale_factor = 1.0,
LLR_calc_unit  lcalc = LLR_calc_unit() 
)
inherited

Set the decoder metric.

Parameters
in_metricDetermines the decoder metric: "MAP", LOGMAP", "LOGMAX", or "TABLE". The default is "LOGMAX".
in_logmax_scale_factorThe extrinsic information from each constituent decoder is to optimistic when LOGMAX decoding is used. This parameter allows for a down-scaling of the extrinsic information that will be passed on to the next decoder. The default value is 1.0. This parameter is ignored for other metrics than "LOGMAX".
lcalcThis parameter can be used to provide a specific LLR_calc_unit which defines the resolution in the table-lookup if decoding with the metric "TABLE" is used.

Definition at line 130 of file turbo.cpp.

References it_error, itpp::LOGMAP, and itpp::Rec_Syst_Conv_Code::set_llrcalc().

void itpp::Turbo_Codec::set_adaptive_stop ( bool  in_adaptive_stop = true)
inherited

Use and adaptive number of iterations.

When the adaptive stop criterion is used the iterations will stop before the maximum number of iterations is executed if the decoding results after one full iteration equals the previous iteration. Default value is true.

Definition at line 160 of file turbo.cpp.

void itpp::Turbo_Codec::set_awgn_channel_parameters ( double  in_Ec,
double  in_N0 
)
inherited

Set parameters for decoding on an AWGN channel.

Parameters
in_EcThe received energy per channel symbol (i.e. per soft input bit)
in_N0The single sided spectral density of the AWGN noise

Definition at line 165 of file turbo.cpp.

References itpp::sqrt().

void itpp::Turbo_Codec::set_scaling_factor ( double  in_Lc)
inherited

Set scaling factor for decoding on e.g. Rayleigh fading channels.

Setting the correct value of the channel reliability function is important for MAP decoder algorithms. However, if the Log-MAX decoding algorithm is used, then the value of Lc is not important. Assuming that the received soft values $r_k$ from the channel equal

\[ r_k = h_k c_k + w_k \]

where $h_k$ is the (complex valued) channel gain, $c_k$ is the transmitted symbol equal to $\{-\sqrt{E_c},+\sqrt{E_c}\}$, and $w_k$ is the AWGN (complex valued) noise with total variance of the real plus imaginary part equal to $N_0$. The input to the turbo decoder shall then be

\[ z_k = \hat{h}_k^{*} r_k \]

where $\hat{h}_k^{*}$ is the conjugate of the channel estimate. Assuming that the channel estimate is perfect, the channel reliability factor shall be set to

\[ L_c = 4\sqrt{E_c} / {N_0} \]

Parameters
in_Lcthe channel reliability factor of the channel.

Definition at line 172 of file turbo.cpp.

void itpp::Turbo_Codec::encode_block ( const bvec &  input,
bvec &  in1,
bvec &  in2,
bmat parity1,
bmat parity2 
)
inherited

Encode a single block.

This function is useful if rate matching is to be applied after the turbo encoder. The size of in1 and in2 equals the size of input plus the tail bits. Tailbits are appended ate the end of in1 and in2. The number of rows in parity1 and parity2 equals the lengths of in1 and in2 respectively. The number of columns of parity1 and parity2 equals the number of parity bits from the first and the second constituent encoders respectively.

Parameters
inputThe input bits to the encoder. Must contain a single code block
in1The input bits to the first constituent encoder with a tail added at the end
in2The input bits to the second constituent encoder (i.e. the interleaved data bits) with a tail added at the end
parity1The parity bits from the first constituent encoder (including parity bits for the first tail)
parity2The parity bits from the second constituent encoder (including parity bits for the second tail)

Definition at line 326 of file turbo.cpp.

References itpp::concat(), itpp::Rec_Syst_Conv_Code::encode_tail(), itpp::Sequence_Interleaver< T >::interleave(), and it_assert.

Referenced by itpp::Turbo_Codec::encode().

void itpp::Turbo_Codec::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" 
)
virtualinherited

Decode a single block.

This function can decode a single coding blocks that was encoded with the encode_block member function. In order to speed up the decoding process it is possible to input the correct data bits. If this information is provided the decoder can stop iterating as soon as the decoded bits match the correct data bits. This simulation trick can greatly speed up the simulation time for high SNR cases when only a few iterations are required. If errors still exist after the maximum number of iterations have been performed, the decoding process stops.

The matrix decoded_bits_i contains the result from decoding iteration i on row i. Even though both rec_syst1 and rec_syst2 are given as inputs, the systematic bits in rec_syst2 will in most cases be punctured and only the tailbits at the end of the vector rec_syst2 will have values different from zero.

Note
This decoding function assumes that the input is scaled as +-2*SNR + noise. This means that the channel reliability factor Lc must be equal to 1.0. No additional scaling is performed by this function.
Parameters
rec_syst1The received input bits to the first constituent decoder with a tail added at the end
rec_syst2The received input bits to the second constituent decoder with a tail added at the end
rec_parity1The received parity bits for the first constituent decoder (including parity bits for the first tail)
rec_parity2The received parity bits for the second constituent decoder (including parity bits for the second tail)
decoded_bits_iContains the result from decoding iteration i on row i.
nrof_used_iterations_iReturns the number of iterations used for decoding of this block.
true_bitsOptional input parameter. If given, the iterations will stop as soon as the decoded bits match the true bits.

Definition at line 361 of file turbo.cpp.

References itpp::concat(), itpp::Sequence_Interleaver< T >::deinterleave(), itpp::Sequence_Interleaver< T >::interleave(), it_assert, it_error, itpp::Vec< Num_T >::left(), itpp::Rec_Syst_Conv_Code::log_decode(), itpp::LOGMAP, itpp::Rec_Syst_Conv_Code::map_decode(), itpp::Vec< Num_T >::right(), and itpp::zeros().

Referenced by itpp::Turbo_Codec::decode().

Friends And Related Function Documentation

int calculate_uncoded_size ( Punctured_Turbo_Codec tc,
int  punctured_size,
int &  fill_bits 
)
friend

Calculates length of uncoded block.

Calculates length of the turbo code input block required to produce output block of length punctured_size. Some puncturing patterns might not allow to create block with such a length and then fill_bits of dummy bits must be used.

Parameters
tcInstance of Punctured_Turbo_Codec
punctured_sizeRequired size of punctured encoded block
fill_bitsNumber of dummy bits that must be attached to the encoded block (parameter calculated within the function)

Definition at line 874 of file turbo.cpp.

ITPP_EXPORT ivec lte_turbo_interleaver_sequence ( int  interleaver_size)
related

Generates the interleaver sequence for the internal turbo encoder interleaver used in LTE.

Author
qdelfin and Stephan Ludwig

Definition at line 1135 of file turbo.cpp.


The documentation for this class was generated from the following files:
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:33 for IT++ by Doxygen 1.8.2