-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibEDM_modulators.h
63 lines (44 loc) · 2.3 KB
/
libEDM_modulators.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <libEDM_matrix.h>
class Modulator {
public:
Modulator (const size_t bits_per_symbol) : _M(bits_per_symbol) {}
dVector demodulate (const cVector &received) const;
cVector modulate (const bVector &bits) const;
size_t bits_per_symbol () const { return _M; }
virtual void demodulate (const cVector &received, dVector &output) const = 0;
virtual void modulate (const bVector &bits, cVector &output) const = 0;
private:
const size_t _M;
};
class BPSK : public Modulator {
public:
BPSK () : Modulator(1) {}
void demodulate (const dVector &received, bVector &output) const;
void demodulate (const dVector &received, dVector &output) const { output = received; }
void demodulate (const cVector &received, bVector &output) const;
void demodulate (const cVector &received, dVector &output) const;
void modulate (const bVector &bits, dVector &output) const;
void modulate (const bVector &bits, cVector &output) const;
dVector demodulate (const cVector &received) const { return Modulator::demodulate(received); }
cVector modulate (const bVector &bits) const { return Modulator::modulate(bits); }
};
class QPSK : public Modulator {
public:
QPSK () : Modulator(2) {}
void demodulate (const cVector &received, bVector &output) const;
void demodulate (const cVector &received, dVector &output) const;
void modulate (const bVector &bits, cVector &output) const;
dVector demodulate (const cVector &received) const { return Modulator::demodulate(received); }
cVector modulate (const bVector &bits) const { return Modulator::modulate(bits); }
};
class OFDM : public Modulator {
public:
const size_t numFFT, numCyclicPrefix;
OFDM (size_t numFFT, size_t numCyclicPrefix) : Modulator(2*numFFT), numFFT(numFFT), numCyclicPrefix(numCyclicPrefix) {}
void demodulate (const cVector &received, bVector &output) const;
void demodulate (const cVector &received, dVector &output) const;
void modulate (const bVector &bits, cVector &output) const;
dVector demodulate (const cVector &received) const { return Modulator::demodulate(received); }
cVector modulate (const bVector &bits) const { return Modulator::modulate(bits); }
};