00001 // Copyright(c) 1993-1996 Tony Kirke 00002 /* 00003 * SPUC - Signal processing using C++ - A DSP library 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2, or (at your option) 00008 * any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 #include <stdio.h> 00020 #include <stdlib.h> 00021 #include <math.h> 00022 #include <complex.h> 00023 #include <max_pn.h> 00024 #include <noise.h> 00025 #include <vco.h> 00026 #include <fading_channel.h> 00027 #include <fir_interp.h> 00028 #include <lagrange.h> 00029 //#include "qam_demap.h" 00030 #include "qam_tx.h" 00031 #include "base_demod.h" 00032 namespace SPUC { 00041 00042 00043 00044 00045 class sim_qam { 00046 public: 00047 00048 qam_tx TX; 00049 noise* n; 00050 base_demod* DUT; 00051 vco* freq_offset; 00052 fir<complex<double> > rx_filter; 00053 lagrange<complex<double> > interp; 00054 double var; 00055 double snr; 00056 double channel_pwr; 00057 complex<double> tx_data; 00058 complex<long> data; 00059 long output_delay; // Equalizer output delay (for paths to merge) 00060 long rate; 00061 00062 bool enable_freq_offset; 00063 bool enable_time_offset; 00064 double carrier_offset_rate; 00065 double time_inc; 00066 double time_offset; 00067 00068 00069 complex<double> base; 00070 complex<double> main; 00071 complex<double> main1, base1; 00072 00073 complex<double> b_noise; // Noise 00074 long rcv_symbols; // Number of symbols decoded 00075 long tx_symbols; // Counter for transmitted symbols 00076 long count; // index of sample number at input rate 00077 double phase_inc; 00078 double phase_acc; 00079 const long over; // Oversampling rate 00080 double alpha; 00081 00082 sim_qam(double tx_filter_bw=0.25); 00083 void loop_init(long rate, long conv_rate, 00084 double carrier_off=0, double time_off=0); 00085 complex<long> step(); 00086 ~sim_qam() { 00087 if (n) delete n; 00088 } 00089 void loop_end(void); 00090 }; 00091 } 00092