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

encoder.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           encoder.h  -  description
00003                              -------------------
00004     begin                : Don Mai 16 2002
00005     copyright            : (C) 2002 by Peter Haase
00006     email                : mail@p-haase.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 #ifndef ENCODER_HEADER
00029 #define ENCODER_HEADER
00030 
00031 #include <iostream>
00032 #include <complex>
00033 
00034 #include <basicdevice.h>
00035 #include <signals.h>
00036 #include <misc.h>
00037 
00038 #include "viterbi.h"
00039 #include "puncturing.h"
00040 #include "decoder.h"
00041 #include "interleaver.h"
00042 #include "modulator.h"
00043 
00044 
00045 
00046 class simth::Device;
00047 
00048 namespace simthlib
00049 {
00050 
00051 
00052 class Encoder;
00053 
00054 
00055 inline std::ostream& operator<<(std::ostream &os, const Encoder &enc);
00056 
00057 
00064 class Encoder : public simth::Device
00065 {
00066 
00067   public:
00068 
00069     Encoder(int deviceID, simth::DeviceSystemIntf* system,
00070         const simth::PropertyList& pl);
00071 
00072     virtual ~Encoder(){}
00073 
00074     virtual void updateInputLengths();
00075     virtual void updateOutputLengths();
00076 
00077     virtual void process();
00078 
00080     void startOfSimulation();
00081 
00091     virtual int getDataLength(int codedLength) const =0;
00092 
00101     virtual int getCodeLength(int rawLength) const =0;
00102 
00106     virtual void Encode(const simth::BitSeq& bits,simth::BitSeq* encBits) const = 0;
00107 
00108     virtual void print(std::ostream &os) const;
00109 
00110     static void init(const std::string fileName, simth::Device** dev, simth::DeviceSystemIntf* sysPtr, int ID,
00111              const std::string& regionQualifier = "");
00112 
00113 };
00114 
00115 
00116 
00125 class ConvEncoder : public Encoder
00126 {
00127   private:
00128 
00129     ConvCodeTrellis* usedTrellis;
00130 
00131 
00132   public:
00133 
00155     ConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00156         const simth::PropertyList& pl, 
00157         int mem, int inbits, int outbits);
00158 
00163     ConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00164         const simth::PropertyList& pl, 
00165         int inSymbolsPerStep, 
00166         const simth::checkedVector<int>& polynomials);
00167 
00171     ConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00172         const simth::PropertyList& pl, 
00173         int inSymbolsPerStep, 
00174         const simth::checkedVector<int>& polynomials,
00175                 const int recursivePolynomial, bool systematic);
00176 
00181     ConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00182         const simth::PropertyList& pl, 
00183         int inSymbolsPerStep, int bitsPerSymbol, map_type mappMode,
00184                 const simth::checkedVector<int>& polynomials, 
00185         const int recursivePolynomial = 0, bool systematic=false);
00186 
00187 
00191     ConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00192         const simth::PropertyList& pl, 
00193         int inputBitsPerStep, int outputBitsPerStep, map_type mappMode);
00194 
00197     ConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00198         const simth::PropertyList& pl);
00199 
00202     virtual ~ConvEncoder(){ delete usedTrellis;}
00203 
00207     virtual int getDataLength(int codedLength) const;
00208 
00212     virtual int getCodeLength(int rawLength) const;
00213 
00214 
00215     virtual int numTailbits() const;
00216 
00217 
00220     virtual void Encode(const simth::BitSeq &bsin, simth::BitSeq* bsout) const;
00221 
00225     virtual int dataBitsPerStep() const {return usedTrellis->numInbits();}
00226 
00230     virtual int codedBitsPerStep() const {return usedTrellis->numOutbits();}
00231 
00232     virtual void print(std::ostream &os) const;
00233 
00234     static simth::checkedVector<int> 
00235     stdVectorToSimthVector(const simth::Property::vector_int&);
00236 };
00237 
00238 
00239 
00240 inline int ConvEncoder::getCodeLength(int dataLength) const
00241 {
00242   return usedTrellis->getCodeLength(dataLength);
00243 }
00244 
00245 inline int ConvEncoder::getDataLength(int codeLength) const
00246 {
00247   return usedTrellis->getDataLength(codeLength);
00248 }
00249 
00250 inline int ConvEncoder::numTailbits() const
00251 {
00252   return usedTrellis->numTailbits();
00253 }
00254 
00255 
00256 
00265 class PunctConvEncoder : public ConvEncoder
00266 {
00267   private:
00268 
00269     Puncturing* usedPuncturing;
00270 
00271   public:
00272 
00283     PunctConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00284              const simth::PropertyList& pl, 
00285              int codeRateNumerator,
00286              int codeRateDenumerator, 
00287              int mem, int inbits, int outbits);
00288 
00289 
00290     PunctConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00291              const simth::PropertyList& pl, 
00292              int codeRateNumerator, int codeRateDenumerator,
00293                      int inBitsPerStep, const simth::checkedVector<int>& polynomials,
00294                      const int recursivePolynomial, bool systematic);
00295 
00297     PunctConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00298              const simth::PropertyList& pl);
00299 
00300 
00301     PunctConvEncoder(int deviceID, simth::DeviceSystemIntf* system,
00302              const simth::PropertyList& pl, 
00303              const std::string& puncturingPattern,
00304                      int inBitsPerStep, const simth::checkedVector<int>& polynomials,
00305                      const int recursivePolynomial, bool systematic);
00306 
00307 
00308     virtual ~PunctConvEncoder(){ delete usedPuncturing;}
00309 
00310     /* Returns the length of a data bit sequence which can be
00311     encoded into a coded bit sequence of the given length.
00312 
00313     */
00314     virtual int getDataLength(int codedLength) const;
00315 
00316     /* Returns the length of the coded bit sequence which the
00317     coder generates from a data sequence of the given length.
00318     */
00319     virtual int getCodeLength(int rawLength) const;
00320 
00321 
00322 
00323     //virtual simth::BitSeq* Encode(simth::BitSeq& bits) const;
00324 
00325     // encodes a bit sequence
00326     virtual void Encode(const simth::BitSeq &bsin, simth::BitSeq* bsout) const;
00327 
00328 };
00329 
00330 
00331 
00332 
00333 
00338 class DapskEncoder : public Encoder
00339 {
00340     ConvEncoder* amplEncoder;
00341     ConvEncoder* phaseEncoder;
00342 
00343     mutable int numInSize;
00344     mutable int numInAmplSize;
00345     mutable int numInPhaseSize;
00346 
00347     int bitsPerAmpl_;
00348     int bitsPerPhase_;
00349 
00350     void splitSequence(const simth::BitSeq& inputBits, simth::BitSeq* amplSeq, simth::BitSeq* phaseSeq) const;
00351     void mergeSequences(const simth::BitSeq& amplSeq, const simth::BitSeq& phaseSeq, simth::BitSeq* outSeq) const;
00352 
00353     void invariante() const;
00354 
00355   protected:
00356     int bitsPerAmpl() const {return bitsPerAmpl_;}
00357     int bitsPerPhase() const {return bitsPerPhase_;}
00358 
00359     void computeSplittedSizes(int numInSize,
00360                               int* amplSize, int* phaseSize) const;
00361 
00362   public:
00363 
00364     DapskEncoder(int deviceID, simth::DeviceSystemIntf* system,
00365          const simth::PropertyList& pl, 
00366          int inSymbolsPerStep, int bitsPerSymbol, map_type mappMode,
00367                  const simth::checkedVector<int>& polynomials, 
00368          const int recursivePolynomial = 0);
00369 
00370 
00371     virtual ~DapskEncoder();
00372 
00373     /* Returns the length of a data bit sequence which can be
00374     encoded into a coded bit sequence of the given length.
00375 
00376     */
00377     virtual int getDataLength(int codedLength) const;
00378 
00379     /* Returns the length of the coded bit sequence which the
00380     coder generates from a data sequence of the given length.
00381     */
00382     virtual int getCodeLength(int rawLength) const;
00383 
00384 
00385 
00386     //virtual simth::BitSeq* Encode(simth::BitSeq& bits) const;
00387 
00388     // encodes a bit sequence
00389     virtual void Encode(const simth::BitSeq &bsin, simth::BitSeq* bsout) const;
00390 
00391     virtual int dataBitsPerStep() const {return bitsPerAmpl()+bitsPerPhase();}
00392     virtual int codedBitsPerStep() const {return (amplEncoder->codedBitsPerStep()+phaseEncoder->codedBitsPerStep());}
00393 
00394     virtual void print(std::ostream &os) const;
00395 
00396 
00397 };
00398 
00399 
00400 inline void DapskEncoder::invariante() const
00401 {
00402   if(DEBUG) {
00403     if(numInAmplSize + numInPhaseSize != numInSize) {
00404       throw std::logic_error("void DapskEncoder::invariante() const : error 1");
00405     }
00406   }
00407 }
00408 
00409 
00410 
00411 } // namespace
00412 
00413 #endif
00414 
00415 
00416 
00417 

Generated on Tue Aug 9 14:35:10 2005 for simtheticlib by  doxygen 1.4.1