00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef ADAPTIVEDEMODULATOR_H
00019 #define ADAPTIVEDEMODULATOR_H
00020
00021 #include <iostream>
00022 #include <fstream>
00023 #include <complex>
00024 #include <vector>
00025 #include <cmath>
00026 #include "signals.h"
00027 #include "misc.h"
00028 #include "phbib.h"
00029 #include "basicdevicefactory.h"
00030 #include "basicdevice.h"
00031 #include "interfaces.h"
00032 #include "modulator.h"
00033 #include "adaptiveModulator.h"
00034 #include "interleaver.h"
00035
00036 namespace simthlib {
00037
00038 class AdaptiveDemodulator;
00039
00040
00041 std::ostream& operator<<(std::ostream &os, const AdaptiveDemodulator& demod);
00042
00043 void initAdaptiveDemodulator(const std::string fileName, simth::Device** dev, simth::DeviceSystemIntf* sysPtr, int ID,
00044 const std::string& regionQualifier = "");
00045
00046
00047
00048
00049 class AdaptiveDemodulatorBase : public simth::CompatibleDevice
00050 {
00051 protected:
00052 simth::SequenceType outputType_;
00053 ExtendedModList* localExtModlist;
00054 map_type mapping;
00055 int avgBitsPerSym;
00056 double snr;
00057 Interleaving *intl;
00058 bool csi_only_for_reliabilities;
00069 virtual void demodulate(const simth::ModSeq &receivedSym,
00070 simth::LlrSeq *correspondingLlrValues,
00071 double noise = 0,
00072 const simth::ModSeq* trans = NULL,
00073 simth::LoadingInfoSeq* loading=NULL);
00074
00078 virtual void demodulate(const simth::ModSeq &receivedSym,
00079 simth::LlvSeq *correspondingLlvValues,
00080 double noise = 0,
00081 const simth::ModSeq* trans = NULL,
00082 simth::LoadingInfoSeq* loading=NULL);
00083
00086 virtual int MakeMetric(Complex sym, simth::Llv* const llv,
00087 ConstellationDiagram* constellation,
00088 MappingScheme* mapping,
00089 int bitsPerSym, Complex h, double noise)=0;
00090
00091 virtual void llvSeq2llrSeq(const simth::LlvSeq& from,
00092 simth::LlrSeq* llrSeq)=0;
00093
00094 AdaptiveDemodulatorBase(simth::SequenceType outType,
00095 map_type _mapping,
00096 int _avgBitsPerSym,
00097 std::auto_ptr<Interleaving> _intl);
00098
00099 public:
00100 AdaptiveDemodulatorBase(int id, simth::DeviceSystemIntf *s, const simth::PropertyList& pl);
00101
00102 virtual void updateInputLengths()=0;
00103 virtual void updateOutputLengths()=0;
00104 virtual void print(std::ostream &os) const=0;
00105 virtual void process()=0;
00106 virtual ~AdaptiveDemodulatorBase();
00107
00108 };
00109
00110
00111
00112
00113 class AdaptiveDemodulator : public AdaptiveDemodulatorBase
00114 {
00115 private:
00118 int MakeMetric(Complex sym, simth::Llv* const llv, ConstellationDiagram* constellation,
00119 MappingScheme* mapping, int bitsPerSym,Complex h, double noise);
00120 void llvSeq2llrSeq(const simth::LlvSeq& from, simth::LlrSeq* llrSeq);
00121
00122 void init();
00123
00124 public:
00125 AdaptiveDemodulator(simth::SequenceType outType, map_type mapping, int avgBitsPerSym, std::auto_ptr<Interleaving> intl);
00126 AdaptiveDemodulator(int id, simth::DeviceSystemIntf *s, const simth::PropertyList& pl);
00127 void updateInputLengths();
00128 void updateOutputLengths();
00129 void print(std::ostream &os) const;
00130 void process();
00131 ~AdaptiveDemodulator(){};
00132 virtual void startOfSimulation();
00133
00134 };
00135
00136
00142 class MultilevelAdaptiveDemodulator : public AdaptiveDemodulatorBase
00143 {
00144 private:
00145
00146
00147
00148 int demodLevel;
00149 simth::checkedVector<simth::BitSeq*> decSeqList;
00150 simth::checkedVector<int> decSeqPos;
00151 simth::checkedVector<unsigned> decSeqLength;
00152
00153
00154
00165
00166
00167
00171
00172
00173
00176 int MakeMetric(Complex sym, simth::Llv* const llv, ConstellationDiagram* constellation,
00177 MappingScheme* mapping, int bitsPerSym,Complex h, double noise);
00178 void llvSeq2llrSeq(const simth::LlvSeq& from, simth::LlrSeq* llrSeq);
00179
00180 public:
00181 MultilevelAdaptiveDemodulator(simth::SequenceType outType, map_type mapping, std::auto_ptr<Interleaving> intl, int operationLevel);
00182 void updateInputLengths();
00183 void updateOutputLengths();
00184 void print(std::ostream &os) const;
00185 void process();
00186 ~MultilevelAdaptiveDemodulator();
00187
00188 };
00189
00190 }
00191
00192 #endif