This program simulates Parallel Concatenated Convolutional Codes (PCCCs) of coding rate 1/3 using a turbo decoder with two SISO RSC modules.
Reference: S. Benedetto, D. Divsalar, G. Motorsi and F. Pollara, "A Soft-Input Soft-Output Maximum A posteriori (MAP) Module to Decode Parallel and Serial Concatenated Codes", TDA Progress Report, nov. 1996
using std::cout;
using std::endl;
using std::string;
int main(void)
{
double threshold_value = 10;
string map_metric="maxlogMAP";
ivec gen = "07 05";
int constraint_length = 3;
int nb_errors_lim = 3000;
int nb_bits_lim = int(1e6);
int perm_len = (1<<14);
int nb_iter = 10;
vec EbN0_dB = "0:0.1:5";
double R = 1.0/3.0;
double Ec = 1.0;
int nb_bits = perm_len-(constraint_length-1);
vec sigma2 = (0.5*Ec/R)*
pow(
inv_dB(EbN0_dB), -1.0);
double Lc;
int nb_blocks;
int nb_errors;
ivec perm(perm_len);
ivec inv_perm(perm_len);
bvec bits(nb_bits);
int cod_bits_len = perm_len*gen.length();
bvec tail;
bvec cod2_input;
int rec_len = int(1.0/R)*perm_len;
bvec coded_bits(rec_len);
vec rec(rec_len);
vec dec1_intrinsic_coded(cod_bits_len);
vec dec2_intrinsic_coded(cod_bits_len);
vec apriori_data(perm_len);
vec extrinsic_coded(perm_len);
vec extrinsic_data(perm_len);
bvec rec_bits(perm_len);
int snr_len = EbN0_dB.length();
mat ber(nb_iter,snr_len);
ber.zeros();
register int en,n;
for (en=0;en<snr_len;en++)
{
cout << "EbN0_dB = " << EbN0_dB(en) << endl;
Lc = -2/sigma2(en);
nb_errors = 0;
nb_blocks = 0;
while ((nb_errors<nb_errors_lim) && (nb_blocks*nb_bits<nb_bits_lim))
{
cod2_input =
concat(bits, tail);
cc.
encode(cod2_input(perm), cod2_bits);
for (n=0;n<perm_len;n++)
{
coded_bits(3*n) = cod2_input(n);
coded_bits(3*n+1) = cod1_bits(n,0);
coded_bits(3*n+2) = cod2_bits(n,0);
}
for (n=0;n<perm_len;n++)
{
dec1_intrinsic_coded(2*n) = Lc*rec(3*n);
dec1_intrinsic_coded(2*n+1) = Lc*rec(3*n+1);
dec2_intrinsic_coded(2*n) = 0.0;
dec2_intrinsic_coded(2*n+1) = Lc*rec(3*n+2);
}
apriori_data.zeros();
for (n=0;n<nb_iter;n++)
{
siso.
rsc(extrinsic_coded, extrinsic_data, dec1_intrinsic_coded, apriori_data,
true);
apriori_data = extrinsic_data(perm);
siso.
rsc(extrinsic_coded, extrinsic_data, dec2_intrinsic_coded, apriori_data);
apriori_data += extrinsic_data;
berc.
count(bits, rec_bits.left(nb_bits));
apriori_data = extrinsic_data(inv_perm);
}
nb_blocks++;
}
ber.set_col(en, ber.get_col(en)/nb_blocks);
}
ff <<
Name(
"EbN0_dB") << EbN0_dB;
ff <<
Name(
"BER") << ber;
ff.close();
return 0;
}
Ordinary AWGN Channel for cvec or vec inputs and outputs.
void set_noise(double noisevar)
Set noise variance (for complex-valued channels the sum of real and imaginary parts)
Bit Error Rate Counter (BERC) Class.
void clear()
Clears the bit error counter.
double get_errors() const
Returns the counted number of bit errors.
double get_errorrate() const
Returns the estimated bit error rate.
void count(const bvec &in1, const bvec &in2)
Cumulative error counter.
BPSK modulator with real symbols.
void modulate_bits(const bvec &bits, vec &output) const
Modulate bits into BPSK symbols in complex domain.
void demodulate_bits(const vec &signal, bvec &output) const
Demodulate noisy BPSK symbols in complex domain into bits.
Automatic naming when saving.
A Recursive Systematic Convolutional Encoder/Decoder class.
void set_generator_polynomials(const ivec &gen, int constraint_length)
Set generator polynomials.
void encode(const bvec &input, bmat &parity_bits)
Encode a binary vector of inputs starting from zero state without adding of a tail.
void encode_tail(const bvec &input, bvec &tail, bmat &parity_bits)
Encode a binary vector of inputs and also adds a tail of K-1 zeros to force the encoder into the zero...
Soft Input Soft Output (SISO) modules.
void set_map_metric(const std::string &in_MAP_metric)
Sets the metric for MAP algorithm (convolutional codes and multipath channels)
static double threshold(const double &x, const double &value)
Functions used to limit values at a given +- threshold.
void set_generators(const itpp::bmat &in_gen)
Sets convolutional code generator polynomials.
void rsc(itpp::vec &extrinsic_coded, itpp::vec &extrinsic_data, const itpp::vec &intrinsic_coded, const itpp::vec &apriori_data)
SISO decoder for RSC codes
ivec sort_index(const Vec< T > &data, SORTING_METHOD method=INTROSORT)
Return an index vector corresponding to a sorted vector data in increasing order.
The IT++ file format reading and writing class.
vec pow(const double x, const vec &y)
Calculates x to the power of y (x^y)
double inv_dB(double x)
Inverse of decibel of x.
void RNG_randomize()
Set a random seed for all Random Number Generators in the current thread.
double randu(void)
Generates a random uniform (0,1) number.
bin randb(void)
Generates a random bit (equally likely 0s and 1s)
Include file for the IT++ communications module.
Mat< bin > bmat
bin matrix
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.
When you run this program, the results (BER and EbN0_dB) are saved into pccc_bersim_awgn.it file. Using the following MATLAB script:
the results can be displayed.
Similarly, the results can be displayed using the following Python script (pyitpp, numpy and matplotlib modules are required):