OFDM simulation by happo6

VIEWS: 0 PAGES: 10

									Simulation of an OFDM
   system with IT++
#include <itcomm.h>

using std::cout;
using std::endl;
using std::string;
using namespace itpp;

int main()
{
             Variable declarations
Parser p;
vec     EbN0dB, EbN0, N0, ber,data_temp,
vec     real_bit,soft_bits,ber_meas,No;
cvec sym_of,trans_symbols,rec_symbols,rec1_symbols;
cvec ofdm_symbols,signal_rec,ofdm_dem;
bvec uncoded_bits, coded_bits, decoded_bits,deconv_bits,rx_bits;
it_file                 ff;
QPSK                    qpsk;
AWGN_Channel            channel;
BERC                    bertt;
OFDM                    ofdm;
int     No_frames,j,i,Ncp,Nsc,Nobitssteps,bit_errors,total_bits;
double Ec, Eb;
                   Initialization
p.init("OFDM_configuration.txt");
No_frames = p.get_int("No_frames");
EbN0dB = vec(p.get_string("SNR"));
Nsc=p.get_int("Nsc");
Ncp=p.get_int("Ncp");

ofdm.set_parameters(Nsc,Ncp);
Ec = 1.0; // Energy per QPSK symbol
Eb = Ec/2; // Energy per bit
EbN0 = inv_dB(EbN0dB); //Calculate Eb/N0 in linear scale
No = Eb/EbN0 ;
Nobits=Nsc;
ber_meas=zeros ( length(EbN0dB) );
RNG_randomize();                  //set random seed generator
 The simulation loops

for (i=0;i<length(EbN0dB);i++) {
       bertt.clear();
       total_bits=0;
       channel.set_noise(No(i));
       for (j=0; j < No_frames; j++) {
              Transmitter

uncoded_bits=randb(Nobits);

qpsk.modulate_bits( uncoded_bits, trans_symbols );

ofdm.modulate( trans_symbols, ofdm_symbols );
         Channel


signal_rec=channel(ofdm_symbols);
            Receiver

ofdm.demodulate(signal_rec,ofdm_dem);
qpsk.demodulate_bits(ofdm_dem,rx_bits);

bertt.count(uncoded_bits,rx_bits);
total_bits= total_bits+length(uncoded_bits);
    }
    ber_meas(i)=double(bertt.get_errors())/total_bits;
    cout << “BER = “ << ber_meas(i) << endl;
}
                 Finalizing
    //Save BER in file
    ff.open("qpsk.it");
    ff<<Name("BER") << ber_meas;
    ff<<Name("EbNodB") << EbN0dB;
    ff<<Name("time") << tt.toc();
    ff.close();

    return 0;
}

								
To top