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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = qam_sim.cpp
  3. //
  4. #define SIM_NAME "QamSim"
  5. #define SIM_TITLE "Complex Baseband Simulation for QAM"
  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 "cmpxagn.h"
  13. //#include "mpskidealmod.h"
  14. #include "qam_symbtowave.h"
  15. #include "quadmod.h"
  16. #include "spec_analyzer.h"
  17. #include "qamoptimdem.h"
  18. //#include "m_pskharddem.h"
  19. #include "ser_ctr.h"
  20. #include "siganchr.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(  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. //            "msk_psd_theor.txt"); //out_filename
  37.   //-----------------------------------------------------
  38.   // create plot file of BER for ideal QPSK
  39. //  M_PskBer(  -10.0,  // beg_ebno,
  40. //            18.0, // end_ebno,
  41. //            401,  // num_pts,
  42. //            "theor_msk_ber.txt");  // out_filename
  43.   //=========================================================================
  44.   //  Allocate signals
  45.   BYTE_SIGNAL(symb_vals);
  46.   BYTE_SIGNAL(mapped_symb_vals);
  47.   FLOAT_SIGNAL(i_baseband_wave);
  48.   FLOAT_SIGNAL(q_baseband_wave);
  49.   COMPLEX_SIGNAL(modulated_signal);
  50.   COMPLEX_SIGNAL(noisy_sig);
  51.   BIT_SIGNAL(symb_clock);
  52.   COMPLEX_SIGNAL(cmpx_integ_sig);
  53.   FLOAT_SIGNAL(power_meas_sig);
  54.   FLOAT_SIGNAL(mag_signal);
  55.   FLOAT_SIGNAL(phase_signal);
  56.   BYTE_SIGNAL(symb_decis);
  57.   BYTE_SIGNAL(symb_err_seq);
  58.   //============================================================
  59.   //  Construct, initialize and connect models
  60.   SymbGener* symb_gen = new SymbGener( "symb_gen",
  61.                                       CommSystem,
  62.                                       symb_vals );
  63. //  SymbRemapper* symb_mapper = new SymbRemapper( "symb_mapper",
  64. //                                                CommSystem,
  65. //                                                symb_vals,
  66. //                                                mapped_symb_vals);
  67.   QamSymbsToQuadWaves* qam_mod = new QamSymbsToQuadWaves( 
  68.                                                 "qam_mod",
  69.                                                 CommSystem,
  70.                                                 symb_vals,
  71.                                                 i_baseband_wave,
  72.                                                 q_baseband_wave,
  73.                                                 symb_clock);
  74.   QuadratureModulator* quad_mod = new QuadratureModulator( "quad_mod",
  75.                                                         CommSystem,
  76.                                                         i_baseband_wave,
  77.                                                         q_baseband_wave,
  78.                                                         modulated_signal,
  79.                                                         mag_signal,
  80.                                                         phase_signal);
  81.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  82.                   new AdditiveGaussianNoise<std::complex<float> >( 
  83.                                                 "agn_source",
  84.                                                 CommSystem,
  85.                                                 modulated_signal,
  86.                                                 noisy_sig,
  87.                                                 power_meas_sig);
  88.   SpectrumAnalyzer<std::complex<float> >* modulator_spec_an = 
  89.                   new SpectrumAnalyzer<std::complex<float> >( 
  90.                                                   "modulator_spec_an",
  91.                                                   CommSystem,
  92.                                                   modulated_signal );
  93.   QamOptimalDemod* qam_demod = new QamOptimalDemod( "qam_demod",
  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.0625, //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. }