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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = mpsk_sim.cpp
  3. //
  4. #define SIM_NAME "MpskSim"
  5. #define SIM_TITLE "Complex Baseband Simulation for M-PSK"
  6. #include "global_stuff.h" 
  7. #include "m_psk_theory.h"
  8. #include "gausrand.h"
  9. #include "symbgen.h"
  10. #include "symb_remap.h"
  11. #include "add_gaus_noise.h"
  12. #include "mpsk_symbtowave.h"
  13. #include "quadmod.h"
  14. #include "spec_analyzer.h"
  15. #include "mpskoptimdem.h"
  16. #include "m_pskharddem.h"
  17. #include "ser_ctr.h"
  18. #include "siganchr.h"
  19. //=========================================================
  20. main()
  21. {
  22. #include "sim_preamble.cpp"
  23.   //=========================================================================
  24.   //  Misc special processing
  25.   //-----------------------------------------------------
  26.   // create plot file of theoretical PSD for QPSK signal
  27.    int big_m;
  28.    GET_INT_PARM( big_m );
  29.   M_PskPsd(  big_m,
  30.             0.0,  // carrier_freq
  31.             1.0,  // symb_energy,
  32.             1.0,  // bit_rate,
  33.             -4.0, // beg_freq,
  34.             4.0,  // end_freq,
  35.             801,  // num_pts,
  36.             true, // plot_in_db,
  37.             "mpsk_psd_theor.txt"); //out_filename
  38.   //-----------------------------------------------------
  39.   // create plot file of BER for ideal QPSK
  40.   M_PskBer( big_m,
  41.              -10.0,  // beg_ebno,
  42.             18.0, // end_ebno,
  43.             401,  // num_pts,
  44.             "theor_mpsk_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.   COMPLEX_SIGNAL(modulated_signal);
  52.   COMPLEX_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.   QuadratureModulator* quad_mod = new QuadratureModulator( "quad_mod",
  77.                                                         CommSystem,
  78.                                                         i_baseband_wave,
  79.                                                         q_baseband_wave,
  80.                                                         modulated_signal,
  81.                                                         mag_signal,
  82.                                                         phase_signal);
  83.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  84.                   new AdditiveGaussianNoise<std::complex<float> >( 
  85.                                                 "agn_source",
  86.                                                 CommSystem,
  87.                                                 modulated_signal,
  88.                                                 noisy_sig,
  89.                                                 power_meas_sig);
  90. //  SpectrumAnalyzer<std::complex<float> >* modulator_spec_an = 
  91. //                  new SpectrumAnalyzer<std::complex<float> >( 
  92. //                                                  "modulator_spec_an",
  93. //                                                  CommSystem,
  94. //                                                  modulated_signal );
  95.   MpskOptimalDemod* m_psk_dem = new MpskOptimalDemod( "m_psk_dem",
  96.                                                     CommSystem,
  97.                                                     noisy_sig,
  98.                                                     symb_clock,
  99.                                                     symb_decis);
  100.   
  101.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  102.                                                 CommSystem,
  103.                                                 modulated_signal,
  104.                                                 0.0625, //samp_intvl
  105.                                                 4096 ); //block_size
  106.   SerCounter* ser_ctr = new SerCounter( "ser_ctr",
  107.                                         CommSystem,
  108.                                         symb_vals,
  109.                                         symb_decis,
  110.                                         symb_err_seq );
  111.   //=============================================================
  112.   #include "sim_postamble.cpp"
  113.   return 0;
  114. }