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

3G开发

开发平台:

Visual C++

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