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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = msk_sim.cpp
  3. //
  4. #define SIM_NAME "MskSim"
  5. #define SIM_TITLE "Complex Baseband Simulation for MSK"
  6. #include "global_stuff.h" 
  7. #include "gausrand.h"
  8. #include "bitgen.h"
  9. #include "bitwav.h"
  10. #include "mskmod.h"
  11. #include "add_gaus_noise.h"
  12. #include "spec_analyzer.h"
  13. #include "phase_genie.h"
  14. #include "quaddem.h"
  15. #include "qpskdem.h"
  16. #include "msk_genie.h"
  17. #include "integ_dump_slice.h"
  18. #include "discrete_delay_T.h"
  19. #include "ber_ctr.h"
  20. #include "siganchr.h"
  21. #include "msk_theory.h"
  22. #include "sigstuff.h"
  23. #include "parmfile.h"
  24. #include "model_graph.h"
  25. #include "sigplot.h"
  26. #include "reports.h"
  27. #include "exec.h"
  28. #include "psstream.h"
  29.    
  30. //#ifdef _DEBUG
  31. // ofstream DebugFile("MskModulator.dbg", ios::out);
  32. //#endif
  33. //=========================================================
  34. //  Global Stuff
  35. //ParmFile ParmInput("MskModulator.dat");
  36. //ofstream LongReport;
  37. //ofstream ShortReport;
  38. //PracSimStream DetailedResults;
  39. //PracSimStream BasicResults;
  40. //PracSimStream ErrorStream;
  41. //PracSimModel *CommSystem;
  42. //ActiveSystemGraph ActSystGraph;
  43. //Executive Exec;
  44. //PracSimModel *PrevModelConstr;
  45. //PracSimModel *ActiveModel;
  46. //SignalPlotter SigPlot;
  47. //int PassNumber;
  48. //int MaxPassNumber;
  49. //int EnclaveNumber;
  50. //=========================================================
  51. main()
  52. {
  53. #include "sim_preamble.cpp"
  54.   //=========================================================================
  55.   //  Misc special processing
  56.   //-----------------------------------------------------
  57.   // create plot file of theoretical PSD for MSK signal
  58.   MskPsd(  0.0,  // carrier_freq
  59.             1.0,  // symb_energy,
  60.             1.0,  // symb_intvl,
  61.             -4.0, // beg_freq,
  62.             4.0,  // end_freq,
  63.             801,  // num_pts,
  64.             true, // plot_in_db,
  65.             "msk_psd_theor.txt"); //out_filename
  66.   //-----------------------------------------------------
  67.   // create plot file of BER for ideal MSK
  68.   MskBer(  -10.0,  // beg_ebno,
  69.             18.0, // end_ebno,
  70.             401,  // num_pts,
  71.             "theor_msk_ber.txt");  // out_filename
  72.   //=========================================================================
  73.   //  Allocate signals
  74.   BIT_SIGNAL(i_bits);
  75.   BIT_SIGNAL(q_bits);
  76.   BIT_SIGNAL(q_bits_delayed);
  77.   FLOAT_SIGNAL(i_baseband_wave);
  78.   FLOAT_SIGNAL(q_baseband_wave);
  79.   BIT_SIGNAL(i_bit_clock);
  80.   BIT_SIGNAL(q_bit_clock);
  81.   FLOAT_SIGNAL(i_filtered_wave);
  82.   FLOAT_SIGNAL(q_filtered_wave);
  83.   COMPLEX_SIGNAL(modulated_signal);
  84.   COMPLEX_SIGNAL(filtered_sig);
  85.   COMPLEX_SIGNAL(noisy_sig);
  86.   COMPLEX_SIGNAL(phase_ref_sig);
  87.   FLOAT_SIGNAL(power_meas_sig);
  88.   FLOAT_SIGNAL(mag_signal);
  89.   FLOAT_SIGNAL(phase_signal);
  90.   FLOAT_SIGNAL(i_demod_wave);
  91.   FLOAT_SIGNAL(q_demod_wave);
  92.   FLOAT_SIGNAL(i_corr_sig);
  93.   FLOAT_SIGNAL(q_corr_sig);
  94.   FLOAT_SIGNAL(i_filt_demod_wave);
  95.   FLOAT_SIGNAL(q_filt_demod_wave);
  96.   FLOAT_SIGNAL(i_samp_demod_wave);
  97.   FLOAT_SIGNAL(q_samp_demod_wave);
  98.   BIT_SIGNAL(i_bit_decis);
  99.   BIT_SIGNAL(q_bit_decis);
  100.   //============================================================
  101.   //  Construct, initialize and connect models
  102.   EnclaveNumber = 0;
  103.   BitGener* i_bit_gen = new BitGener( "i_bit_gen",
  104.                                       CommSystem,
  105.                                       i_bits );
  106.   BitGener* q_bit_gen = new BitGener( "q_bit_gen",
  107.                                       CommSystem,
  108.                                       q_bits );
  109.   DiscreteDelay<bit_t>* q_bit_delay = new DiscreteDelay<bit_t>( 
  110.                                 "q_bit_delay",
  111.                                 CommSystem,
  112.                                 q_bits,
  113.                                 q_bits_delayed);
  114.   BitsToWave* i_wave_gen = new BitsToWave( "i_wave_gen",
  115.                                            CommSystem,
  116.                                            i_bits,
  117.                                            i_baseband_wave,
  118.                                            i_bit_clock );
  119.   BitsToWave* q_wave_gen = new BitsToWave( "q_wave_gen",
  120.                                            CommSystem,
  121.                                            q_bits,
  122.                                            q_baseband_wave,
  123.                                            q_bit_clock );
  124.   MskModulator* msk_mod = new MskModulator( "msk_mod",
  125.                                             CommSystem,
  126.                                             i_baseband_wave,
  127.                                             q_baseband_wave,
  128.                                             modulated_signal,
  129.                                             mag_signal,
  130.                                             phase_signal );
  131.   
  132.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  133.                   new AdditiveGaussianNoise<std::complex<float> >( 
  134.                                                 "agn_source",
  135.                                                 CommSystem,
  136.                                                 modulated_signal,
  137.                                                 noisy_sig,
  138.                                                 power_meas_sig);
  139.   SpectrumAnalyzer<std::complex<float> >* modulator_spec_an = 
  140.                   new SpectrumAnalyzer<std::complex<float> >( 
  141.                                                   "modulator_spec_an",
  142.                                                   CommSystem,
  143.                                                   modulated_signal );
  144.    PhaseRecoveryGenie* phase_genie = new PhaseRecoveryGenie( "phase_genie",
  145.                                                             CommSystem,
  146.                                                             phase_ref_sig);
  147.    QuadratureDemod* quad_demod = new QuadratureDemod( "quad_demod",
  148.                                                       CommSystem,
  149.                                                       noisy_sig,
  150.                                                       phase_ref_sig,
  151.                                                       i_demod_wave,
  152.                                                       q_demod_wave);
  153. //  QpskDemodulator* qpsk_dem = new QpskDemodulator( "qpsk_dem",
  154. //                                                    CommSystem,
  155. //                                                    noisy_sig,
  156. //                                                    i_demod_wave,
  157. //                                                    q_demod_wave);
  158.   SignalAnchor* temp_anchor = new SignalAnchor( "temp_anchor_1",
  159.                                                 CommSystem,
  160.                                                 i_baseband_wave,
  161.                                                 q_baseband_wave,
  162.                                                 0.0625, //samp_intvl
  163.                                                 4096 ); //block_size
  164.    MskShapeGenie* msk_genie = new MskShapeGenie( "msk_genie",
  165.                                                    CommSystem,
  166.                                                    i_corr_sig,
  167.                                                    q_corr_sig);
  168.   IntegrateDumpAndSlice* i_bit_slicer = new IntegrateDumpAndSlice( "i_bit_slicer",
  169.                                           CommSystem,
  170.                                           i_demod_wave,
  171.                                           //i_corr_sig,
  172.                                           i_bit_clock,
  173.                                           i_samp_demod_wave,
  174.                                           i_bit_decis );
  175.   BerCounter* i_ber_ctr = new BerCounter( "i_ber_ctr",
  176.                                         CommSystem,
  177.                                         i_bits,
  178.                                         i_bit_decis );
  179.   IntegrateDumpAndSlice* q_bit_slicer = new IntegrateDumpAndSlice( "q_bit_slicer",
  180.                                           CommSystem,
  181.                                           q_demod_wave,
  182.                                           //q_corr_sig,
  183.                                           q_bit_clock,
  184.                                           q_samp_demod_wave,
  185.                                           q_bit_decis );
  186.   BerCounter* q_ber_ctr = new BerCounter( "q_ber_ctr",
  187.                                         CommSystem,
  188.                                         q_bits_delayed,
  189.                                         q_bit_decis );
  190.   //=============================================================
  191.   #include "sim_postamble.cpp"
  192.   return 0;
  193. }