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

3G开发

开发平台:

Visual C++

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