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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = filter_testbed_sim.cpp
  3. //
  4. #define SIM_NAME "Filters"
  5. #define SIM_TITLE "Testbed for Butterworth Filter"
  6. #include "global_stuff.h" 
  7. #include "bitgen.h"
  8. #include "bitwav.h"
  9. #include "stepgen.h"
  10. #include "noise_gen.h"
  11. #include "swep_tone_xmtr.h"
  12. #include "swep_tone_rcvr.h"
  13. #include "siganchr.h"
  14. #include "spec_analyzer.h"
  15. #include "butt_filt_iir.h"
  16. #include "butt_filt_intg.h"
  17. #include "cheb_filt_iir.h"
  18. #include "cheb_filt_intg.h"
  19. #include "elip_filt_iir.h"
  20. #include "elip_filt_intg.h"
  21. #include "bess_filt_iir.h"
  22. #include "ampl_to_db_pwr.h"
  23. #include "fsk_theory.h"
  24. //=========================================================
  25. main()
  26. {
  27. #include "sim_preamble.cpp"
  28.    int System_Mode_Switch_1;
  29.    System_Mode_Switch_1 = ParmInput->GetIntParm("System_Mode_Switch_1");
  30.   //=========================================================================
  31.   //  Misc special processing
  32.   //=========================================================================
  33.   //  Allocate signals
  34.   BIT_SIGNAL(bit_seq);
  35.   BIT_SIGNAL(bit_clock);
  36.   //FLOAT_SIGNAL(square_pulse_wave);
  37.   FLOAT_SIGNAL(test_sig);
  38.   FLOAT_SIGNAL(baseband_wave);
  39.   FLOAT_SIGNAL(db_pwr_sig);
  40.   FLOAT_SIGNAL(swept_rx_output);
  41.   //============================================================
  42.   //  Construct, initialize and connect models
  43.   StepGener* step_gen = new StepGener( "step_gen",
  44.                                       CommSystem,
  45.                                       test_sig );
  46. //  BitGener* bit_gen = new BitGener( "bit_gen",
  47. //                                      CommSystem,
  48. //                                      bit_seq );
  49. //  BitsToWave* wave_gen = new BitsToWave( "wave_gen",
  50. //                                           CommSystem,
  51. //                                           bit_seq,
  52. //                                           test_sig,
  53. //                                           bit_clock );
  54. //  GaussianNoiseGenerator *noise_gen = new GaussianNoiseGenerator( "noise_gen",
  55. //                                                                  CommSystem,
  56. //                                                                  test_sig);
  57. //   Control<bool> *rx_enable = new Control<bool>(   "rx_enable",
  58. //                                                   CommSystem);
  59. //   Control<double> *swept_freq_ctl = new Control<double>( 
  60. //                                                      "swept_freq_ctl",
  61. //                                                      CommSystem);
  62. //   Control<double> *block_phase_ctl = new Control<double>( 
  63. //                                                      "block_phase_ctl",
  64. //                                                      CommSystem);
  65. //   SweptToneTransmitter *tone_xmtr = new SweptToneTransmitter( "tone_xmtr",
  66. //                                        CommSystem,
  67. //                                        test_sig,
  68. //                                        rx_enable,
  69. //                                        swept_freq_ctl,
  70. //                                        block_phase_ctl );
  71.   //SpectrumAnalyzer<float>* input_spec_an = 
  72.   //                new SpectrumAnalyzer<float>( 
  73.   //                                            "input_spec_an",
  74.   //                                            CommSystem,
  75.   //                                            test_sig );
  76.   //EllipticalFilterByInteg* base_filt = new EllipticalFilterByInteg( "base_filt",
  77.   //ButterworthFilterByInteg* base_filt = new ButterworthFilterByInteg( "base_filt",
  78.   //ChebyshevFilterByInteg* base_filt = new ChebyshevFilterByInteg( "base_filt",
  79.   //BesselFilterByInteg* base_filt = new BesselFilterByInteg( "base_filt",
  80.    if(System_Mode_Switch_1==0)
  81.    {
  82.      ButterworthFilterByInteg* base_filt = new ButterworthFilterByInteg( "base_filt",
  83.                                                         CommSystem,
  84.                                                         test_sig,
  85.                                                         baseband_wave);
  86.    }
  87.    else
  88.    {
  89.       ButterworthFilterByIir<float>* base_filt = new ButterworthFilterByIir<float>( "base_filt",
  90.                                                         CommSystem,
  91.                                                         test_sig,
  92.                                                         baseband_wave);
  93.       //SubordFilterTestShell<float>* base_filt = new SubordFilterTestShell<float>( "base_filt",
  94.       //                                                  CommSystem,
  95.       //                                                  test_sig,
  96.       //                                                  baseband_wave);
  97.    }
  98.    AmplitudeToDbPower* db_converter = new AmplitudeToDbPower( "db_converter",
  99.                                 CommSystem,
  100.                                 baseband_wave,
  101.                                 db_pwr_sig);
  102.   SpectrumAnalyzer<float>* output_spec_an = 
  103.                   new SpectrumAnalyzer<float>( 
  104.                                               "output_spec_an",
  105.                                               CommSystem,
  106.                                               baseband_wave );
  107. //  SweptToneReceiver* tone_rcvr = new SweptToneReceiver( "tone_rcvr",
  108. //                                                         CommSystem,
  109. //                                                         baseband_wave,
  110. //                                                         test_sig,
  111. //                                                         swept_rx_output,
  112. //                                                         rx_enable,
  113. //                                                         swept_freq_ctl,
  114. //                                                         block_phase_ctl);
  115.   SignalAnchor* temp_anchor = new SignalAnchor( "temp_anchor",
  116.                                                 CommSystem,
  117.                                                 baseband_wave);
  118.                                              //   0.0078125, //samp_rate
  119.                                              //   4096 ); //block_size
  120. //  SignalAnchor* temp_anchor_3 = new SignalAnchor( "temp_anchor_3",
  121. //                                                CommSystem,
  122. //                                                ref_seq,
  123. //                                                1.0, //samp_rate
  124. //                                                128 ); //block_size
  125.   //=============================================================
  126.   #include "sim_postamble.cpp"
  127.   return 0;
  128. }