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

decoder.h

Go to the documentation of this file.
00001 
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 DECODER_HEADER
00029 #define DECODER_HEADER
00030 
00031 #include <iostream>
00032 #include <string>
00033 #include <complex>
00034 #include <memory>
00035 
00036 #include <misc.h>
00037 #include <signals.h>
00038 #include <basicdevice.h>
00039 
00040 #include "viterbi.h"
00041 #include "trellis.h"
00042 #include "trellisdecoding.h"
00043 
00044 
00045 
00046 namespace simthlib{ 
00047 
00048 class Decoder;
00049 class Encoder;
00050 
00051 
00052 std::ostream& operator<<(std::ostream &os, const Decoder &cod);
00053 
00054 
00060 class Decoder : public simth::Device
00061 {
00062   private:
00063 
00064     simth::SequenceType inputType_;
00065 
00066   protected:
00067 
00068     simth::SequenceType inputType() const {return inputType_;}
00069 
00070   public:
00071     Decoder(int deviceID, simth::DeviceSystemIntf* system,
00072         const simth::PropertyList& pl, 
00073         simth::SequenceType inType);
00074 
00077     virtual ~Decoder(){};
00078 
00081     virtual void decode(const simth::BitSeq &bsin,simth::BitSeq& bsout) = 0;
00082 
00083 
00084 
00089     virtual void decode(const simth::LlvSeq &llv, simth::BitSeq& bsout) = 0;
00090 
00095     virtual void decode(const simth::LlrSeq &llr, simth::BitSeq& bsout) = 0;
00096 
00102     virtual int getDataLength(int codedLength) const =0;
00103 
00109     virtual int getCodeLength(int rawLength) const =0;
00110 
00114     virtual void process();
00115 
00116     // nicht fuer alle coder: virtual LLRSeq* decode(simth::LlvSeq &llv,
00117     //sova_type sova=CODER_IN);
00118     virtual void print(std::ostream &os) const;
00119 
00120     static void init(const std::string& fileName, simth::Device** dev, simth::DeviceSystemIntf* sysPtr, int ID,
00121                  const std::string& regionQualifier = "");
00122 
00125     void startOfSimulation();
00126 };
00127 
00128 
00129 
00130 
00131 
00132 
00139 class StreamDecoder : public Decoder
00140 {
00141 
00142   public:
00143 
00144     StreamDecoder(int deviceID, simth::DeviceSystemIntf* system,
00145           const simth::PropertyList& pl, 
00146           simth::SequenceType inType);
00147 
00152     virtual int dataBitsPerStep() const = 0;
00157     virtual int codedBitsPerStep() const = 0;
00158 
00170     virtual void process();
00171   
00172     virtual void updateInputLengths();
00173     virtual void updateOutputLengths();
00174 
00175   protected:
00176     
00177     //keeps the number of llr values (or the number of hard input bits) that
00178     //yields when decoding the desired number of output (data) bits.  
00179     size_t llrInputLength;
00180 };
00181 
00182 
00190 class TrellisDecoder : public StreamDecoder
00191 {
00192   private:
00193 
00194     TrellisDecodingAlgorithm* usedAlgorithm;
00195 
00196   protected:
00197 
00198   public:
00199 
00207     TrellisDecoder(int deviceID, simth::DeviceSystemIntf* system,
00208            const simth::PropertyList& pl, 
00209            std::auto_ptr<TrellisDecodingAlgorithm> algorithm_ptr,
00210                    simth::SequenceType inType);
00211                    
00212     virtual ~TrellisDecoder();
00213 
00214     // decodes a bit sequence (hard decision decoding)
00215     virtual void decode(const simth::BitSeq & bsin, simth::BitSeq& bsout);
00216 
00217     /* performs a maximum likelihood sequence estimation of the
00218     data sequence based on the log-likelihood values of received
00219     modulation symbols (soft decision decoding) */
00220     virtual void decode(const simth::LlvSeq &llv, simth::BitSeq& bsout);
00221 
00222     /* performs a maximum likelihood sequence estimation of the
00223     data sequence based on the log-likelihood ratios of the received
00224     modulation symbols (soft decision decoding) */
00225     virtual void decode(const simth::LlrSeq &llr, simth::BitSeq& bsout);
00226 
00227 
00228     /* Returns the length of a data bit sequence which can be
00229     encoded into a coded bit sequence of the given length.
00230 
00231     */
00232     virtual int getDataLength(int codedLength) const;
00233 
00234     /* Returns the length of the coded bit sequence which the
00235     coder generates from a data sequence of the given length.
00236     */
00237     virtual int getCodeLength(int rawLength) const;
00238 
00243     virtual int dataBitsPerStep() const {return usedAlgorithm->trellis()->numInbits();}
00248     virtual int codedBitsPerStep() const {return usedAlgorithm->trellis()->numOutbits();}
00249 
00250 
00251     /* calculates log-likelihood ratios of the
00252     data sequence based on the log-likelihood values of received
00253     modulation symbols (soft in / soft out decoding) */
00254 
00255     virtual void print(std::ostream &os) const;
00256 };
00257 
00258 inline int TrellisDecoder::getCodeLength(int rawLength) const
00259 {
00260   return usedAlgorithm->trellis()->getCodeLength(rawLength);
00261 }
00262 
00263 
00264 inline int TrellisDecoder::getDataLength(int codeLength) const
00265 {
00266   return usedAlgorithm->trellis()->getDataLength(codeLength);
00267 }
00268 
00269 
00270 
00283 class ConvDecoder : public TrellisDecoder
00284 {
00285 
00286    public:
00287       
00314       ConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00315           const simth::PropertyList& pl, 
00316           int mem, int inbits, int outbits, 
00317           simth::SequenceType inType,
00318           trellisdecoding::DecodingAlgorithmMode decodingMode);
00319 
00325       ConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00326           const simth::PropertyList& pl, 
00327           int inSymbolsPerStep, 
00328           const simth::checkedVector<int>& polynomials, 
00329           simth::SequenceType inType,
00330           trellisdecoding::DecodingAlgorithmMode decodingMode);
00331 
00335       ConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00336           const simth::PropertyList& pl, 
00337           int inSymbolsPerStep, 
00338           const simth::checkedVector<int>& polynomials, 
00339           int recursivePolynomial, bool systematic,
00340           simth::SequenceType inType, 
00341           trellisdecoding::DecodingAlgorithmMode decodingMode);
00342 
00347       ConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00348           const simth::PropertyList& pl);
00349                 
00354       ConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00355           const simth::PropertyList& pl, 
00356           int inSymbolsPerStep, int bitsPerSymbol, 
00357           ConvCodeTrellis::StartingMode startingMode, 
00358           map_type mappMode, 
00359           const simth::checkedVector<int>& polynomials, 
00360           int recursivePolynomial, bool systematic,
00361           simth::SequenceType inType,
00362           trellisdecoding::DecodingAlgorithmMode decodingMode);
00363                 
00364 };
00365 
00366 
00367 class Puncturing;
00368 
00377 class PunctConvDecoder : public TrellisDecoder
00378 {
00379   private:
00380 
00381   protected:
00382   
00383     Puncturing* usedPuncturing;
00384 
00385   public:
00386 
00398     PunctConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00399              const simth::PropertyList& pl, 
00400              int codeRateNumerator,
00401              int codeRateDenumerator, 
00402              int mem, 
00403              int inbits, 
00404              int outbits);
00405 
00406 
00407     PunctConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00408              const simth::PropertyList& pl, 
00409              int codeRateNumerator, 
00410              int codeRateDenumerator, int inbitsPerStep,
00411                      const simth::checkedVector<int>& polynomials,
00412                      const int recursivePolynomial, bool systematic);
00413 
00415     PunctConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00416              const simth::PropertyList& pl);
00417 
00418     PunctConvDecoder(int deviceID, simth::DeviceSystemIntf* system,
00419              const simth::PropertyList& pl, 
00420              const std::string& puncturingPattern, int inbitsPerStep,
00421                      const simth::checkedVector<int>& polynomials,
00422                      const int recursivePolynomial, bool systematic);
00423 
00424     virtual ~PunctConvDecoder();
00425 
00426 
00427     virtual void updateInputLengths();
00428     virtual void updateOutputLengths();
00429 
00430 
00431     /* Returns the length of a data bit sequence which can be
00432        encoded into a coded bit sequence of the given length.
00433     */
00434     virtual int getDataLength(int codedLength) const;
00435 
00436     /* Returns the length of the coded bit sequence the
00437         coder generates from a data sequence of the given length.
00438     */
00439     virtual int getCodeLength(int rawLength) const;
00440 
00443     virtual void decode(const simth::LlrSeq &llr, simth::BitSeq& bsout);
00444 
00445     // not implemented -> throws an error
00446     virtual void decode(const simth::BitSeq & bsin, simth::BitSeq& bsout);
00447 
00448     // not implemented -> throws an error
00449     virtual void decode(const simth::LlvSeq &llv, simth::BitSeq& bsout);
00450 
00451     void setPuncturing(const std::string& newPuncturePattern);
00452 };
00453 
00454 
00455 }
00456 
00457 #endif

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