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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = interpolate_2_sim.cpp
  3. //
  4. #define SIM_NAME "Interpolate_2"
  5. #define SIM_TITLE "Simple Interpolation"
  6. #include "global_stuff.h" 
  7. #include "tone_gen.h"
  8. #include "multi_tone_gen.h"
  9. #include "andf1fir.h"
  10. #include "cpxtophs.h"
  11. #include "siganchr.h"
  12. #include "ms_error_T.h"
  13. #include "upsampler_T.h"
  14. #include "downsampler_T.h"
  15. #include "discrete_delay_T.h"
  16. #include "spec_analyzer.h"
  17. #include "correlator.h"
  18. #include "contin_delay2_T.h"
  19. #include "add_gaus_noise.h"
  20. //=========================================================
  21. main()
  22. {
  23. #include "sim_preamble.cpp"
  24.   //=========================================================================
  25.   //  Misc special processing
  26.   //=========================================================================
  27.   //  Allocate signals
  28.   FLOAT_SIGNAL(test_sig);
  29.   FLOAT_SIGNAL(noisy_test_sig);
  30.   FLOAT_SIGNAL(noise_only_sig);
  31.   FLOAT_SIGNAL(filt_noise_only_sig);
  32.   FLOAT_SIGNAL(filt_noiseless_sig);
  33.   FLOAT_SIGNAL(noise_only_upsamp_sig);
  34.   FLOAT_SIGNAL(ref_sig);
  35.   FLOAT_SIGNAL(delayed_ref_sig);
  36.   FLOAT_SIGNAL(upsamp_test_sig);
  37.   FLOAT_SIGNAL(noiseless_upsamp_sig);
  38.   FLOAT_SIGNAL(filt_sig);
  39.   FLOAT_SIGNAL(correl_out_sig);
  40.   //FLOAT_SIGNAL(interm_filt_sig_1);
  41.   //FLOAT_SIGNAL(interm_filt_sig_2);
  42.   FLOAT_SIGNAL(delayed_filt_sig);
  43.   FLOAT_SIGNAL(power_meas_sig);
  44.   //============================================================
  45.   //  Construct, initialize and connect models
  46. //   ToneGener* sig_gen = new  ToneGener( "sig_gen",
  47. //                                       CommSystem,
  48. //                                       test_sig );
  49. //   MultipleSineGener* sine_gen_1 = new MultipleSineGener( "sine_gen_1",
  50. //                       CommSystem,
  51. //                       test_sig );
  52.    MultipleToneGener* ref_sine_gen = new MultipleToneGener( "ref_sine_gen",
  53.                        CommSystem,
  54.                        ref_sig );
  55.    Downsampler<float> *downsampler = new Downsampler<float>("downsampler",
  56.                                                             CommSystem,
  57.                                                             ref_sig,
  58.                                                             test_sig);
  59.    AdditiveGaussianNoise<float>* noise_gen = new AdditiveGaussianNoise<float> (
  60.                                               "noise_gen",
  61.                                               CommSystem,
  62.                                               test_sig,
  63.                                               noisy_test_sig,
  64.                                               noise_only_sig,
  65.                                               power_meas_sig);
  66.    MeanSquareError< float >* noise_meter = new MeanSquareError<float>( 
  67.                                                    "noise_meter",
  68.                                                    CommSystem,
  69.                                                    noisy_test_sig,
  70.                                                    test_sig);
  71.    SpectrumAnalyzer<float>* spec_analyzer_0 = 
  72.                   new SpectrumAnalyzer<float>(  "spec_analyzer_0",
  73.                                                 CommSystem,
  74.                                                 ref_sig );
  75.    SpectrumAnalyzer<float>* spec_analyzer_1 = 
  76.                   new SpectrumAnalyzer<float>(  "spec_analyzer_1",
  77.                                                 CommSystem,
  78.                                                 noisy_test_sig );
  79.    SpectrumAnalyzer<float>* spec_analyzer_4 = 
  80.                   new SpectrumAnalyzer<float>(  "spec_analyzer_4",
  81.                                                 CommSystem,
  82.                                                 test_sig );
  83.    SpectrumAnalyzer<float>* spec_analyzer_5 = 
  84.                   new SpectrumAnalyzer<float>(  "spec_analyzer_5",
  85.                                                 CommSystem,
  86.                                                 noise_only_sig );
  87.    Upsampler< float > *upsampler = new Upsampler<float>( "upsampler",
  88.                                 CommSystem,
  89.                                 noisy_test_sig,
  90.                                 upsamp_test_sig );
  91.    Upsampler< float > *noiseless_upsampler = new Upsampler<float>( "noiseless_upsampler",
  92.                                 CommSystem,
  93.                                 test_sig,
  94.                                 noiseless_upsamp_sig );
  95.    Upsampler< float > *noise_only_upsampler = new Upsampler<float>( "noise_only_upsampler",
  96.                                 CommSystem,
  97.                                 noise_only_sig,
  98.                                 noise_only_upsamp_sig );
  99.    MeanSquareError< float >* upsamp_meter = new MeanSquareError<float>( 
  100.                                                    "upsamp_meter",
  101.                                                    CommSystem,
  102.                                                    upsamp_test_sig,
  103.                                                    noiseless_upsamp_sig);
  104.    SpectrumAnalyzer<float>* spec_analyzer_2 = 
  105.                   new SpectrumAnalyzer<float>(  "spec_analyzer_2",
  106.                                                 CommSystem,
  107.                                                 upsamp_test_sig );
  108.    SpectrumAnalyzer<float>* spec_analyzer_8 = 
  109.                   new SpectrumAnalyzer<float>(  "spec_analyzer_8",
  110.                                                 CommSystem,
  111.                                                 noise_only_upsamp_sig );
  112. //   SincInterpolator* recon_box = 
  113. //                  new SincInterpolator(   "recon_box",
  114. //                                          CommSystem,
  115. //                                          tone_sig);
  116.    AnlgDirectFormFir* direct_fir = new AnlgDirectFormFir( "direct_fir",
  117.                                                           CommSystem,
  118.                                                           upsamp_test_sig,
  119.                                                           filt_sig );
  120.    AnlgDirectFormFir* direct_fir_2 = new AnlgDirectFormFir( "direct_fir_2",
  121.                                                           CommSystem,
  122.                                                           noiseless_upsamp_sig,
  123.                                                           filt_noiseless_sig );
  124.    AnlgDirectFormFir* direct_fir_3 = new AnlgDirectFormFir( "direct_fir_3",
  125.                                                           CommSystem,
  126.                                                           noise_only_upsamp_sig,
  127.                                                           filt_noise_only_sig );
  128.    MeanSquareError< float >* filt_meter = new MeanSquareError<float>( 
  129.                                                    "filt_meter",
  130.                                                    CommSystem,
  131.                                                    filt_sig,
  132.                                                    filt_noiseless_sig);
  133.    SpectrumAnalyzer<float>* spec_analyzer_3 = 
  134.                   new SpectrumAnalyzer<float>(  "spec_analyzer_3",
  135.                                                 CommSystem,
  136.                                                 filt_sig );
  137.    SpectrumAnalyzer<float>* spec_analyzer_6 = 
  138.                   new SpectrumAnalyzer<float>(  "spec_analyzer_6",
  139.                                                 CommSystem,
  140.                                                 filt_noiseless_sig );
  141.    SpectrumAnalyzer<float>* spec_analyzer_7 = 
  142.                   new SpectrumAnalyzer<float>(  "spec_analyzer_7",
  143.                                                 CommSystem,
  144.                                                 filt_noise_only_sig );
  145.   Control<float>* delay_at_max_corr = new Control<float>( "delay_at_max_corr",
  146.                                                    CommSystem );
  147.   Control<int>* samps_delay_at_max_corr = new Control<int>( "samps_delay_at_max_corr",
  148.                                                    CommSystem );
  149. //   RealCorrelator *ref_correl = new RealCorrelator( "ref_correl",
  150. //                                                      CommSystem,
  151. //                                                      filt_sig,
  152. //                                                      ref_sig,
  153. //                                                      correl_out_sig,
  154. //                                                      delay_at_max_corr,
  155. //                                                      samps_delay_at_max_corr);
  156. //   ContinuousDelay2< float >* cont_ref_delay = new ContinuousDelay2< float >( 
  157. //                                                               "cont_ref_delay",
  158. //                                                               CommSystem,
  159. //                                                               ref_sig,
  160. //                                                               delayed_ref_sig);
  161.    DiscreteDelay< float >* ref_delay = new DiscreteDelay<float>( "ref_delay",
  162.                                                                  CommSystem,
  163.                                                                  ref_sig,
  164.                                                                  delayed_ref_sig);
  165.    DiscreteDelay< float >* filt_delay = new DiscreteDelay<float>( "filt_delay",
  166.                                                                  CommSystem,
  167.                                                                  filt_sig,
  168.                                                                  delayed_filt_sig);
  169.    MeanSquareError< float >* error_meter = new MeanSquareError<float>( 
  170.                                                    "error_meter",
  171.                                                    CommSystem,
  172.                                                    delayed_filt_sig,
  173.                                                    delayed_ref_sig);
  174.    SignalAnchor* temp_ref_anchor = new SignalAnchor( "temp_ref_anchor",
  175.                                                       CommSystem,
  176.                                                       ref_sig);
  177.    SignalAnchor* temp_anchor = new SignalAnchor( "temp_anchor",
  178.                                                 CommSystem,
  179.                                                 test_sig);
  180.   //=============================================================
  181.   #include "sim_postamble.cpp"
  182.   return 0;
  183. }