qpsk_sim_bp.cpp
上传用户:jtjnyq9001
上传日期:2014-11-21
资源大小:3974k
文件大小:7k
源码类别:

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = qpsk_sim_bp.cpp
  3. //
  4. #define SIM_NAME "QpskSim_Bp"
  5. #define SIM_TITLE "Bandpass Simulation of QPSK"
  6. #include "global_stuff.h" 
  7. #include "qpsk_theory.h"
  8. #include "bitgen.h"
  9. #include "bitwav.h"
  10. #include "siganchr.h"
  11. #include "quadmod_bp.h"
  12. #include "phase_rotate.h"
  13. #include "add_gaus_noise.h"
  14. #include "spec_analyzer.h"
  15. #include "quad_carr_genie.h"
  16. #include "quad_mixer_bp.h"
  17. #include "integ_dump_slice.h"
  18. #include "qpskoptbitdem.h"
  19. #include "ber_ctr.h"
  20. #include "qpsk_err_ctr.h"
  21. main()
  22. {
  23. #include "sim_preamble.cpp"
  24.   //=========================================================================
  25.   //  Misc special processing
  26.   //-----------------------------------------------------
  27.   // create plot file of theoretical PSD for QPSK signal
  28.   QpskPsd(  0.0,  // carrier_freq
  29.             1.0,  // symb_energy,
  30.             1.0,  // symb_intvl,
  31.             -4.0, // beg_freq,
  32.             4.0,  // end_freq,
  33.             801,  // num_pts,
  34.             true, // plot_in_db,
  35.             "qpsk_psd_theor.txt"); //out_filename
  36.   //-----------------------------------------------------
  37.   // create plot file of BER for ideal QPSK
  38.   QpskBer(  -10.0,  // beg_ebno,
  39.             18.0, // end_ebno,
  40.             401,  // num_pts,
  41.             "theor_qpsk_ber.txt");  // out_filename
  42.   //=========================================================================
  43.   //  Allocate signals
  44.   BIT_SIGNAL(i_bits);
  45.   BIT_SIGNAL(q_bits);
  46.   FLOAT_SIGNAL(i_baseband_wave);
  47.   FLOAT_SIGNAL(q_baseband_wave);
  48.   FLOAT_SIGNAL(modulated_signal);
  49.   FLOAT_SIGNAL(i_recov_carrier_sig);
  50.   FLOAT_SIGNAL(q_recov_carrier_sig);
  51.   FLOAT_SIGNAL(noisy_sig);
  52.   BIT_SIGNAL(symb_clock);
  53.   BIT_SIGNAL(q_symb_clock);
  54.   FLOAT_SIGNAL(power_meas_sig);
  55.   FLOAT_SIGNAL(i_demod_wave);
  56.   FLOAT_SIGNAL(q_demod_wave);
  57.   FLOAT_SIGNAL(i_samp_wave);
  58.   FLOAT_SIGNAL(q_samp_wave);
  59.   BIT_SIGNAL(i_bit_decis);
  60.   BIT_SIGNAL(q_bit_decis);
  61.   //============================================================
  62.   //  Construct, initialize and connect models
  63.   BitGener* i_bit_gen = new BitGener( "i_bit_gen",
  64.                                       CommSystem,
  65.                                       i_bits );
  66.   BitGener* q_bit_gen = new BitGener( "q_bit_gen",
  67.                                       CommSystem,
  68.                                       q_bits );
  69.   BitsToWave* i_wave_gen = new BitsToWave( "i_wave_gen",
  70.                                            CommSystem,
  71.                                            i_bits,
  72.                                            i_baseband_wave,
  73.                                            symb_clock );
  74.   BitsToWave* q_wave_gen = new BitsToWave( "q_wave_gen",
  75.                                            CommSystem,
  76.                                            q_bits,
  77.                                            q_baseband_wave,
  78.                                            q_symb_clock );
  79.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  80.                                                 CommSystem,
  81.                                                 i_baseband_wave,
  82.                                                 q_baseband_wave,
  83.                                                 0.03125, //samp_intvl
  84.                                                 4096 ); //block_size
  85.   QuadBandpassModulator* qpsk_mod = new QuadBandpassModulator( "qpsk_mod",
  86.                                                 CommSystem,
  87.                                                 i_baseband_wave,
  88.                                                 q_baseband_wave,
  89.                                                 modulated_signal);
  90.   
  91.   AdditiveGaussianNoise<float>* agn_source = 
  92.                   new AdditiveGaussianNoise<float>( 
  93.                                                 "agn_source",
  94.                                                 CommSystem,
  95.                                                 modulated_signal,
  96.                                                 noisy_sig,
  97.                                                 power_meas_sig);
  98.   SpectrumAnalyzer<float>* spec_analyzer = 
  99.                   new SpectrumAnalyzer<float>( 
  100.                                                   "spec_analyzer",
  101.                                                   CommSystem,
  102.                                                   modulated_signal );
  103.   QuadCarrierRecovGenie* carrier_recovery = new QuadCarrierRecovGenie( "carrier_recovery",
  104.                                                                    CommSystem,
  105.                                                                    i_recov_carrier_sig,
  106.                                                                    q_recov_carrier_sig);
  107.   
  108.   QuadBandpassMixer* quad_dem = new QuadBandpassMixer( "quad_dem",
  109.                                                    CommSystem,
  110.                                                    noisy_sig,
  111.                                                    i_recov_carrier_sig,
  112.                                                    q_recov_carrier_sig,
  113.                                                    i_demod_wave,
  114.                                                    q_demod_wave );
  115.   IntegrateDumpAndSlice* i_bit_slicer = new IntegrateDumpAndSlice( "i_bit_slicer",
  116.                                            CommSystem,
  117.                                            i_demod_wave,
  118.                                            symb_clock,
  119.                                            i_samp_wave,
  120.                                            i_bit_decis);
  121.   IntegrateDumpAndSlice* q_bit_slicer = new IntegrateDumpAndSlice( "q_bit_slicer",
  122.                                            CommSystem,
  123.                                            q_demod_wave,
  124.                                            q_symb_clock,
  125.                                            q_samp_wave,
  126.                                            q_bit_decis);
  127.   BerCounter* i_ber_ctr = new BerCounter( "i_ber_ctr",
  128.                                           CommSystem,
  129.                                           i_bits,
  130.                                           i_bit_decis );
  131.   BerCounter* q_ber_ctr = new BerCounter( "q_ber_ctr",
  132.                                           CommSystem,
  133.                                           q_bits,
  134.                                           q_bit_decis );
  135.   QpskErrorCounter* ser_ctr = new QpskErrorCounter( "ser_ctr",
  136.                                                     CommSystem,
  137.                                                     i_bits,
  138.                                                     q_bits,
  139.                                                     i_bit_decis,
  140.                                                     q_bit_decis );
  141.   //=============================================================
  142.   #include "sim_postamble.cpp"
  143.   return 0;
  144. }