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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = oqpsk_sim.cpp
  3. //
  4. #define SIM_NAME "OqpskSim"
  5. #define SIM_TITLE "Complex Baseband Simulation of OQPSK"
  6. #include "global_stuff.h" 
  7. #include "qpsk_theory.h"
  8. #include "bitgen.h"
  9. #include "bitwav.h"
  10. #include "discrete_delay_T.h"
  11. #include "siganchr.h"
  12. #include "quadmod.h"
  13. #include "phase_rotate.h"
  14. #include "add_gaus_noise.h"
  15. #include "spec_analyzer.h"
  16. #include "phase_genie.h"
  17. #include "quaddem.h"
  18. #include "integ_dump_slice.h"
  19. #include "qpskoptbitdem.h"
  20. #include "ber_ctr.h"
  21. main()
  22. {
  23. #include "sim_preamble.cpp"
  24.   //=========================================================================
  25.   //  Misc special processing
  26.   //=========================================================================
  27.   //  Allocate signals
  28.   BIT_SIGNAL(i_bits);
  29.   BIT_SIGNAL(q_bits);
  30.   BIT_SIGNAL(q_bits_delayed);
  31.   FLOAT_SIGNAL(i_baseband_wave);
  32.   FLOAT_SIGNAL(q_baseband_wave);
  33.   COMPLEX_SIGNAL(modulated_signal);
  34.   COMPLEX_SIGNAL(shifted_signal);
  35.   COMPLEX_SIGNAL(recov_carrier_sig);
  36.   COMPLEX_SIGNAL(noisy_sig);
  37.   BIT_SIGNAL(symb_clock);
  38.   BIT_SIGNAL(delayed_clock);
  39.   BIT_SIGNAL(q_symb_clock);
  40.   FLOAT_SIGNAL(power_meas_sig);
  41.   FLOAT_SIGNAL(i_demod_wave);
  42.   FLOAT_SIGNAL(q_demod_wave);
  43.   FLOAT_SIGNAL(i_samp_wave);
  44.   FLOAT_SIGNAL(q_samp_wave);
  45.   BIT_SIGNAL(i_bit_decis);
  46.   BIT_SIGNAL(q_bit_decis);
  47.   //============================================================
  48.   //  Construct, initialize and connect models
  49.   BitGener* i_bit_gen = new BitGener( "i_bit_gen",
  50.                                       CommSystem,
  51.                                       i_bits );
  52.   BitGener* q_bit_gen = new BitGener( "q_bit_gen",
  53.                                       CommSystem,
  54.                                       q_bits );
  55.   DiscreteDelay< bit_t >* q_bit_delay = new DiscreteDelay< bit_t >( "q_bit_delay",
  56.                                                               CommSystem,
  57.                                                               q_bits,
  58.                                                               q_bits_delayed );
  59.   BitsToWave* i_wave_gen = new BitsToWave( "i_wave_gen",
  60.                                            CommSystem,
  61.                                            i_bits,
  62.                                            i_baseband_wave,
  63.                                            symb_clock );
  64.   BitsToWave* q_wave_gen = new BitsToWave( "q_wave_gen",
  65.                                            CommSystem,
  66.                                            q_bits,
  67.                                            q_baseband_wave,
  68.                                            q_symb_clock );
  69.   DiscreteDelay< bit_t >* clock_delay = new DiscreteDelay< bit_t >( "clock_delay",
  70.                                                               CommSystem,
  71.                                                               q_symb_clock,
  72.                                                               delayed_clock );
  73.   SignalAnchor* temp_anchor_1 = new SignalAnchor( "temp_anchor_1",
  74.                                                 CommSystem,
  75.                                                 i_baseband_wave,
  76.                                                 q_baseband_wave,
  77.                                                 0.0625, //samp_intvl
  78.                                                 4096 ); //block_size
  79.   QuadratureModulator* qpsk_mod = new QuadratureModulator( "qpsk_mod",
  80.                                                 CommSystem,
  81.                                                 i_baseband_wave,
  82.                                                 q_baseband_wave,
  83.                                                 modulated_signal);
  84.   
  85.   PhaseRotate* phase_shifter = new PhaseRotate( "phase_shifter",
  86.                                                 CommSystem,
  87.                                                 modulated_signal,
  88.                                                 shifted_signal);
  89.   AdditiveGaussianNoise<std::complex<float> >* agn_source = 
  90.                   new AdditiveGaussianNoise<std::complex<float> >( 
  91.                                                 "agn_source",
  92.                                                 CommSystem,
  93.                                                 shifted_signal,
  94.                                                 noisy_sig,
  95.                                                 power_meas_sig);
  96.   SpectrumAnalyzer<std::complex<float> >* spec_analyzer = 
  97.                   new SpectrumAnalyzer<std::complex<float> >( 
  98.                                                   "spec_analyzer",
  99.                                                   CommSystem,
  100.                                                   modulated_signal );
  101.   PhaseRecoveryGenie* carrier_recovery = new PhaseRecoveryGenie( "carrier_recovery",
  102.                                                                    CommSystem,
  103.                                                                    recov_carrier_sig);
  104.   
  105.   QuadratureDemod* quad_dem = new QuadratureDemod( "quad_dem",
  106.                                                    CommSystem,
  107.                                                    noisy_sig,
  108.                                                    recov_carrier_sig,
  109.                                                    i_demod_wave,
  110.                                                    q_demod_wave );
  111.   IntegrateDumpAndSlice* i_bit_slicer = new IntegrateDumpAndSlice( "i_bit_slicer",
  112.                                            CommSystem,
  113.                                            i_demod_wave,
  114.                                            symb_clock,
  115.                                            i_samp_wave,
  116.                                            i_bit_decis);
  117.   IntegrateDumpAndSlice* q_bit_slicer = new IntegrateDumpAndSlice( "q_bit_slicer",
  118.                                            CommSystem,
  119.                                            q_demod_wave,
  120.                                            q_symb_clock,
  121.                                            q_samp_wave,
  122.                                            q_bit_decis);
  123.   BerCounter* i_ber_ctr = new BerCounter( "i_ber_ctr",
  124.                                           CommSystem,
  125.                                           i_bits,
  126.                                           i_bit_decis );
  127.   BerCounter* q_ber_ctr = new BerCounter( "q_ber_ctr",
  128.                                           CommSystem,
  129.                                           q_bits_delayed,
  130.                                           q_bit_decis );
  131.   //=============================================================
  132.   #include "sim_postamble.cpp"
  133.   return 0;
  134. }