forked from xdsopl/LDPC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mods_handler.cc
62 lines (56 loc) · 2.22 KB
/
mods_handler.cc
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
/*
LDPC modulations handler
Copyright 2018 Ahmet Inan <[email protected]>
*/
#include <cstring>
#include <cmath>
#include <algorithm>
#include "psk.hh"
#include "qam.hh"
#include "modulation.hh"
#include "testbench.hh"
template <typename TYPE, typename CODE>
constexpr typename TYPE::value_type PhaseShiftKeying<4, TYPE, CODE>::rcp_sqrt_2;
template <typename TYPE, typename CODE>
constexpr TYPE PhaseShiftKeying<8, TYPE, CODE>::rot_acw;
template <typename TYPE, typename CODE>
constexpr TYPE PhaseShiftKeying<8, TYPE, CODE>::rot_cw;
template <typename TYPE, typename CODE>
constexpr typename TYPE::value_type QuadratureAmplitudeModulation<16, TYPE, CODE>::AMP;
template <typename TYPE, typename CODE>
constexpr typename TYPE::value_type QuadratureAmplitudeModulation<64, TYPE, CODE>::AMP;
template <typename TYPE, typename CODE>
constexpr typename TYPE::value_type QuadratureAmplitudeModulation<256, TYPE, CODE>::AMP;
template <typename TYPE, typename CODE>
constexpr typename TYPE::value_type QuadratureAmplitudeModulation<1024, TYPE, CODE>::AMP;
template <int LEN>
ModulationInterface<complex_type, code_type> *create_modulation(char *name)
{
if (!strcmp(name, "BPSK"))
return new Modulation<PhaseShiftKeying<2, complex_type, code_type>, LEN>();
if (!strcmp(name, "QPSK"))
return new Modulation<PhaseShiftKeying<4, complex_type, code_type>, LEN / 2>();
if (!strcmp(name, "8PSK"))
return new Modulation<PhaseShiftKeying<8, complex_type, code_type>, LEN / 3>();
if (!strcmp(name, "QAM16"))
return new Modulation<QuadratureAmplitudeModulation<16, complex_type, code_type>, LEN / 4>();
if (!strcmp(name, "QAM64"))
return new Modulation<QuadratureAmplitudeModulation<64, complex_type, code_type>, LEN / 6>();
if (!strcmp(name, "QAM256"))
return new Modulation<QuadratureAmplitudeModulation<256, complex_type, code_type>, LEN / 8>();
if (!strcmp(name, "QAM1024"))
return new Modulation<QuadratureAmplitudeModulation<1024, complex_type, code_type>, LEN / 10>();
return 0;
}
ModulationInterface<complex_type, code_type> *create_modulation(char *name, int len)
{
switch (len) {
case 16200:
return create_modulation<16200>(name);
case 32400:
return create_modulation<32400>(name);
case 64800:
return create_modulation<64800>(name);
}
return 0;
}