2
# Copyright 2005,2006 Free Software Foundation, Inc.
4
# This file is part of GNU Radio
6
# GNU Radio is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3, or (at your option)
11
# GNU Radio is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with GNU Radio; see the file COPYING. If not, write to
18
# the Free Software Foundation, Inc., 51 Franklin Street,
19
# Boston, MA 02110-1301, USA.
22
from math import pi, sqrt
25
# These constellations are generated for Gray coding when symbos [1, ..., m] are used
26
# Mapping to Gray coding is therefore unnecessary
28
def make_constellation(m):
29
# number of bits/symbol (log2(M))
30
k = int(math.log10(m) / math.log10(2.0))
35
a = (i&(0x01 << k-1)) >> k-1
36
b = (i&(0x01 << k-2)) >> k-2
37
bits_i = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(2, k, 2)]
38
bits_q = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(3, k, 2)]
44
for jj in range(ll-ii):
45
rr = abs(bits_i[jj] - rr)
46
ss += rr*pow(2.0, ii+1)
53
for jj in range(ll-ii):
54
rr = abs(bits_q[jj] - rr)
55
ss += rr*pow(2.0, ii+1)
61
const_map.append(complex(re, im))
63
norm_map = [complex(i.real/coeff, i.imag/coeff) for i in const_map]
66
# Common definition of constellations for Tx and Rx
68
4 : make_constellation(4), # QAM4 (QPSK)
69
8 : make_constellation(8), # QAM8
70
16: make_constellation(16), # QAM16
71
64: make_constellation(64), # QAM64
72
256: make_constellation(256) # QAM256
75
# -----------------------
77
# -----------------------
78
# binary to gray coding
96
# -----------------------
98
# -----------------------