Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ofdm_data_encoder.h

Go to the documentation of this file.
00001 #ifndef OFDMDETX
00002 #define OFDMDETX
00003 #include <math.h>
00004 #include <complex.h>
00005 #include <bit_scrambler.h>
00006 #include "data_conv_encoder.h"
00007 #include "qam_mod.h"
00008 namespace SPUC {
00009 /*
00010  * SPUC - Signal processing using C++ - A DSP library
00011  * 
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2, or (at your option)
00015  * any later version.
00016  * 
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  * 
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025 */
00031 class ofdm_data_encoder 
00032 {
00033 public:
00034         data_conv_encoder CONV;
00035         qam_mod QAM;
00036         long rate_index; // 0 BPSK, Max for highest QAM, etc
00037         long enc_rate;
00038         long tx_bits_per_symbol;
00039         long total_bits;
00040         long number_symbols;
00041         long frame;
00042         long serial;
00043         long sample;
00044         long data_index;
00045         bool raw_bit; // current input data bit
00046         bool* raw_data;
00047         bool* interleaver_in;
00048         bool* interleaved;
00049         bool* interleaver_out;
00050         long* pre_mod;
00051         
00052  public:
00053         const long Carriers;
00054         int coded_bits_per_frame;
00055         int raw_bits_this_frame;
00056         bool no_conv;
00057         
00058         // Constructor (with default data rate)
00059         ofdm_data_encoder(int index, int T_fft, int D_carriers,
00060                                           int max_range) : Carriers(D_carriers),
00061                                           CONV(index, T_fft), QAM(index)
00062                 {
00063                         rate_index = index;
00064                         raw_data = new bool[T_fft*16];
00065                         interleaver_in = new bool[T_fft*max_range];
00066                         interleaved = new bool[T_fft*max_range];
00067                         pre_mod = new long[Carriers];
00068                         reset();
00069                 }
00070         // Determine number of OFDM symbol (must be called AFTER set_rate())
00071         long tx_burst_size(long bytes) {
00072                 number_symbols = (8*bytes+6+coded_bits_per_frame+1)/coded_bits_per_frame;
00073                 total_bits = number_symbols*coded_bits_per_frame;
00074         }
00075         void reset() { // clear variables for next burst
00076                 serial = 0;
00077                 sample = 0;
00078                 frame = 0;
00079                 raw_bit=0;
00080                 coded_bits_per_frame=0;
00081                 raw_bits_this_frame=0;
00082                 tx_bits_per_symbol = 0;
00083                 data_index = 0;
00084         }
00085         ~ofdm_data_encoder() {
00086                 delete [] raw_data;
00087                 delete [] interleaver_in;
00088                 delete [] interleaved;
00089                 delete [] pre_mod;
00090         } 
00091         void set_rate(int mod, int conv_rate) {
00092                 if (conv_rate == 0) no_conv = 1;
00093                 else no_conv = 0;
00094                 enc_rate = conv_rate;
00095                 if (mod>0) tx_bits_per_symbol = 2*mod;
00096                 else tx_bits_per_symbol = 1;
00097         }
00098         bool* interleave(bool* data_in); 
00099         bool get_data(void);
00100 
00101         complex<long> data_map(long rate);
00102         
00103         void get_data_frame();
00104         void serial_to_word_input(bool in);
00105         long serial_to_word_output(void);
00106 };
00107 }
00108 #endif
00109 
00110 

Generated on Fri Sep 16 11:02:20 2005 for spuc by  doxygen 1.4.4