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

conv_interleaver.h

Go to the documentation of this file.
00001 // 
00002 // SPUC - Signal processing using C++ - A DSP library
00009 #ifndef __cinterleave_h
00010 #define __cinterleave_h
00011 #include <binary.h>
00012 #include <matrix.h>
00013 #include <random.h>
00014 namespace SPUC {
00015 #define MAXINTLVR 128
00016         template<class T> class Vec;
00017         template<class T> class Mat;
00028         template <class T>
00029                 class Convolutional_Interleaver {
00030         public:
00032                 Convolutional_Interleaver(void) {rows = 0; cols = 0; rd_sel = wr_sel = 0;};
00034                 Convolutional_Interleaver(int in_rows, int in_cols);
00036                 T interleave(const T input);
00037                 void interleave_write(const T input);
00038                 T interleave_read(void);
00040                 T deinterleave(const T input);
00042                 void set_size(int in_rows, int in_cols) {
00043                         int i;
00044                         rows = in_rows;
00045                         cols = in_cols;
00046                         input_length = 0;
00047                         if (rows > MAXINTLVR) rows = MAXINTLVR;
00048                         for (i=0;i<rows;i++) {
00049                                 D[i].set_size(i*cols);
00050                         }
00051                         wr_sel = 0;
00052                         rd_sel = 0;
00053                 };
00055                 int get_rows(void) {return rows;};
00057                 int get_cols(void) {return cols;};
00058                 void reset(void)
00059                 {
00060                         int i;
00061                         for (i=0;i<rows;i++) D[i].reset();
00062                         wr_sel = 0;
00063                         rd_sel = 0;
00064                 }
00065                 void resync(void) { 
00066                         wr_sel = 0;
00067                         rd_sel = 0;
00068                 }
00069         private:
00070                 int rows, cols, input_length;
00071                 int wr_sel;
00072                 int rd_sel;
00073                 delay<T> D[MAXINTLVR];
00074 
00075         };
00076         
00077         //
00078         // Convolutional Interleaver
00079         //
00080         template<class T>
00081                 Convolutional_Interleaver<T>::Convolutional_Interleaver(int in_rows, int in_cols)
00082                 {
00083                         int i;
00084                         rows = in_rows;
00085                         cols = in_cols;
00086                         input_length = 0;
00087                         if (rows > MAXINTLVR) rows = MAXINTLVR;
00088                         for (i=0;i<rows;i++) {
00089                                 D[i].set_size(i*cols);
00090                         }
00091                         rd_sel = wr_sel = 0;
00092                 }
00093         
00094         template<class T>
00095                 T Convolutional_Interleaver<T>::interleave(const T input)
00096                 {
00097                         interleave_write(input);
00098                         return(interleave_read());
00099                 }
00100         template<class T>
00101                 void Convolutional_Interleaver<T>::interleave_write(const T input)
00102                 {
00103                         D[wr_sel].input(input);
00104                         wr_sel++;
00105                         wr_sel = wr_sel % rows;
00106                 }
00107         template<class T>
00108                 T Convolutional_Interleaver<T>::interleave_read(void)
00109                 {
00110                         T outp = D[rd_sel].last();
00111                         rd_sel++;
00112                         rd_sel = rd_sel % rows;
00113                         return(outp);
00114                 }
00115         template<class T>
00116                 T Convolutional_Interleaver<T>::deinterleave(const T input)
00117                 {
00118                         // not using rd_sel yet!
00119                         T outp = D[rows-1-wr_sel].update(input);
00120                         wr_sel++;
00121                         wr_sel = wr_sel % rows;
00122                         return(outp);
00123                 }
00124 
00125 
00126 }
00127 
00128 #endif

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