def __init__(self, mod_code=None, differential=False, *args, **kwargs): constellation = digital_swig.constellation_bpsk() super(bpsk_mod, self).__init__(constellation=constellation, differential=differential, *args, **kwargs)
def _get_constellation(bps): """ Returns a modulator block for a given number of bits per symbol """ constellation = {1: digital.constellation_bpsk(), 2: digital.constellation_qpsk(), 3: digital.constellation_8psk()} try: return constellation[bps] except KeyError: print "Modulation not supported." exit(1)
def _get_constellation(bps): """ Returns a modulator block for a given number of bits per symbol """ constellation = { 1: digital.constellation_bpsk(), 2: digital.constellation_qpsk(), 3: digital.constellation_8psk() } try: return constellation[bps] except KeyError: print 'Modulation not supported.' exit(1)
def test_constellation_decoder_cb_bpsk(self): cnst = digital.constellation_bpsk() src_data = (0.5 + 0.5j, 0.1 - 1.2j, -0.8 - 0.1j, -0.45 + 0.8j, 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j) expected_result = (1, 1, 0, 0, 1, 0, 1) src = blocks.vector_source_c(src_data) op = digital.constellation_decoder_cb(cnst.base()) dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() # run the graph and wait for it to finish actual_result = dst.data() # fetch the contents of the sink # print "actual result", actual_result # print "expected result", expected_result self.assertFloatTuplesAlmostEqual(expected_result, actual_result)
def test_constellation_decoder_cb_bpsk(self): cnst = digital.constellation_bpsk() src_data = (0.5 + 0.5j, 0.1 - 1.2j, -0.8 - 0.1j, -0.45 + 0.8j, 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j) expected_result = (1, 1, 0, 0, 1, 0, 1) src = blocks.vector_source_c(src_data) op = digital.constellation_decoder_cb(cnst.base()) dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() # run the graph and wait for it to finish actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result self.assertFloatTuplesAlmostEqual(expected_result, actual_result)
def __init__(self, constellation_points=_def_constellation_points, differential=False, *args, **kwargs): """ Hierarchical block for RRC-filtered BPSK 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 BPSK.') super(bpsk_demod, self).__init__(constellation=constellation, differential=differential, *args, **kwargs)
def __init__(self, constellation_points=_def_constellation_points, differential=False, *args, **kwargs): """ Hierarchical block for RRC-filtered BPSK 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 BPSK.') super(bpsk_demod, self).__init__(constellation=constellation, differential=differential, *args, **kwargs)
import digital_swig fsm_args = { "awgn1o2_4": ( 2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), (0, 3, 3, 0, 1, 2, 2, 1), ), "rep2": (2, 1, 4, (0, 0), (0, 3)), "nothing": (2, 1, 2, (0, 0), (0, 1)), } constells = { 2: digital_swig.constellation_bpsk(), 4: digital_swig.constellation_qpsk(), } class test_trellis(gr_unittest.TestCase): def test_001_fsm(self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) self.assertEqual(fsm_args["awgn1o2_4"], (f.I(), f.S(), f.O(), f.NS(), f.OS())) def test_002_fsm(self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) g = trellis.fsm(f) self.assertEqual((g.I(), g.S(), g.O(), g.NS(), g.OS()), (f.I(), f.S(), f.O(), f.NS(), f.OS()))
def __init__(self, mod_code=None, differential=False, *args, **kwargs): constellation = digital_swig.constellation_bpsk() super(bpsk_demod, self).__init__(constellation=constellation, differential=differential, *args, **kwargs)
def bpsk_constellation(): return digital_swig.constellation_bpsk()
# It's pretty ugly that we can't import trellis from gnuradio in this test # but because it runs on the non-installed python code it's all a mess. import trellis import os import digital_swig fsm_args = {"awgn1o2_4": (2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), (0, 3, 3, 0, 1, 2, 2, 1), ), "rep2": (2, 1, 4, (0, 0), (0, 3)), "nothing": (2, 1, 2, (0, 0), (0, 1)), } constells = {2: digital_swig.constellation_bpsk(), 4: digital_swig.constellation_qpsk(), } class test_trellis (gr_unittest.TestCase): def test_001_fsm (self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS())) def test_002_fsm (self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) g = trellis.fsm(f) self.assertEqual((g.I(),g.S(),g.O(),g.NS(),g.OS()),(f.I(),f.S(),f.O(),f.NS(),f.OS())) def test_003_fsm (self):
def bpsk_constellation(m=_def_constellation_points): if m != _def_constellation_points: raise ValueError("BPSK can only have 2 constellation points.") return digital_swig.constellation_bpsk()
import os from gnuradio import gr, gr_unittest import trellis_swig as trellis import digital_swig as digital import analog_swig as analog import blocks_swig as blocks fsm_args = { "awgn1o2_4": (2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), (0, 3, 3, 0, 1, 2, 2, 1)), "rep2": (2, 1, 4, (0, 0), (0, 3)), "nothing": (2, 1, 2, (0, 0), (0, 1)), } constells = {2: digital.constellation_bpsk(), 4: digital.constellation_qpsk()} class test_trellis(gr_unittest.TestCase): def test_001_fsm(self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) self.assertEqual(fsm_args["awgn1o2_4"], (f.I(), f.S(), f.O(), f.NS(), f.OS())) def test_002_fsm(self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) g = trellis.fsm(f) self.assertEqual((g.I(), g.S(), g.O(), g.NS(), g.OS()), (f.I(), f.S(), f.O(), f.NS(), f.OS())) def test_003_fsm(self): # FIXME: no file "awgn1o2_4.fsm" # f = trellis.fsm("awgn1o2_4.fsm")
import blocks_swig as blocks fsm_args = { "awgn1o2_4": ( 2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), (0, 3, 3, 0, 1, 2, 2, 1), ), "rep2": (2, 1, 4, (0, 0), (0, 3)), "nothing": (2, 1, 2, (0, 0), (0, 1)), } constells = { 2: digital.constellation_bpsk(), 4: digital.constellation_qpsk(), } class test_trellis(gr_unittest.TestCase): def test_001_fsm(self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) self.assertEqual(fsm_args["awgn1o2_4"], (f.I(), f.S(), f.O(), f.NS(), f.OS())) def test_002_fsm(self): f = trellis.fsm(*fsm_args["awgn1o2_4"]) g = trellis.fsm(f) self.assertEqual((g.I(), g.S(), g.O(), g.NS(), g.OS()), (f.I(), f.S(), f.O(), f.NS(), f.OS()))