From 57860e0199c005f26b4942cc7ed5e5acf829a68b Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Wed, 10 Aug 2011 22:37:51 -0400
Subject: Cleaning up; adding a different dbpsk that uses differential coding.
 The normal bpsk is non-differential by default, but can be set to use
 differential with the right flag.

---
 gr-digital/python/bpsk.py | 79 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 73 insertions(+), 6 deletions(-)

(limited to 'gr-digital/python/bpsk.py')

diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py
index 806a5d6951..58a8289a56 100644
--- a/gr-digital/python/bpsk.py
+++ b/gr-digital/python/bpsk.py
@@ -34,7 +34,7 @@ import modulation_utils2
 # Default number of points in constellation.
 _def_constellation_points = 2
 # Whether differential coding is used.
-_def_differential = True
+_def_differential = False
 
 # /////////////////////////////////////////////////////////////////////////////
 #                           BPSK constellation
@@ -52,7 +52,7 @@ def bpsk_constellation(m=_def_constellation_points):
 class bpsk_mod(generic_mod):
 
     def __init__(self, constellation_points=_def_constellation_points,
-                 *args, **kwargs):
+                 differential=False, *args, **kwargs):
 
         """
 	Hierarchical block for RRC-filtered BPSK modulation.
@@ -68,8 +68,8 @@ class bpsk_mod(generic_mod):
         if constellation_points != 2:
             raise ValueError('Number of constellation points must be 2 for BPSK.')
         super(bpsk_mod, self).__init__(constellation=constellation,
-                                       *args, **kwargs)
-
+                                       differential=differential, *args, **kwargs)
+        
 # /////////////////////////////////////////////////////////////////////////////
 #                           BPSK demodulator
 #
@@ -78,7 +78,7 @@ class bpsk_mod(generic_mod):
 class bpsk_demod(generic_demod):
 
     def __init__(self, constellation_points=_def_constellation_points,
-                 *args, **kwargs):
+                 differential=False, *args, **kwargs):
 
         """
 	Hierarchical block for RRC-filtered BPSK modulation.
@@ -94,7 +94,71 @@ class bpsk_demod(generic_demod):
         if constellation_points != 2:
             raise ValueError('Number of constellation points must be 2 for BPSK.')
         super(bpsk_demod, self).__init__(constellation=constellation,
-                                         *args, **kwargs)
+                                         differential=differential, *args, **kwargs)
+
+
+
+# /////////////////////////////////////////////////////////////////////////////
+#                           DBPSK constellation
+# /////////////////////////////////////////////////////////////////////////////
+
+def dbpsk_constellation(m=_def_constellation_points):
+    if m != _def_constellation_points:
+        raise ValueError("DBPSK can only have 2 constellation points.")
+    return digital_swig.constellation_dbpsk()
+
+# /////////////////////////////////////////////////////////////////////////////
+#                           DBPSK modulator
+# /////////////////////////////////////////////////////////////////////////////
+
+class dbpsk_mod(generic_mod):
+
+    def __init__(self, constellation_points=_def_constellation_points,
+                 differential=True, *args, **kwargs):
+
+        """
+	Hierarchical block for RRC-filtered DBPSK modulation.
+
+	The input is a byte stream (unsigned char) and the
+	output is the complex modulated signal at baseband.
+
+        See generic_mod block for list of parameters.
+	"""
+
+        constellation_points = _def_constellation_points
+        constellation = digital_swig.constellation_bpsk()
+        if constellation_points != 2:
+            raise ValueError('Number of constellation points must be 2 for DBPSK.')
+        super(dbpsk_mod, self).__init__(constellation=constellation,
+                                        differential=True,
+                                        *args, **kwargs)
+
+# /////////////////////////////////////////////////////////////////////////////
+#                           DBPSK demodulator
+#
+# /////////////////////////////////////////////////////////////////////////////
+
+class dbpsk_demod(generic_demod):
+
+    def __init__(self, constellation_points=_def_constellation_points,
+                 differential=True, *args, **kwargs):
+
+        """
+	Hierarchical block for RRC-filtered DBPSK modulation.
+
+	The input is a byte stream (unsigned char) and the
+	output is the complex modulated signal at baseband.
+
+        See generic_demod block for list of parameters.
+        """
+
+        constellation_points = _def_constellation_points
+        constellation = digital_swig.constellation_bpsk()
+        if constellation_points != 2:
+            raise ValueError('Number of constellation points must be 2 for DBPSK.')
+        super(dbpsk_demod, self).__init__(constellation=constellation,
+                                          differential=True,
+                                          *args, **kwargs)
 
 #
 # Add these to the mod/demod registry
@@ -102,3 +166,6 @@ class bpsk_demod(generic_demod):
 modulation_utils2.add_type_1_mod('bpsk', bpsk_mod)
 modulation_utils2.add_type_1_demod('bpsk', bpsk_demod)
 modulation_utils2.add_type_1_constellation('bpsk', bpsk_constellation)
+modulation_utils2.add_type_1_mod('dbpsk', dbpsk_mod)
+modulation_utils2.add_type_1_demod('dbpsk', dbpsk_demod)
+modulation_utils2.add_type_1_constellation('dbpsk', dbpsk_constellation)
-- 
cgit v1.2.3