summaryrefslogtreecommitdiff
path: root/gr-digital/python/qa_constellation.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python/qa_constellation.py')
-rwxr-xr-xgr-digital/python/qa_constellation.py59
1 files changed, 34 insertions, 25 deletions
diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py
index ddd8c71e64..a593c3ea3e 100755
--- a/gr-digital/python/qa_constellation.py
+++ b/gr-digital/python/qa_constellation.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -23,9 +23,10 @@
import random
from cmath import exp, pi, log
-from gnuradio import gr, gr_unittest, blks2
+from gnuradio import gr, gr_unittest
from utils import mod_codes
-import digital_swig
+import digital_swig as digital
+import blocks_swig as blocks
# import from local folder
import psk
@@ -51,7 +52,7 @@ def twod_constell():
(-1+0j), (0-1j))
rot_sym = 2
dim = 2
- return digital_swig.constellation_calcdist(points, [], rot_sym, dim)
+ return digital.constellation_calcdist(points, [], rot_sym, dim)
def threed_constell():
oned_points = ((1+0j), (0+1j), (-1+0j), (0-1j))
@@ -63,7 +64,7 @@ def threed_constell():
points += [oned_points[ia], oned_points[ib], oned_points[ic]]
rot_sym = 4
dim = 3
- return digital_swig.constellation_calcdist(points, [], rot_sym, dim)
+ return digital.constellation_calcdist(points, [], rot_sym, dim)
# A list of tuples for constellation testing. The contents of the
# tuples are (constructor, poss_args, differential, diff_argname).
@@ -74,15 +75,25 @@ easy_constellation_info = (
{'m': (2, 4, 8, 16, ),
'mod_code': tested_mod_codes, },
True, None),
+ (psk.psk_constellation,
+ {'m': (2, 4, 8, 16, 32, 64),
+ 'mod_code': tested_mod_codes,
+ 'differential': (False,)},
+ False, None),
(qam.qam_constellation,
{'constellation_points': (4,),
'mod_code': tested_mod_codes,
'large_ampls_to_corners': [False],},
True, None),
- (digital_swig.constellation_bpsk, {}, True, None),
- (digital_swig.constellation_qpsk, {}, False, None),
- (digital_swig.constellation_dqpsk, {}, True, None),
- (digital_swig.constellation_8psk, {}, False, None),
+ (qam.qam_constellation,
+ {'constellation_points': (4, 16, 64),
+ 'mod_code': tested_mod_codes,
+ 'differential': (False,)},
+ False, None),
+ (digital.constellation_bpsk, {}, True, None),
+ (digital.constellation_qpsk, {}, False, None),
+ (digital.constellation_dqpsk, {}, True, None),
+ (digital.constellation_8psk, {}, False, None),
(twod_constell, {}, True, None),
(threed_constell, {}, True, None),
)
@@ -150,7 +161,7 @@ def tested_constellations(easy=True, medium=True, difficult=True):
break
-class test_constellation (gr_unittest.TestCase):
+class test_constellation(gr_unittest.TestCase):
src_length = 256
@@ -178,7 +189,7 @@ class test_constellation (gr_unittest.TestCase):
data = dst.data()
# Don't worry about cut off data for now.
first = constellation.bits_per_symbol()
- self.assertEqual (self.src_data[first:len(data)], data[first:])
+ self.assertEqual(self.src_data[first:len(data)], data[first:])
class mod_demod(gr.hier_block2):
@@ -200,40 +211,39 @@ class mod_demod(gr.hier_block2):
self.blocks = [self]
# We expect a stream of unpacked bits.
# First step is to pack them.
- self.blocks.append(
- gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
+ self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
# Second step we unpack them such that we have k bits in each byte where
# each constellation symbol hold k bits.
self.blocks.append(
- gr.packed_to_unpacked_bb(self.constellation.bits_per_symbol(),
- gr.GR_MSB_FIRST))
+ blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(),
+ gr.GR_MSB_FIRST))
# Apply any pre-differential coding
# Gray-coding is done here if we're also using differential coding.
if self.constellation.apply_pre_diff_code():
- self.blocks.append(gr.map_bb(self.constellation.pre_diff_code()))
+ self.blocks.append(digital.map_bb(self.constellation.pre_diff_code()))
# Differential encoding.
if self.differential:
- self.blocks.append(gr.diff_encoder_bb(arity))
+ self.blocks.append(digital.diff_encoder_bb(arity))
# Convert to constellation symbols.
- self.blocks.append(gr.chunks_to_symbols_bc(self.constellation.points(),
- self.constellation.dimensionality()))
+ self.blocks.append(digital.chunks_to_symbols_bc(self.constellation.points(),
+ self.constellation.dimensionality()))
# CHANNEL
# Channel just consists of a rotation to check differential coding.
if rotation is not None:
- self.blocks.append(gr.multiply_const_cc(rotation))
+ self.blocks.append(blocks.multiply_const_cc(rotation))
# RX
# Convert the constellation symbols back to binary values.
- self.blocks.append(digital_swig.constellation_decoder_cb(self.constellation.base()))
+ self.blocks.append(digital.constellation_decoder_cb(self.constellation.base()))
# Differential decoding.
if self.differential:
- self.blocks.append(gr.diff_decoder_bb(arity))
+ self.blocks.append(digital.diff_decoder_bb(arity))
# Decode any pre-differential coding.
if self.constellation.apply_pre_diff_code():
- self.blocks.append(gr.map_bb(
+ self.blocks.append(digital.map_bb(
mod_codes.invert_code(self.constellation.pre_diff_code())))
# unpack the k bit vector into a stream of bits
- self.blocks.append(gr.unpack_k_bits_bb(
+ self.blocks.append(blocks.unpack_k_bits_bb(
self.constellation.bits_per_symbol()))
# connect to block output
check_index = len(self.blocks)
@@ -241,7 +251,6 @@ class mod_demod(gr.hier_block2):
self.blocks.append(self)
self.connect(*self.blocks)
-
if __name__ == '__main__':
gr_unittest.run(test_constellation, "test_constellation.xml")