This program simulates the performance of LDPC codes on the AWGN channel. Since the channel is symmetric, the zero codeword is used.
#include <sstream>
int main(int argc, char **argv)
{
if (argc < 2) {
it_info(
"Usage: " << argv[0] <<
" codec_file.it [EbN0_dB]");
return 1;
}
int64_t Nbits = 5000000000LL;
int Nbers = 2000;
double BERmin = 1e-6;
vec EbN0db = "0.6:0.2:5";
bool single_snr_mode = false;
if (argc == 3) {
istringstream ss(argv[2]);
double x;
ss >> x;
EbN0db = x;
single_snr_mode = true;
}
cout << "Running with Eb/N0: " << EbN0db << endl;
C.set_exit_conditions(2500);
cout << C << endl;
int N = C.get_nvar();
for (
int j = 0; j <
length(EbN0db); j++) {
double N0 =
pow(10.0, -EbN0db(j) / 10.0) / C.get_rate();
for (int64_t i = 0; i < Nbits; i += C.get_nvar()) {
vec x = chan(s);
QLLRvec llr;
C.bp_decode(C.get_llrcalc().to_qllr(softbits), llr);
bvec bitsout = llr < 0;
berc.
count(bitsin, bitsout);
ferc.
count(bitsin, bitsout);
if (single_snr_mode) {
cout << "Eb/N0 = " << EbN0db(j) << " Simulated "
<<
"Obtained " << berc.
get_errors() <<
" bit errors. "
}
else {
break;
}
}
cout << "Eb/N0 = " << EbN0db(j) << " Simulated "
<<
"Obtained " << berc.
get_errors() <<
" bit errors. "
break;
}
return 0;
}
Ordinary AWGN Channel for cvec or vec inputs and outputs.
Bit Error Rate Counter (BERC) Class.
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.
double get_total_bits() const
Returns the total number of bits processed.
Class for counting block error rates.
void set_blocksize(int inblocksize, bool clear=true)
Set the block size.
double get_errorrate() const
Returns the block error rate.
void count(const bvec &in1, const bvec &in2)
Calculate the number of block errors between in1 and in2.
double get_total_blocks() const
Returns the total number of block processed.
BPSK modulator with real symbols.
void modulate_bits(const bvec &bits, vec &output) const
Modulate bits into BPSK symbols in complex domain.
virtual void demodulate_soft_bits(const vec &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
Soft demodulator for AWGN channel.
Low-density parity check (LDPC) codec.
Systematic LDPC Generator class.
#define it_info(s)
Print information message.
it_file & flush(it_file &f)
Flush operator.
vec pow(const double x, const vec &y)
Calculates x to the power of y (x^y)
int length(const Vec< T > &v)
Length of vector.
void RNG_randomize()
Set a random seed for all Random Number Generators in the current thread.
ITPP_EXPORT bvec zeros_b(int size)
A Binary vector of zeros.
Include file for the IT++ communications module.