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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = qam_sim_bp.cpp
  3. //
  4. #define SIM_NAME "QamSim_Bp"
  5. #define SIM_TITLE "Bandpass Simulation for QAM"
  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 "qam_symbtowave.h"
  14. #include "quadmod_bp.h"
  15. #include "spec_analyzer.h"
  16. #include "quad_carr_genie.h"
  17. #include "quad_mixer_bp.h"
  18. #include "integ_n_dump.h"
  19. #include "qam_decoder.h"
  20. #include "m_pskharddem.h"
  21. #include "ser_ctr.h"
  22. #include "siganchr.h"
  23. #include "qam_theory.h"
  24. //=========================================================
  25. main()
  26. {
  27. #include "sim_preamble.cpp"
  28.   //=========================================================================
  29.   //  Misc special processing
  30.   //-----------------------------------------------------
  31.   // create plot file of theoretical PSD for QPSK signal
  32.    int big_m;
  33.    GET_INT_PARM( big_m );
  34.    QamPsd(  big_m,
  35.             0.0,  // carrier_freq
  36.             1.0,  // symb_energy,
  37.             1.0,  // symb_intvl,
  38.             -4.0, // beg_freq,
  39.             4.0,  // end_freq,
  40.             801,  // num_pts,
  41.             true, // plot_in_db,
  42.             "msk_psd_theor.txt"); //out_filename
  43.   //-----------------------------------------------------
  44.   // create plot file of BER for ideal QPSK
  45.   QamBer(  big_m,
  46.             -10.0,  // beg_ebno,
  47.             18.0, // end_ebno,
  48.             401,  // num_pts,
  49.             "theor_msk_ber.txt");  // out_filename
  50.   //=========================================================================
  51.   //  Allocate signals
  52.   BYTE_SIGNAL(symb_vals);
  53.   BYTE_SIGNAL(mapped_symb_vals);
  54.   FLOAT_SIGNAL(i_baseband_wave);
  55.   FLOAT_SIGNAL(q_baseband_wave);
  56.   FLOAT_SIGNAL(modulated_signal);
  57.   FLOAT_SIGNAL(noisy_sig);
  58.   FLOAT_SIGNAL(i_recov_carrier_sig);
  59.   FLOAT_SIGNAL(q_recov_carrier_sig);
  60.   FLOAT_SIGNAL(i_demod_wave);
  61.   FLOAT_SIGNAL(q_demod_wave);
  62.   FLOAT_SIGNAL(i_samp_wave);
  63.   FLOAT_SIGNAL(q_samp_wave);
  64.   BIT_SIGNAL(symb_clock);
  65.   COMPLEX_SIGNAL(cmpx_integ_sig);
  66.   FLOAT_SIGNAL(power_meas_sig);
  67.   FLOAT_SIGNAL(mag_signal);
  68.   FLOAT_SIGNAL(phase_signal);
  69.   BYTE_SIGNAL(symb_decis);
  70.   BYTE_SIGNAL(symb_err_seq);
  71.   //============================================================
  72.   //  Construct, initialize and connect models
  73.   SymbGener* symb_gen = new SymbGener( "symb_gen",
  74.                                       CommSystem,
  75.                                       symb_vals );
  76. //  SymbRemapper* symb_mapper = new SymbRemapper( "symb_mapper",
  77. //                                                CommSystem,
  78. //                                                symb_vals,
  79. //                                                mapped_symb_vals);
  80.   QamSymbsToQuadWaves* qam_mod = new QamSymbsToQuadWaves( 
  81.                                                 "qam_mod",
  82.                                                 CommSystem,
  83.                                                 symb_vals,
  84.                                                 i_baseband_wave,
  85.                                                 q_baseband_wave,
  86.                                                 symb_clock);
  87.   QuadBandpassModulator* quad_mod = new QuadBandpassModulator( "quad_mod",
  88.                                                         CommSystem,
  89.                                                         i_baseband_wave,
  90.                                                         q_baseband_wave,
  91.                                                         modulated_signal);
  92.   AdditiveGaussianNoise<float>* agn_source = 
  93.                   new AdditiveGaussianNoise<float>( 
  94.                                                 "agn_source",
  95.                                                 CommSystem,
  96.                                                 modulated_signal,
  97.                                                 noisy_sig,
  98.                                                 power_meas_sig);
  99.   SpectrumAnalyzer<float>* modulator_spec_an = 
  100.                   new SpectrumAnalyzer<float>( 
  101.                                                   "modulator_spec_an",
  102.                                                   CommSystem,
  103.                                                   modulated_signal );
  104.   QuadCarrierRecovGenie* carrier_recovery = new QuadCarrierRecovGenie( "carrier_recovery",
  105.                                                                    CommSystem,
  106.                                                                    i_recov_carrier_sig,
  107.                                                                    q_recov_carrier_sig);
  108.   
  109.   QuadBandpassMixer* quad_dem = new QuadBandpassMixer( "quad_dem",
  110.                                                    CommSystem,
  111.                                                    noisy_sig,
  112.                                                    i_recov_carrier_sig,
  113.                                                    q_recov_carrier_sig,
  114.                                                    i_demod_wave,
  115.                                                    q_demod_wave );
  116.   IntegrateAndDump* i_integrator = new IntegrateAndDump( "i_integrator",
  117.                                            CommSystem,
  118.                                            i_demod_wave,
  119.                                            symb_clock,
  120.                                            i_samp_wave);
  121.   IntegrateAndDump* q_integrator = new IntegrateAndDump( "q_integrator",
  122.                                            CommSystem,
  123.                                            q_demod_wave,
  124.                                            symb_clock,
  125.                                            q_samp_wave);
  126.   QamSymbolDecoder* qam_demod = new QamSymbolDecoder( 
  127.                                                    "qam_demod",
  128.                                                     CommSystem,
  129.                                                     i_samp_wave,
  130.                                                     q_samp_wave,
  131.                                                     symb_decis);
  132.   
  133.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  134.                                                 CommSystem,
  135.                                                 modulated_signal,
  136.                                                 0.015625, //samp_intvl
  137.                                                 4096 ); //block_size
  138.   SerCounter* ser_ctr = new SerCounter( "ser_ctr",
  139.                                         CommSystem,
  140.                                         symb_vals,
  141.                                         symb_decis,
  142.                                         symb_err_seq );
  143.   //=============================================================
  144.   #include "sim_postamble.cpp"
  145.   return 0;
  146. }