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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = digital_pll_sim.cpp
  3. //
  4. #define SIM_NAME "DigitalPLL"
  5. #define SIM_TITLE "Simulation of Digital PLL"
  6. #include "global_stuff.h" 
  7. #include "qpsk_theory.h"
  8. #include "bitgen.h"
  9. #include "bitwav.h"
  10. #include "siganchr.h"
  11. #include "bpsk_mod_bp.h"
  12. #include "phase_rotate.h"
  13. #include "add_gaus_noise.h"
  14. #include "butt_filt_iir.h"
  15. #include "spec_analyzer.h"
  16. #include "quad_carr_genie.h"
  17. #include "digital_pll.h"
  18. #include "contin_delay_T.h"
  19. #include "mixer_bp.h"
  20. #include "quad_mixer_bp.h"
  21. #include "integ_dump_slice.h"
  22. #include "qpskoptbitdem.h"
  23. #include "ber_ctr.h"
  24. #include "qpsk_err_ctr.h"
  25. #include "multi_tone_gen.h"
  26. main()
  27. {
  28. #include "sim_preamble.cpp"
  29.   //=========================================================================
  30.   //  Misc special processing
  31.   //=========================================================================
  32.   //  Allocate signals
  33.   BIT_SIGNAL(bit_vals);
  34.   FLOAT_SIGNAL(baseband_wave);
  35.   FLOAT_SIGNAL(modulated_signal);
  36.   FLOAT_SIGNAL(pll_err_sig);
  37.   FLOAT_SIGNAL(pll_filt_err_sig);
  38.   FLOAT_SIGNAL(pll_ref_sig);
  39.   FLOAT_SIGNAL(pll_vco_freq_sig);
  40.   FLOAT_SIGNAL(pll_ref_phase_sig);
  41.   FLOAT_SIGNAL(pll_u2_out_sig);
  42.   FLOAT_SIGNAL(delay_squared_signal);
  43.   FLOAT_SIGNAL(error_signal);
  44.   FLOAT_SIGNAL(filt_squared_signal);
  45.   FLOAT_SIGNAL(recov_carrier_sig);
  46.   FLOAT_SIGNAL(i_recov_carrier_sig);
  47.   FLOAT_SIGNAL(q_recov_carrier_sig);
  48.   FLOAT_SIGNAL(noisy_sig);
  49.   BIT_SIGNAL(symb_clock);
  50.   FLOAT_SIGNAL(power_meas_sig);
  51.   //============================================================
  52.   //  Construct, initialize and connect models
  53. //  BitGener* bit_gen = new BitGener( "bit_gen",
  54. //                                      CommSystem,
  55. //                                      bit_vals );
  56. //  BitsToWave* wave_gen = new BitsToWave( "wave_gen",
  57. //                                           CommSystem,
  58. //                                           bit_vals,
  59. //                                           baseband_wave,
  60. //                                           symb_clock );
  61. //  SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  62. //                                                CommSystem,
  63. //                                                baseband_wave,
  64. //                                                //q_baseband_wave,
  65. //                                                0.0078125, //samp_intvl
  66. //                                                4096 ); //block_size
  67. //  BpskBandpassModulator* bpsk_mod = new BpskBandpassModulator( "bpsk_mod",
  68. //                                                CommSystem,
  69. //                                                baseband_wave,
  70. //                                                modulated_signal);
  71.   
  72.    MultipleToneGener* sine_gen = new MultipleToneGener(   "sine_gen",
  73.                                                          CommSystem,
  74.                                                          modulated_signal );
  75.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  76.                                                 CommSystem,
  77.                                                 modulated_signal,
  78.                                                 //q_baseband_wave,
  79.                                                 0.0078125, //samp_intvl
  80.                                                 4096 ); //block_size
  81.   AdditiveGaussianNoise<float>* agn_source = 
  82.                   new AdditiveGaussianNoise<float>( 
  83.                                                 "agn_source",
  84.                                                 CommSystem,
  85.                                                 modulated_signal,
  86.                                                 noisy_sig,
  87.                                                 power_meas_sig);
  88. //  SpectrumAnalyzer<float>* spec_analyzer = 
  89. //                  new SpectrumAnalyzer<float>( 
  90. //                                                  "spec_analyzer",
  91. //                                                  CommSystem,
  92. //                                                  modulated_signal );
  93.    DigitalPLL* carr_recov_loop = new DigitalPLL( "carr_recov_loop",
  94.                                                 CommSystem,
  95.                                                 noisy_sig,
  96.                                                 pll_filt_err_sig,
  97.                                                 pll_ref_sig,
  98.                                                 pll_vco_freq_sig,
  99.                                                 pll_ref_phase_sig,
  100.                                                 recov_carrier_sig);
  101. //   ContinuousDelay< float >* loop_delay_elem = new ContinuousDelay<float>( "loop_delay_elem",
  102. //                                   CommSystem,
  103. //                                   squared_signal,
  104. //                                   delay_squared_signal);
  105. //   BandpassMixer* loop_mixer = new BandpassMixer( "loop_mixer",
  106. //                                                   CommSystem,
  107. //                                                   squared_signal,
  108. //                                                   delay_squared_signal,
  109. //                                                   error_signal );
  110. //  ButterworthFilterByIir<float>* double_freq_filter = 
  111. //            new ButterworthFilterByIir<float>( "double_freq_filter",
  112. //                                        CommSystem,
  113. //                                        squared_signal,
  114. //                                        filt_squared_signal );
  115. //  SpectrumAnalyzer<float>* spec_anal_2 = 
  116. //                  new SpectrumAnalyzer<float>( 
  117. //                                                  "spec_anal_2",
  118. //                                                  CommSystem,
  119. //                                                  squared_signal );
  120. //  SpectrumAnalyzer<float>* spec_anal_3 = 
  121. //                  new SpectrumAnalyzer<float>( 
  122. //                                                  "spec_anal_3",
  123. //                                                  CommSystem,
  124. //                                                  filt_squared_signal );
  125. //  QuadCarrierRecovGenie* carrier_recovery = new QuadCarrierRecovGenie( "carrier_recovery",
  126. //                                                                   CommSystem,
  127. //                                                                   i_recov_carrier_sig,
  128. //                                                                   q_recov_carrier_sig);
  129.   
  130. //  QuadBandpassMixer* quad_dem = new QuadBandpassMixer( "quad_dem",
  131. //                                                   CommSystem,
  132. //                                                   noisy_sig,
  133. //                                                   i_recov_carrier_sig,
  134. //                                                   q_recov_carrier_sig,
  135. //                                                   i_demod_wave,
  136. //                                                   q_demod_wave );
  137. //  IntegrateDumpAndSlice* i_bit_slicer = new IntegrateDumpAndSlice( "i_bit_slicer",
  138. //                                           CommSystem,
  139. //                                           i_demod_wave,
  140. //                                           symb_clock,
  141. //                                           i_samp_wave,
  142. //                                           i_bit_decis);
  143. //  IntegrateDumpAndSlice* q_bit_slicer = new IntegrateDumpAndSlice( "q_bit_slicer",
  144. //                                           CommSystem,
  145. //                                           q_demod_wave,
  146. //                                           q_symb_clock,
  147. //                                           q_samp_wave,
  148. //                                           q_bit_decis);
  149. //  BerCounter* i_ber_ctr = new BerCounter( "i_ber_ctr",
  150. //                                          CommSystem,
  151. //                                          i_bits,
  152. //                                          i_bit_decis );
  153. //  BerCounter* q_ber_ctr = new BerCounter( "q_ber_ctr",
  154. //                                          CommSystem,
  155. //                                          q_bits,
  156. //                                          q_bit_decis );
  157. //  QpskErrorCounter* ser_ctr = new QpskErrorCounter( "ser_ctr",
  158. //                                                    CommSystem,
  159. //                                                    i_bits,
  160. //                                                    q_bits,
  161. //                                                    i_bit_decis,
  162. //                                                    q_bit_decis );
  163.   //=============================================================
  164.   #include "sim_postamble.cpp"
  165.   return 0;
  166. }