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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = fsk_coh_sim.cpp
  3. //
  4. #define SIM_NAME "FskCohSim"
  5. #define SIM_TITLE "Bandpass Sim of Coherent FSK"
  6. #include "global_stuff.h" 
  7. #include "fsk_theory.h"
  8. #include "gausrand.h"
  9. #include "bitgen.h"
  10. #include "bitwav.h"
  11. #include "butt_filt_iir.h"
  12. #include "vco_ce.h"
  13. #include "add_gaus_noise.h"
  14. #include "spec_analyzer.h"
  15. #include "fsk_genie.h"
  16. #include "fsk_demod_coh.h"
  17. #include "ber_ctr.h"
  18. #include "siganchr.h"
  19. main()
  20. {
  21. #include "sim_preamble.cpp"
  22.   //=========================================================================
  23.   //  Misc special processing
  24.   //-----------------------------------------------------
  25.   // create plot file of theoretical PSD for FSK signal
  26.   FskPsd(  0.0,  // carrier_freq
  27.             1.0,  // symb_energy,
  28.             1.0,  // symb_intvl,
  29.             -4.0, // beg_freq,
  30.             4.0,  // end_freq,
  31.             801,  // num_pts,
  32.             true, // plot_in_db,
  33.             "fsk_psd_theor.txt"); //out_filename
  34.   //-----------------------------------------------------
  35.   // create plot file of BER for ideal QPSK
  36.   FskBer(  -10.0,  // beg_ebno,
  37.             18.0, // end_ebno,
  38.             401,  // num_pts,
  39.             "theor_fsk_ber.txt");  // out_filename
  40.   //=========================================================================
  41.   //  Allocate signals
  42.   BIT_SIGNAL(bit_vals);
  43.   FLOAT_SIGNAL(baseband_wave);
  44.   FLOAT_SIGNAL(filt_baseband_wave);
  45.   COMPLEX_SIGNAL(modulated_signal);
  46.   FLOAT_SIGNAL(modulated_ref_signal);
  47.   COMPLEX_SIGNAL(noisy_sig);
  48.   COMPLEX_SIGNAL(lo_ref_sig);
  49.   COMPLEX_SIGNAL(hi_ref_sig);
  50.   BIT_SIGNAL(symb_clock);
  51.   BIT_SIGNAL(delayed_clock);
  52.   FLOAT_SIGNAL(power_meas_sig);
  53.   BIT_SIGNAL(bit_decis);
  54.   FLOAT_SIGNAL(lo_integ_sig);
  55.   FLOAT_SIGNAL(hi_integ_sig);
  56.   FLOAT_SIGNAL(lo_correl_sig);
  57.   FLOAT_SIGNAL(hi_correl_sig);
  58.   //============================================================
  59.   //  Construct, initialize and connect models
  60.   BitGener* bit_gen = new BitGener( "bit_gen",
  61.                                       CommSystem,
  62.                                       bit_vals );
  63.   BitsToWave* wave_gen = new BitsToWave( "wave_gen",
  64.                                            CommSystem,
  65.                                            bit_vals,
  66.                                            baseband_wave,
  67.                                            symb_clock );
  68.    ComplexVco* fsk_mod_1 = new ComplexVco( "fsk_mod_1",
  69.                                              CommSystem,
  70.                                              baseband_wave,
  71.                                              modulated_signal);
  72.   
  73.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  74.                   new AdditiveGaussianNoise<std::complex<float> >( 
  75.                                                 "agn_source",
  76.                                                 CommSystem,
  77.                                                 modulated_signal,
  78.                                                 noisy_sig,
  79.                                                 power_meas_sig);
  80.   SpectrumAnalyzer<std::complex<float> >* modulator_spec_an = 
  81.                   new SpectrumAnalyzer<std::complex<float> >( 
  82.                                               "modulator_spec_an",
  83.                                               CommSystem,
  84.                                               modulated_signal );
  85.   FskCarrierGenie* carrier_recovery = new FskCarrierGenie( "carrier_recovery",
  86.                                                            CommSystem,
  87.                                                            lo_ref_sig,
  88.                                                            hi_ref_sig);
  89.   FskCoherentDemod* fsk_dem = new FskCoherentDemod( "fsk_dem",
  90.                                                     CommSystem,
  91.                                                     noisy_sig,
  92.                                                     lo_ref_sig,
  93.                                                     hi_ref_sig,
  94.                                                     symb_clock,
  95.                                                     bit_decis,
  96.                                                     lo_integ_sig,
  97.                                                     hi_integ_sig);
  98.   
  99.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  100.                                                 CommSystem,
  101.                                                 baseband_wave);
  102.   BerCounter* ber_ctr = new BerCounter( "ber_ctr",
  103.                                           CommSystem,
  104.                                           bit_vals,
  105.                                           bit_decis );
  106.   //=============================================================
  107.   #include "sim_postamble.cpp"
  108.   return 0;
  109. }