diff options
Diffstat (limited to 'gr-digital/python/qam.py')
-rw-r--r-- | gr-digital/python/qam.py | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index 6834e1945a..5919839186 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -1,5 +1,5 @@ # -# Copyright 2005,2006,2011 Free Software Foundation, Inc. +# Copyright 2005,2006,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,10 +27,11 @@ from math import pi, sqrt, log from gnuradio import gr from generic_mod_demod import generic_mod, generic_demod +from generic_mod_demod import shared_mod_args, shared_demod_args from utils.gray_code import gray_code from utils import mod_codes import modulation_utils -import digital_swig +import digital_swig as digital # Default number of points in constellation. _def_constellation_points = 16 @@ -165,11 +166,12 @@ def qam_constellation(constellation_points=_def_constellation_points, else: raise ValueError("Mod code is not implemented for QAM") if differential: - points = make_differential_constellation(constellation_points, gray_coded) + points = make_differential_constellation(constellation_points, gray_coded=False) else: points = make_non_differential_constellation(constellation_points, gray_coded) side = int(sqrt(constellation_points)) width = 2.0/(side-1) + # No pre-diff code # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] @@ -180,6 +182,7 @@ def qam_constellation(constellation_points=_def_constellation_points, sector_values = large_ampls_to_corners_mapping(side, points, width) constellation = digital_swig.constellation_expl_rect( points, pre_diff_code, 4, side, side, width, width, sector_values) + return constellation def find_closest_point(p, qs): @@ -257,6 +260,19 @@ def large_ampls_to_corners_mapping(side, points, width): # ///////////////////////////////////////////////////////////////////////////// class qam_mod(generic_mod): + """ + Hierarchical block for RRC-filtered QAM modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation_points: Number of constellation points (must be a power of four) (integer). + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, constellation_points=_def_constellation_points, differential=_def_differential, @@ -291,13 +307,25 @@ class qam_mod(generic_mod): # ///////////////////////////////////////////////////////////////////////////// class qam_demod(generic_demod): + """ + Hierarchical block for RRC-filtered QAM modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation_points: Number of constellation points (must be a power of four) (integer). + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_demod for additional arguments + __doc__ += shared_mod_args def __init__(self, constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code, large_ampls_to_corner = False, *args, **kwargs): - """ Hierarchical block for RRC-filtered QAM modulation. |