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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
#!/usr/bin/env python
#
# Copyright 2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
import numpy
from .constellation_map_generator import constellation_map_generator
'''
Note on the naming scheme. Each constellation is named using a prefix
for the type of constellation, the order of the constellation, and a
distinguishing feature, which comes in three modes:
- No extra feature: the basic Gray-coded constellation map; others
will be derived from this type.
- A single number: an indexed number to uniquely identify different
constellation maps.
- 0xN_x0_x1..._xM: A permutation of the base constellation, explained
below.
For rectangular constellations (BPSK, QPSK, QAM), we can define a
hyperspace and look for all symmetries. This is also known as the
automorphism group of the hypercube, aka the hyperoctahedral
group. What this means is that we can easily define all possible
rotations in terms of the first base mapping by creating the mapping:
f(x) = k XOR pi(x)
The x is the bit string for the symbol we are altering. Then k is a
bit string of n bits where n is the number of bits per symbol in the
constellation (e.g., 2 for QPSK or 6 for QAM64). The pi is a
permutation function specified as pi_0, pi_1..., pi_n-1. This permutes
the bits from the base constellation symbol to a new code, which is
then xor'd by k.
The value of k is from 0 to 2^n-1 and pi is a list of all bit
positions.
The total number of Gray coded modulations is (2^n)*(n!).
We create aliases for all possible naming schemes for the
constellations. So if a hyperoctahedral group is defined, we also set
this function equal to a function name using a unique ID number, and
we always select one rotation as our basic rotation that the other
rotations are based off of.
'''
# BPSK Constellation Mappings
def psk_2_0x0():
'''
0 | 1
'''
const_points = [-1, 1]
symbols = [0, 1]
return (const_points, symbols)
psk_2 = psk_2_0x0 # Basic BPSK rotation
psk_2_0 = psk_2 # First ID for BPSK rotations
def psk_2_0x1():
'''
1 | 0
'''
const_points = [-1, 1]
symbols = [1, 0]
return (const_points, symbols)
psk_2_1 = psk_2_0x1
############################################################
# BPSK Soft bit LUT generators
############################################################
def sd_psk_2_0x0(x, Es=1):
'''
0 | 1
'''
x_re = x.real
dist = Es*numpy.sqrt(2)
return [dist*x_re,]
sd_psk_2 = sd_psk_2_0x0 # Basic BPSK rotation
sd_psk_2_0 = sd_psk_2 # First ID for BPSK rotations
def sd_psk_2_0x1(x, Es=1):
'''
1 | 0
'''
x_re = [x.real,]
dist = Es*numpy.sqrt(2)
return -dist*x_re
sd_psk_2_1 = sd_psk_2_0x1
############################################################
# QPSK Constellation Mappings
############################################################
def psk_4_0x0_0_1():
'''
| 10 | 11
| -------
| 00 | 01
'''
const_points = [-1-1j, 1-1j,
-1+1j, 1+1j]
symbols = [0, 1, 2, 3]
return (const_points, symbols)
psk_4 = psk_4_0x0_0_1
psk_4_0 = psk_4
def psk_4_0x1_0_1():
'''
| 11 | 10
| -------
| 01 | 00
'''
k = 0x1
pi = [0, 1]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_1 = psk_4_0x1_0_1
def psk_4_0x2_0_1():
'''
| 00 | 01
| -------
| 10 | 11
'''
k = 0x2
pi = [0, 1]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_2 = psk_4_0x2_0_1
def psk_4_0x3_0_1():
'''
| 01 | 00
| -------
| 11 | 10
'''
k = 0x3
pi = [0, 1]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_3 = psk_4_0x3_0_1
def psk_4_0x0_1_0():
'''
| 01 | 11
| -------
| 00 | 10
'''
k = 0x0
pi = [1, 0]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_4 = psk_4_0x0_1_0
def psk_4_0x1_1_0():
'''
| 00 | 10
| -------
| 01 | 11
'''
k = 0x1
pi = [1, 0]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_5 = psk_4_0x1_1_0
def psk_4_0x2_1_0():
'''
| 11 | 01
| -------
| 10 | 00
'''
k = 0x2
pi = [1, 0]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_6 = psk_4_0x2_1_0
def psk_4_0x3_1_0():
'''
| 10 | 00
| -------
| 11 | 01
'''
k = 0x3
pi = [1, 0]
return constellation_map_generator(psk_4()[0], psk_4()[1], k, pi)
psk_4_7 = psk_4_0x3_1_0
############################################################
# QPSK Constellation Softbit LUT generators
############################################################
def sd_psk_4_0x0_0_1(x, Es=1):
'''
| 10 | 11
| -------
| 00 | 01
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [dist*x_im, dist*x_re]
sd_psk_4 = sd_psk_4_0x0_0_1
sd_psk_4_0 = sd_psk_4
def sd_psk_4_0x1_0_1(x, Es=1):
'''
| 11 | 10
| -------
| 01 | 00
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [dist*x_im, -dist*x_re]
sd_psk_4_1 = sd_psk_4_0x1_0_1
def sd_psk_4_0x2_0_1(x, Es=1):
'''
| 00 | 01
| -------
| 10 | 11
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [-dist*x_im, dist*x_re]
sd_psk_4_2 = sd_psk_4_0x2_0_1
def sd_psk_4_0x3_0_1(x, Es=1):
'''
| 01 | 00
| -------
| 11 | 10
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [-dist*x_im, -dist*x_re]
sd_psk_4_3 = sd_psk_4_0x3_0_1
def sd_psk_4_0x0_1_0(x, Es=1):
'''
| 01 | 11
| -------
| 00 | 10
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [dist*x_re, dist*x_im]
sd_psk_4_4 = sd_psk_4_0x0_1_0
def sd_psk_4_0x1_1_0(x, Es=1):
'''
| 00 | 10
| -------
| 01 | 11
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [dist*x_re, -dist*x_im]
sd_psk_4_5 = sd_psk_4_0x1_1_0
def sd_psk_4_0x2_1_0(x, Es=1):
'''
| 11 | 01
| -------
| 10 | 00
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [-dist*x_re, dist*x_im]
sd_psk_4_6 = sd_psk_4_0x2_1_0
def sd_psk_4_0x3_1_0(x, Es=1):
'''
| 10 | 00
| -------
| 11 | 01
'''
x_re = x.real
x_im = x.imag
dist = Es*numpy.sqrt(2)
return [-dist*x_re, -dist*x_im]
sd_psk_4_7 = sd_psk_4_0x3_1_0
|