From 4daafa4e7d91b01e64cd8260fcbb9a97708524ba Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sun, 17 Jul 2011 18:34:34 -0400
Subject: digital: reverting back to ofdm, pkt, and modulation_utils in
 gnuradio-core to master. Moved new versions under gr-digital.

---
 .../src/python/gnuradio/blks2impl/ofdm.py          | 75 +++++++++++++---------
 1 file changed, 43 insertions(+), 32 deletions(-)

(limited to 'gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py')

diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
index 3b1cd12ac3..2663f7cf87 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
@@ -21,26 +21,12 @@
 # 
 
 import math
-from gnuradio import gr, ofdm_packet_utils, modulation_utils2
+from gnuradio import gr, ofdm_packet_utils
 import gnuradio.gr.gr_threading as _threading
 import psk, qam
 
 from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver
 
-def _add_common_options(normal, expert):
-    """
-    Adds OFDM-specific options to the Options Parser that are common
-    both to the modulator and demodulator.
-    """
-    mods_list = ", ".join(modulation_utils2.type_1_constellations().keys())
-    normal.add_option("-m", "--modulation", type="string", default="psk",
-                      help="set modulation type (" + mods_list + ") [default=%default]")
-    expert.add_option("", "--fft-length", type="intx", default=512,
-                      help="set the number of FFT bins [default=%default]")
-    expert.add_option("", "--occupied-tones", type="intx", default=200,
-                      help="set the number of occupied FFT bins [default=%default]")
-    expert.add_option("", "--cp-length", type="intx", default=128,
-                      help="set the number of bits in the cyclic prefix [default=%default]")
 
 # /////////////////////////////////////////////////////////////////////////////
 #                   mod/demod with packets as i/o
@@ -75,8 +61,6 @@ class ofdm_mod(gr.hier_block2):
         self._fft_length = options.fft_length
         self._occupied_tones = options.occupied_tones
         self._cp_length = options.cp_length
-        
-        arity = options.constellation_points
 
         win = [] #[1 for i in range(self._fft_length)]
 
@@ -98,9 +82,19 @@ class ofdm_mod(gr.hier_block2):
             
         symbol_length = options.fft_length + options.cp_length
         
-        const = modulation_utils2.type_1_constellations()[self._modulation](arity).points()
-
-        self._pkt_input = gr.ofdm_mapper_bcv(const, msgq_limit,
+        mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
+        arity = mods[self._modulation]
+        
+        rot = 1
+        if self._modulation == "qpsk":
+            rot = (0.707+0.707j)
+            
+        if(self._modulation.find("psk") >= 0):
+            rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity])
+        elif(self._modulation.find("qam") >= 0):
+            rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+        #print rotated_const
+        self._pkt_input = gr.ofdm_mapper_bcv(rotated_const, msgq_limit,
                                              options.occupied_tones, options.fft_length)
         
         self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles)
@@ -146,10 +140,14 @@ class ofdm_mod(gr.hier_block2):
         """
         Adds OFDM-specific options to the Options Parser
         """
-        _add_common_options(normal, expert)
-        for mod in modulation_utils2.type_1_mods().values():
-            mod.add_options(expert)
-
+        normal.add_option("-m", "--modulation", type="string", default="bpsk",
+                          help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]")
+        expert.add_option("", "--fft-length", type="intx", default=512,
+                          help="set the number of FFT bins [default=%default]")
+        expert.add_option("", "--occupied-tones", type="intx", default=200,
+                          help="set the number of occupied FFT bins [default=%default]")
+        expert.add_option("", "--cp-length", type="intx", default=128,
+                          help="set the number of bits in the cyclic prefix [default=%default]")
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
 
@@ -198,9 +196,6 @@ class ofdm_demod(gr.hier_block2):
         self._cp_length = options.cp_length
         self._snr = options.snr
 
-        arity = options.constellation_points
-        print("con points is %s" % options.constellation_points)
-        
         # Use freq domain to get doubled-up known symbol for correlation in time domain
         zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0))
         ksfreq = known_symbols_4512_3[0:self._occupied_tones]
@@ -216,11 +211,22 @@ class ofdm_demod(gr.hier_block2):
                                        self._occupied_tones, self._snr, preambles,
                                        options.log)
 
-        constell = modulation_utils2.type_1_constellations()[self._modulation](arity)
+        mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
+        arity = mods[self._modulation]
+        
+        rot = 1
+        if self._modulation == "qpsk":
+            rot = (0.707+0.707j)
+
+        if(self._modulation.find("psk") >= 0):
+            rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity])
+        elif(self._modulation.find("qam") >= 0):
+            rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+        #print rotated_const
 
         phgain = 0.25
         frgain = phgain*phgain / 4.0
-        self.ofdm_demod = gr.ofdm_frame_sink2(constell.base(),
+        self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity),
                                              self._rcvd_pktq,
                                              self._occupied_tones,
                                              phgain, frgain)
@@ -247,9 +253,14 @@ class ofdm_demod(gr.hier_block2):
         """
         Adds OFDM-specific options to the Options Parser
         """
-        _add_common_options(normal, expert)
-        for mod in modulation_utils2.type_1_mods().values():
-            mod.add_options(expert)
+        normal.add_option("-m", "--modulation", type="string", default="bpsk",
+                          help="set modulation type (bpsk or qpsk) [default=%default]")
+        expert.add_option("", "--fft-length", type="intx", default=512,
+                          help="set the number of FFT bins [default=%default]")
+        expert.add_option("", "--occupied-tones", type="intx", default=200,
+                          help="set the number of occupied FFT bins [default=%default]")
+        expert.add_option("", "--cp-length", type="intx", default=128,
+                          help="set the number of bits in the cyclic prefix [default=%default]")
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
 
-- 
cgit v1.2.3