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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = nla_2_box_sim.cpp
  3. //
  4. #define SIM_NAME "NLA_2_Box"
  5. #define SIM_TITLE "Complex Baseband Simulation for 2-Box NLA model"
  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 "qam_symbtowave.h"
  12. #include "add_gaus_noise.h"
  13. #include "mpsk_symbtowave.h"
  14. #include "quadmod.h"
  15. #include "spec_analyzer.h"
  16. #include "cmpx_iq_plot.h"
  17. #include "m_pskharddem.h"
  18. #include "ser_ctr.h"
  19. #include "siganchr.h"
  20. #include "nonlinear_amp.h"
  21. #include "polar_freq_dom_filt.h"
  22. #include "mpskoptimdem.h"
  23. #include "cpxtoquad.h"
  24. #include "quadcmpx.h"
  25. #include "andf1fir.h"
  26. //=========================================================
  27. main()
  28. {
  29. #include "sim_preamble.cpp"
  30.   //=========================================================================
  31.   //  Misc special processing
  32.   //=========================================================================
  33.   //  Allocate signals
  34.   BYTE_SIGNAL(symb_vals);
  35.   BYTE_SIGNAL(mapped_symb_vals);
  36.   FLOAT_SIGNAL(i_baseband_wave);
  37.   FLOAT_SIGNAL(q_baseband_wave);
  38.   COMPLEX_SIGNAL(modulated_signal);
  39.   COMPLEX_SIGNAL(noisy_sig);
  40.   COMPLEX_SIGNAL(nla_filt_sig);
  41.   COMPLEX_SIGNAL(ampl_sig);
  42.   COMPLEX_SIGNAL(filtered_rx_sig);
  43.   BIT_SIGNAL(symb_clock);
  44.   COMPLEX_SIGNAL(cmpx_integ_sig);
  45.   FLOAT_SIGNAL(power_meas_sig);
  46.   FLOAT_SIGNAL(mag_signal);
  47.   FLOAT_SIGNAL(phase_signal);
  48.   BYTE_SIGNAL(symb_decis);
  49.   BYTE_SIGNAL(symb_err_seq);
  50.   FLOAT_SIGNAL(i_demod_sig);
  51.   FLOAT_SIGNAL(q_demod_sig);
  52.   FLOAT_SIGNAL(i_filt_sig);
  53.   FLOAT_SIGNAL(q_filt_sig);
  54.   //============================================================
  55.   //  Construct, initialize and connect models
  56.   SymbGener* symb_gen = new SymbGener( "symb_gen",
  57.                                       CommSystem,
  58.                                       symb_vals );
  59.   SymbRemapper* symb_mapper = new SymbRemapper( "symb_mapper",
  60.                                                 CommSystem,
  61.                                                 symb_vals,
  62.                                                 mapped_symb_vals);
  63.   MpskSymbsToQuadWaves* m_psk_mod = new MpskSymbsToQuadWaves( 
  64.                                                 "m_psk_mod",
  65.                                                 CommSystem,
  66.                                                 mapped_symb_vals,
  67.                                                 i_baseband_wave,
  68.                                                 q_baseband_wave,
  69.                                                 symb_clock);
  70. //    QamSymbsToQuadWaves* qam_mod = new QamSymbsToQuadWaves( 
  71. //                                                "qam_mod",
  72. //                                                CommSystem,
  73. //                                                symb_vals,
  74. //                                                i_baseband_wave,
  75. //                                                q_baseband_wave,
  76. //                                                symb_clock);
  77. QuadratureModulator* quad_mod = new QuadratureModulator( "quad_mod",
  78.                                                         CommSystem,
  79.                                                         i_baseband_wave,
  80.                                                         q_baseband_wave,
  81.                                                         modulated_signal,
  82.                                                         mag_signal,
  83.                                                         phase_signal);
  84.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  85.                   new AdditiveGaussianNoise<std::complex<float> >( 
  86.                                                 "agn_source",
  87.                                                 CommSystem,
  88.                                                 modulated_signal,
  89.                                                 noisy_sig,
  90.                                                 power_meas_sig);
  91.    PolarFreqDomainFilter* nla_filt = new PolarFreqDomainFilter( "nla_filt",
  92.                                                                 CommSystem,
  93.                                                                 noisy_sig,
  94.                                                                 nla_filt_sig);
  95. //  SpectrumAnalyzer<std::complex<float> >* spec_analyzer_2 = 
  96. //                  new SpectrumAnalyzer<std::complex<float> >( 
  97. //                                                  "spec_analyzer_2",
  98. //                                                  CommSystem,
  99. //                                                  nla_filt_sig );
  100.    NonlinearAmplifier* nonlin_amp = new NonlinearAmplifier( "nonlin_amp",
  101.                                                             CommSystem,
  102.                                                             nla_filt_sig,
  103.                                                             ampl_sig);
  104. //  AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  105. //                  new AdditiveGaussianNoise<std::complex<float> >( 
  106. //                                                "agn_source",
  107. //                                                CommSystem,
  108. //                                                nla_filt_sig,
  109. //                                                noisy_sig,
  110. //                                                power_meas_sig);
  111.   SpectrumAnalyzer<std::complex<float> >* spec_analyzer_1 = 
  112.                   new SpectrumAnalyzer<std::complex<float> >( 
  113.                                                   "spec_analyzer_1",
  114.                                                   CommSystem,
  115.                                                   noisy_sig );
  116. CmpxToQuadrature* quad_demod = new CmpxToQuadrature( "quad_demod",
  117.                                                       CommSystem,
  118.                                                       ampl_sig,
  119.                                                       i_demod_sig,
  120.                                                       q_demod_sig);
  121.    AnlgDirectFormFir* i_rx_filt = new AnlgDirectFormFir( "i_rx_filt",
  122.                                                           CommSystem,
  123.                                                           i_demod_sig,
  124.                                                           i_filt_sig );
  125.    AnlgDirectFormFir* q_rx_filt = new AnlgDirectFormFir( "q_rx_filt",
  126.                                                           CommSystem,
  127.                                                           q_demod_sig,
  128.                                                           q_filt_sig );
  129.    QuadratureToComplex* i_q_combiner = new QuadratureToComplex( "i_q_combiner",
  130.                                                                   CommSystem,
  131.                                                                   i_filt_sig,
  132.                                                                   q_filt_sig,
  133.                                                                   filtered_rx_sig);
  134.   SpectrumAnalyzer<std::complex<float> >* spec_analyzer_3 = 
  135.                   new SpectrumAnalyzer<std::complex<float> >( 
  136.                                                   "spec_analyzer_3",
  137.                                                   CommSystem,
  138.                                                   filtered_rx_sig );
  139.   MpskOptimalDemod* m_psk_dem = new MpskOptimalDemod( "m_psk_dem",
  140.                                                     CommSystem,
  141.                                                     noisy_sig,
  142.                                                     symb_clock,
  143.                                                     symb_decis);
  144.   
  145.   CmpxIqPlot* iq_plot = new CmpxIqPlot( "iq_plot",
  146.                                         CommSystem,
  147.                                         noisy_sig,
  148.                                         symb_clock);
  149.   
  150.   CmpxIqPlot* filt_iq_plot = new CmpxIqPlot( "filt_iq_plot",
  151.                                         CommSystem,
  152.                                         filtered_rx_sig,
  153.                                         symb_clock);
  154.   
  155. //  CmpxIqPlot* amp_iq_plot = new CmpxIqPlot( "amp_iq_plot",
  156. //                                        CommSystem,
  157. //                                        ampl_sig,
  158. //                                        symb_clock);
  159.   
  160.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  161.                                                 CommSystem,
  162.                                                 modulated_signal,
  163.                                                 0.0625, //samp_intvl
  164.                                                 4080 ); //block_size
  165.   SerCounter* ser_ctr = new SerCounter( "ser_ctr",
  166.                                         CommSystem,
  167.                                         mapped_symb_vals,
  168.                                         symb_decis,
  169.                                         symb_err_seq );
  170.   //=============================================================
  171.   #include "sim_postamble.cpp"
  172.   return 0;
  173. }