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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = mpsk_sim_bp.cpp
  3. //
  4. #define SIM_NAME "MpskSim_Bp"
  5. #define SIM_TITLE "Bandpass Simulation for M-PSK"
  6. #include "global_stuff.h" 
  7. #include "gausrand.h"
  8. #include "symbgen.h"
  9. #include "symb_remap.h"
  10. #include "add_gaus_noise.h"
  11. //#include "cmpxagn.h"
  12. #include "mpskidealmod.h"
  13. #include "mpsk_symbtowave.h"
  14. #include "quadmod_bp.h"
  15. #include "spec_analyzer.h"
  16. #include "mpskoptdem_bp.h"
  17. #include "m_pskharddem.h"
  18. #include "ser_ctr.h"
  19. #include "siganchr.h"
  20. #include "m_psk_theory.h"
  21. //=========================================================
  22. main()
  23. {
  24. #include "sim_preamble.cpp"
  25.   //=========================================================================
  26.   //  Misc special processing
  27.   //-----------------------------------------------------
  28.   // create plot file of theoretical PSD for QPSK signal
  29.   M_PskPsd(  4,   // big_m
  30.             0.0,  // carrier_freq
  31.             1.0,  // symb_energy,
  32.             1.0,  // symb_intvl,
  33.             -4.0, // beg_freq,
  34.             4.0,  // end_freq,
  35.             801,  // num_pts,
  36.             true, // plot_in_db,
  37.             "msk_psd_theor.txt"); //out_filename
  38.   //-----------------------------------------------------
  39.   // create plot file of BER for ideal QPSK
  40.   M_PskBer(  4,
  41.            -10.0,  // beg_ebno,
  42.             18.0, // end_ebno,
  43.             401,  // num_pts,
  44.             "theor_msk_ber.txt");  // out_filename
  45.   //=========================================================================
  46.   //  Allocate signals
  47.   BYTE_SIGNAL(symb_vals);
  48.   BYTE_SIGNAL(mapped_symb_vals);
  49.   FLOAT_SIGNAL(i_baseband_wave);
  50.   FLOAT_SIGNAL(q_baseband_wave);
  51.   FLOAT_SIGNAL(modulated_signal);
  52.   FLOAT_SIGNAL(noisy_sig);
  53.   BIT_SIGNAL(symb_clock);
  54.   COMPLEX_SIGNAL(cmpx_integ_sig);
  55.   FLOAT_SIGNAL(power_meas_sig);
  56.   FLOAT_SIGNAL(mag_signal);
  57.   FLOAT_SIGNAL(phase_signal);
  58.   BYTE_SIGNAL(symb_decis);
  59.   BYTE_SIGNAL(symb_err_seq);
  60.   //============================================================
  61.   //  Construct, initialize and connect models
  62.   SymbGener* symb_gen = new SymbGener( "symb_gen",
  63.                                       CommSystem,
  64.                                       symb_vals );
  65.   SymbRemapper* symb_mapper = new SymbRemapper( "symb_mapper",
  66.                                                 CommSystem,
  67.                                                 symb_vals,
  68.                                                 mapped_symb_vals);
  69.   MpskSymbsToQuadWaves* m_psk_mod = new MpskSymbsToQuadWaves( 
  70.                                                 "m_psk_mod",
  71.                                                 CommSystem,
  72.                                                 mapped_symb_vals,
  73.                                                 i_baseband_wave,
  74.                                                 q_baseband_wave,
  75.                                                 symb_clock);
  76.   QuadBandpassModulator* quad_mod = new QuadBandpassModulator( "quad_mod",
  77.                                                         CommSystem,
  78.                                                         i_baseband_wave,
  79.                                                         q_baseband_wave,
  80.                                                         modulated_signal);
  81.   AdditiveGaussianNoise<float>* agn_source = 
  82.                   new AdditiveGaussianNoise<float>( 
  83.                                                 "agn_source",
  84.                                                 CommSystem,
  85.                                                 modulated_signal,
  86.                                                 noisy_sig,
  87.                                                 power_meas_sig);
  88.   SpectrumAnalyzer<float>* modulator_spec_an = 
  89.                   new SpectrumAnalyzer<float>( 
  90.                                                   "modulator_spec_an",
  91.                                                   CommSystem,
  92.                                                   modulated_signal );
  93.   MpskOptimalBandpassDemod* m_psk_dem = new MpskOptimalBandpassDemod( "m_psk_dem",
  94.                                                     CommSystem,
  95.                                                     noisy_sig,
  96.                                                     symb_clock,
  97.                                                     symb_decis);
  98.   
  99.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  100.                                                 CommSystem,
  101.                                                 modulated_signal,
  102.                                                 0.015625, //samp_intvl
  103.                                                 4096 ); //block_size
  104.   SerCounter* ser_ctr = new SerCounter( "ser_ctr",
  105.                                         CommSystem,
  106.                                         symb_vals,
  107.                                         symb_decis,
  108.                                         symb_err_seq );
  109.   //=============================================================
  110.   #include "sim_postamble.cpp"
  111.   return 0;
  112. }