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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = fsk_coh_sim_bp.cpp
  3. //
  4. #define SIM_NAME "FskCohSim_Bp"
  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 "fsk_2tone_bp.h"
  13. #include "vco_bp.h"
  14. //#include "discrete_delay_T.h"
  15. #include "add_gaus_noise.h"
  16. #include "spec_analyzer.h"
  17. #include "fsk_genie_bp.h"
  18. //#include "correlator.h"
  19. #include "fsk_demod_coh_bp.h"
  20. #include "ber_ctr.h"
  21. #include "siganchr.h"
  22. main()
  23. {
  24. #include "sim_preamble.cpp"
  25.   //=========================================================================
  26.   //  Misc special processing
  27.   //-----------------------------------------------------
  28.   // create plot file of theoretical PSD for FSK signal
  29.   FskPsd(  0.0,  // carrier_freq
  30.             1.0,  // symb_energy,
  31.             1.0,  // symb_intvl,
  32.             -4.0, // beg_freq,
  33.             4.0,  // end_freq,
  34.             801,  // num_pts,
  35.             true, // plot_in_db,
  36.             "fsk_psd_theor.txt"); //out_filename
  37.   //-----------------------------------------------------
  38.   // create plot file of BER for ideal QPSK
  39.   FskBer(  -10.0,  // beg_ebno,
  40.             18.0, // end_ebno,
  41.             401,  // num_pts,
  42.             "theor_fsk_ber.txt");  // out_filename
  43.   //=========================================================================
  44.   //  Allocate signals
  45.   BIT_SIGNAL(bit_vals);
  46.   FLOAT_SIGNAL(baseband_wave);
  47.   FLOAT_SIGNAL(filt_baseband_wave);
  48.   FLOAT_SIGNAL(modulated_signal);
  49.   FLOAT_SIGNAL(modulated_ref_signal);
  50.   FLOAT_SIGNAL(noisy_sig);
  51.   FLOAT_SIGNAL(lo_ref_sig);
  52.   FLOAT_SIGNAL(hi_ref_sig);
  53.   BIT_SIGNAL(symb_clock);
  54.   BIT_SIGNAL(delayed_clock);
  55.   FLOAT_SIGNAL(power_meas_sig);
  56.   BIT_SIGNAL(bit_decis);
  57.   FLOAT_SIGNAL(lo_integ_sig);
  58.   FLOAT_SIGNAL(hi_integ_sig);
  59.   FLOAT_SIGNAL(lo_correl_sig);
  60.   FLOAT_SIGNAL(hi_correl_sig);
  61.   //============================================================
  62.   //  Construct, initialize and connect models
  63.   BitGener* bit_gen = new BitGener( "bit_gen",
  64.                                       CommSystem,
  65.                                       bit_vals );
  66.   BitsToWave* wave_gen = new BitsToWave( "wave_gen",
  67.                                            CommSystem,
  68.                                            bit_vals,
  69.                                            baseband_wave,
  70.                                            symb_clock );
  71. //  ButterworthFilterByIir<float>* tx_baseband_filter = 
  72. //            new ButterworthFilterByIir<float>( "tx_baseband_filter",
  73. //                                        CommSystem,
  74. //                                        baseband_wave,
  75. //                                        filt_baseband_wave );
  76. //   FskTwoToneModulator_Bp* fsk_mod_2 = new FskTwoToneModulator_Bp( "fsk_mod_2",
  77. //                                                                   CommSystem,
  78. //                                                                   filt_baseband_wave,
  79. //                                                                   modulated_signal);
  80.    BandpassVco* fsk_mod_1 = new BandpassVco( "fsk_mod_1",
  81.                                              CommSystem,
  82.                                              baseband_wave,
  83.                                              modulated_signal);
  84.   
  85.   AdditiveGaussianNoise<float>* agn_source = 
  86.                   new AdditiveGaussianNoise<float>( 
  87.                                                 "agn_source",
  88.                                                 CommSystem,
  89.                                                 modulated_signal,
  90.                                                 noisy_sig,
  91.                                                 power_meas_sig);
  92.   SpectrumAnalyzer<float>* modulator_spec_an = 
  93.                   new SpectrumAnalyzer<float>( 
  94.                                               "modulator_spec_an",
  95.                                               CommSystem,
  96.                                               modulated_signal );
  97.   FskBandpassCarrierGenie* carrier_recovery = new FskBandpassCarrierGenie( 
  98.                                                             "carrier_recovery",
  99.                                                            CommSystem,
  100.                                                            lo_ref_sig,
  101.                                                            hi_ref_sig);
  102. //  Control<float>* lo_ref_delay_ctl = new Control<float>("lo_ref_delay_ctl");
  103. //  Control<int>* lo_ref_samps_delay_ctl = new Control<int>("lo_ref_samps_delay_ctl");
  104. //  RealCorrelator* lo_freq_sync = new RealCorrelator( "lo_freq_sync",
  105. //                                                      CommSystem,
  106. //                                                      lo_ref_sig,
  107. //                                                      modulated_signal,
  108. //                                                      lo_correl_sig,
  109. //                                                      lo_ref_delay_ctl,
  110. //                                                      lo_ref_samps_delay_ctl);
  111. //  Control<float>* hi_ref_delay_ctl = new Control<float>("hi_ref_delay_ctl");
  112. //  Control<int>* hi_ref_samps_delay_ctl = new Control<int>("hi_ref_samps_delay_ctl");
  113. //  RealCorrelator* hi_freq_sync = new RealCorrelator( "hi_freq_sync",
  114. //                                                      CommSystem,
  115. //                                                      hi_ref_sig,
  116. //                                                      modulated_signal,
  117. //                                                      hi_correl_sig,
  118. //                                                      hi_ref_delay_ctl,
  119. //                                                      hi_ref_samps_delay_ctl);
  120.   FskCoherentBandpassDemod* fsk_dem = new FskCoherentBandpassDemod( "fsk_dem",
  121.                                                     CommSystem,
  122.                                                     noisy_sig,
  123.                                                     lo_ref_sig,
  124.                                                     hi_ref_sig,
  125.                                                     symb_clock,
  126.                                                     bit_decis,
  127.                                                     lo_integ_sig,
  128.                                                     hi_integ_sig);
  129.   
  130.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  131.                                                 CommSystem,
  132.                                                 baseband_wave);
  133.   BerCounter* ber_ctr = new BerCounter( "ber_ctr",
  134.                                           CommSystem,
  135.                                           bit_vals,
  136.                                           bit_decis );
  137.   //=============================================================
  138.   #include "sim_postamble.cpp"
  139.   return 0;
  140. }