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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = sqr_loop_sim_bp.cpp
  3. //
  4. #define SIM_NAME "SqrLoopSim_Bp"
  5. #define SIM_TITLE "Bandpass Simulation of Squaring Loop"
  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 "linear_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. main()
  26. {
  27. #include "sim_preamble.cpp"
  28.   //=========================================================================
  29.   //  Misc special processing
  30.   //-----------------------------------------------------
  31.   // create plot file of theoretical PSD for QPSK signal
  32.   QpskPsd(  0.0,  // carrier_freq
  33.             1.0,  // symb_energy,
  34.             1.0,  // symb_intvl,
  35.             -4.0, // beg_freq,
  36.             4.0,  // end_freq,
  37.             801,  // num_pts,
  38.             true, // plot_in_db,
  39.             "qpsk_psd_theor.txt"); //out_filename
  40.   //-----------------------------------------------------
  41.   // create plot file of BER for ideal QPSK
  42.   QpskBer(  -10.0,  // beg_ebno,
  43.             18.0, // end_ebno,
  44.             401,  // num_pts,
  45.             "theor_qpsk_ber.txt");  // out_filename
  46.   //=========================================================================
  47.   //  Allocate signals
  48.   BIT_SIGNAL(bit_vals);
  49.   FLOAT_SIGNAL(baseband_wave);
  50.   FLOAT_SIGNAL(modulated_signal);
  51.   FLOAT_SIGNAL(pll_err_sig);
  52.   FLOAT_SIGNAL(pll_filt_err_sig);
  53.   FLOAT_SIGNAL(pll_ref_sig);
  54.   FLOAT_SIGNAL(pll_vco_phase_sig);
  55.   FLOAT_SIGNAL(pll_vco_freq_sig);
  56.   FLOAT_SIGNAL(squared_signal);
  57.   FLOAT_SIGNAL(error_signal);
  58.   FLOAT_SIGNAL(filt_squared_signal);
  59.   FLOAT_SIGNAL(recov_carrier_sig);
  60.   FLOAT_SIGNAL(i_recov_carrier_sig);
  61.   FLOAT_SIGNAL(q_recov_carrier_sig);
  62.   FLOAT_SIGNAL(noisy_sig);
  63.   //FLOAT_SIGNAL(sqrd_noisy_sig);
  64.   BIT_SIGNAL(symb_clock);
  65.   FLOAT_SIGNAL(power_meas_sig);
  66.   //============================================================
  67.   //  Construct, initialize and connect models
  68.   BitGener* bit_gen = new BitGener( "bit_gen",
  69.                                       CommSystem,
  70.                                       bit_vals );
  71.   BitsToWave* wave_gen = new BitsToWave( "wave_gen",
  72.                                            CommSystem,
  73.                                            bit_vals,
  74.                                            baseband_wave,
  75.                                            symb_clock );
  76.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  77.                                                 CommSystem,
  78.                                                 baseband_wave,
  79.                                                 //q_baseband_wave,
  80.                                                 0.0078125, //samp_intvl
  81.                                                 4096 ); //block_size
  82.   BpskBandpassModulator* bpsk_mod = new BpskBandpassModulator( "bpsk_mod",
  83.                                                 CommSystem,
  84.                                                 baseband_wave,
  85.                                                 modulated_signal);
  86.   
  87.   AdditiveGaussianNoise<float>* agn_source = 
  88.                   new AdditiveGaussianNoise<float>( 
  89.                                                 "agn_source",
  90.                                                 CommSystem,
  91.                                                 modulated_signal,
  92.                                                 noisy_sig,
  93.                                                 power_meas_sig);
  94.   SpectrumAnalyzer<float>* spec_analyzer = 
  95.                   new SpectrumAnalyzer<float>( 
  96.                                                   "spec_analyzer",
  97.                                                   CommSystem,
  98.                                                   modulated_signal );
  99. //   BandpassSquaringPLL* carr_recov_loop = new BandpassSquaringPLL( "carr_recov_loop",
  100. //                                                                     CommSystem,
  101. //                                                                     noisy_sig,
  102. //                                                                     sqrd_noisy_sig,
  103. //                                                                     pll_err_sig,
  104. //                                                                     pll_filt_err_sig,
  105. //                                                                     pll_ref_sig,
  106. //                                                                     pll_vco_freq_sig,
  107. //                                                                     pll_phase_sig,
  108. //                                                                     recov_carrier_sig);
  109. //   ContinuousDelay< float >* loop_delay_elem = new ContinuousDelay<float>( "loop_delay_elem",
  110. //                                   CommSystem,
  111. //                                   squared_signal,
  112. //                                   delay_squared_signal);
  113.    BandpassMixer* loop_mixer = new BandpassMixer( "loop_mixer",
  114.                                                    CommSystem,
  115.                                                    modulated_signal,
  116.                                                    modulated_signal,
  117.                                                    squared_signal );
  118.    LinearPLL* carr_recov_loop = new LinearPLL( "carr_recov_loop",
  119.                                                 CommSystem,
  120.                                                 squared_signal,
  121.                                                 pll_err_sig,
  122.                                                 pll_filt_err_sig,
  123.                                                 pll_ref_sig,
  124.                                                 pll_vco_freq_sig,
  125.                                                 pll_vco_phase_sig,
  126.                                                 recov_carrier_sig);
  127. //  ButterworthFilterByIir<float>* double_freq_filter = 
  128. //            new ButterworthFilterByIir<float>( "double_freq_filter",
  129. //                                        CommSystem,
  130. //                                        squared_signal,
  131. //                                        filt_squared_signal );
  132. //  SpectrumAnalyzer<float>* spec_anal_2 = 
  133. //                  new SpectrumAnalyzer<float>( 
  134. //                                                  "spec_anal_2",
  135. //                                                  CommSystem,
  136. //                                                  sqrd_noisy_sig );
  137.   SpectrumAnalyzer<float>* spec_anal_3 = 
  138.                   new SpectrumAnalyzer<float>( 
  139.                                                   "spec_anal_3",
  140.                                                   CommSystem,
  141.                                                   pll_err_sig );
  142.   SpectrumAnalyzer<float>* spec_anal_4 = 
  143.                   new SpectrumAnalyzer<float>( 
  144.                                                   "spec_anal_4",
  145.                                                   CommSystem,
  146.                                                   pll_filt_err_sig );
  147. //  QuadCarrierRecovGenie* carrier_recovery = new QuadCarrierRecovGenie( "carrier_recovery",
  148. //                                                                   CommSystem,
  149. //                                                                   i_recov_carrier_sig,
  150. //                                                                   q_recov_carrier_sig);
  151.   
  152. //  QuadBandpassMixer* quad_dem = new QuadBandpassMixer( "quad_dem",
  153. //                                                   CommSystem,
  154. //                                                   noisy_sig,
  155. //                                                   i_recov_carrier_sig,
  156. //                                                   q_recov_carrier_sig,
  157. //                                                   i_demod_wave,
  158. //                                                   q_demod_wave );
  159. //  IntegrateDumpAndSlice* i_bit_slicer = new IntegrateDumpAndSlice( "i_bit_slicer",
  160. //                                           CommSystem,
  161. //                                           i_demod_wave,
  162. //                                           symb_clock,
  163. //                                           i_samp_wave,
  164. //                                           i_bit_decis);
  165. //  IntegrateDumpAndSlice* q_bit_slicer = new IntegrateDumpAndSlice( "q_bit_slicer",
  166. //                                           CommSystem,
  167. //                                           q_demod_wave,
  168. //                                           q_symb_clock,
  169. //                                           q_samp_wave,
  170. //                                           q_bit_decis);
  171. //  BerCounter* i_ber_ctr = new BerCounter( "i_ber_ctr",
  172. //                                          CommSystem,
  173. //                                          i_bits,
  174. //                                          i_bit_decis );
  175. //  BerCounter* q_ber_ctr = new BerCounter( "q_ber_ctr",
  176. //                                          CommSystem,
  177. //                                          q_bits,
  178. //                                          q_bit_decis );
  179. //  QpskErrorCounter* ser_ctr = new QpskErrorCounter( "ser_ctr",
  180. //                                                    CommSystem,
  181. //                                                    i_bits,
  182. //                                                    q_bits,
  183. //                                                    i_bit_decis,
  184. //                                                    q_bit_decis );
  185.   //=============================================================
  186.   #include "sim_postamble.cpp"
  187.   return 0;
  188. }