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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = bpsk_sim_bp.cpp
  3. //
  4. #define SIM_NAME "BpskSim_Bp"
  5. #define SIM_TITLE "Bandpass 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_bp.h"
  12. #include "add_gaus_noise.h"
  13. #include "spec_analyzer.h"
  14. #include "carrier_genie.h"
  15. #include "bpsk_demod_bp.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.   FLOAT_SIGNAL(modulated_signal);
  44.   FLOAT_SIGNAL(noisy_sig);
  45.   FLOAT_SIGNAL(ref_carrier);
  46.   BIT_SIGNAL(symb_clock);
  47.   BIT_SIGNAL(delayed_clock);
  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.   BpskBandpassModulator* bpsk_mod = new BpskBandpassModulator( "bpsk_mod",
  61.                                                 CommSystem,
  62.                                                 baseband_wave,
  63.                                                 modulated_signal);
  64.   
  65.   AdditiveGaussianNoise<float>* agn_source = 
  66.                   new AdditiveGaussianNoise<float>( 
  67.                                                 "agn_source",
  68.                                                 CommSystem,
  69.                                                 modulated_signal,
  70.                                                 noisy_sig,
  71.                                                 power_meas_sig);
  72.   SpectrumAnalyzer<float>* modulator_spec_an = 
  73.                   new SpectrumAnalyzer<float>( 
  74.                                               "modulator_spec_an",
  75.                                               CommSystem,
  76.                                               modulated_signal );
  77.   CarrierRecoveryGenie* carrier_recovery = new CarrierRecoveryGenie( "carrier_recovery",
  78.                                                                    CommSystem,
  79.                                                                    ref_carrier);
  80.   BpskBandpassDemod* bpsk_dem = new BpskBandpassDemod( "bpsk_dem",
  81.                                                     CommSystem,
  82.                                                     noisy_sig,
  83.                                                     ref_carrier,
  84.                                                     symb_clock,
  85.                                                     bit_decis);
  86.   
  87.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  88.                                                 CommSystem,
  89.                                                 baseband_wave,
  90.                                                 0.015625, //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. }