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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = bpsk_sim.cpp
  3. //
  4. #define SIM_NAME "BpskSim"
  5. #define SIM_TITLE "Complex Baseband Simulation of BPSK"
  6. #include "global_stuff.h" 
  7. #include "bpsk_theory.h"
  8. #include "gausrand.h"
  9. #include "bitgen.h"
  10. #include "bitwav.h"
  11. #include "bpsk_mod.h"
  12. #include "add_gaus_noise.h"
  13. #include "spec_analyzer.h"
  14. #include "phase_genie.h"
  15. #include "bpsk_correl_demod.h"
  16. #include "ber_ctr.h"
  17. #include "siganchr.h"
  18. main()
  19. {
  20. #include "sim_preamble.cpp"
  21.   //=========================================================================
  22.   //  Misc special processing
  23.   //-----------------------------------------------------
  24.   // create plot file of theoretical PSD for QPSK signal
  25.   BpskPsd(  0.0,  // carrier_freq
  26.             1.0,  // symb_energy,
  27.             1.0,  // symb_intvl,
  28.             -4.0, // beg_freq,
  29.             4.0,  // end_freq,
  30.             801,  // num_pts,
  31.             true, // plot_in_db,
  32.             "bpsk_psd_theor.txt"); //out_filename
  33.   //-----------------------------------------------------
  34.   // create plot file of BER for ideal QPSK
  35.   BpskBer(  -10.0,  // beg_ebno,
  36.             18.0, // end_ebno,
  37.             401,  // num_pts,
  38.             "theor_bpsk_ber.txt");  // out_filename
  39.   //=========================================================================
  40.   //  Allocate signals
  41.   BIT_SIGNAL(bit_vals);
  42.   FLOAT_SIGNAL(baseband_wave);
  43.   BIT_SIGNAL(symb_clock);
  44.   COMPLEX_SIGNAL(modulated_signal);
  45.   COMPLEX_SIGNAL(noisy_sig);
  46.   BIT_SIGNAL(delayed_clock);
  47.   COMPLEX_SIGNAL(phase_ref_sig);
  48.   FLOAT_SIGNAL(power_meas_sig);
  49.   BIT_SIGNAL(bit_decis);
  50.   //============================================================
  51.   //  Construct, initialize and connect models
  52.   BitGener* bit_gen = new BitGener( "bit_gen",
  53.                                       CommSystem,
  54.                                       bit_vals );
  55.   BitsToWave* wave_gen = new BitsToWave( "wave_gen",
  56.                                            CommSystem,
  57.                                            bit_vals,
  58.                                            baseband_wave,
  59.                                            symb_clock );
  60.   BpskModulator* bpsk_mod = new BpskModulator( "bpsk_mod",
  61.                                                 CommSystem,
  62.                                                 baseband_wave,
  63.                                                 modulated_signal);
  64.   
  65.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  66.                   new AdditiveGaussianNoise<std::complex<float> >( 
  67.                                                 "agn_source",
  68.                                                 CommSystem,
  69.                                                 modulated_signal,
  70.                                                 noisy_sig,
  71.                                                 power_meas_sig);
  72.   //SpectrumAnalyzer<std::complex<float> >* modulator_spec_an = 
  73.   //                new SpectrumAnalyzer<std::complex<float> >( 
  74.   //                                                "modulator_spec_an",
  75.   //                                                CommSystem,
  76.   //                                                modulated_signal );
  77.   PhaseRecoveryGenie* carrier_recovery = new PhaseRecoveryGenie( "carrier_recovery",
  78.                                                                    CommSystem,
  79.                                                                    phase_ref_sig);
  80.   BpskCorrelationDemod* bpsk_dem = new BpskCorrelationDemod( "bpsk_dem",
  81.                                                     CommSystem,
  82.                                                     noisy_sig,
  83.                                                     phase_ref_sig,
  84.                                                     symb_clock,
  85.                                                     bit_decis);
  86.   
  87.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  88.                                                 CommSystem,
  89.                                                 baseband_wave,
  90.                                                 0.0625, //samp_intvl
  91.                                                 4096 ); //block_size
  92.   BerCounter* ber_ctr = new BerCounter( "ber_ctr",
  93.                                           CommSystem,
  94.                                           bit_vals,
  95.                                           bit_decis );
  96.   //=============================================================
  97.   #include "sim_postamble.cpp"
  98.   return 0;
  99. }