summaryrefslogtreecommitdiff
path: root/gr-digital/python
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python')
-rw-r--r--gr-digital/python/CMakeLists.txt2
-rw-r--r--gr-digital/python/cpm.py5
-rw-r--r--gr-digital/python/generic_mod_demod.py7
-rw-r--r--gr-digital/python/gfsk.py9
-rw-r--r--gr-digital/python/gmsk.py9
-rw-r--r--gr-digital/python/ofdm_receiver.py5
-rwxr-xr-xgr-digital/python/qa_constellation.py2
-rwxr-xr-xgr-digital/python/qa_constellation_receiver.py31
-rwxr-xr-xgr-digital/python/qa_cpm.py11
-rwxr-xr-xgr-digital/python/qa_fll_band_edge.py7
-rwxr-xr-xgr-digital/python/qa_lfsr.py49
11 files changed, 111 insertions, 26 deletions
diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt
index fdb5acd819..4ea656e29c 100644
--- a/gr-digital/python/CMakeLists.txt
+++ b/gr-digital/python/CMakeLists.txt
@@ -73,6 +73,8 @@ foreach(py_qa_test_file ${py_qa_test_files})
${CMAKE_BINARY_DIR}/gr-digital/swig
${CMAKE_BINARY_DIR}/gr-filter/python
${CMAKE_BINARY_DIR}/gr-filter/swig
+ ${CMAKE_BINARY_DIR}/gr-analog/python
+ ${CMAKE_BINARY_DIR}/gr-analog/swig
)
set(GR_TEST_TARGET_DEPS volk gruel gnuradio-core gnuradio-digital)
GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
diff --git a/gr-digital/python/cpm.py b/gr-digital/python/cpm.py
index a2c9f2f0e0..1929a73d30 100644
--- a/gr-digital/python/cpm.py
+++ b/gr-digital/python/cpm.py
@@ -25,6 +25,7 @@
# See gnuradio-examples/python/digital for examples
from gnuradio import gr, filter
+from gnuradio import analog
from math import pi
import numpy
@@ -126,7 +127,7 @@ class cpm_mod(gr.hier_block2):
if cpm_type == 0: # CPFSK
self.taps= (1.0/self._symbols_per_pulse/2,) * self.ntaps
elif cpm_type == 1: # GMSK
- gaussian_taps = gr.firdes.gaussian(
+ gaussian_taps = filter.firdes.gaussian(
1.0/2, # gain
samples_per_symbol, # symbol_rate
bt, # bandwidth * symbol time
@@ -145,7 +146,7 @@ class cpm_mod(gr.hier_block2):
self.filter = filter.pfb.arb_resampler_fff(samples_per_symbol, self.taps)
# FM modulation
- self.fmmod = gr.frequency_modulator_fc(sensitivity)
+ self.fmmod = analog.frequency_modulator_fc(sensitivity)
if verbose:
self._print_verbage()
diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py
index 855249dc63..b71118ebcb 100644
--- a/gr-digital/python/generic_mod_demod.py
+++ b/gr-digital/python/generic_mod_demod.py
@@ -36,6 +36,11 @@ try:
except ImportError:
import filter_swig as filter
+try:
+ from gnuradio import analog
+except ImportError:
+ import analog_swig as analog
+
# default values (used in __init__ and add_options)
_def_samples_per_symbol = 2
_def_excess_bw = 0.35
@@ -264,7 +269,7 @@ class generic_demod(gr.hier_block2):
ntaps = 11 * int(self._samples_per_symbol*nfilts)
# Automatic gain control
- self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
+ self.agc = analog.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
# Frequency correction
fll_ntaps = 55
diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py
index 09f12ebc30..c69dd4d7d8 100644
--- a/gr-digital/python/gfsk.py
+++ b/gr-digital/python/gfsk.py
@@ -2,7 +2,7 @@
# GFSK modulation and demodulation.
#
#
-# Copyright 2005,2006,2007 Free Software Foundation, Inc.
+# Copyright 2005-2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,7 @@
# See gnuradio-examples/python/digital for examples
from gnuradio import gr
+from gnuradio import analog
import modulation_utils
import digital_swig as digital
from math import pi
@@ -102,7 +103,7 @@ class gfsk_mod(gr.hier_block2):
# Form Gaussian filter
# Generate Gaussian response (Needs to be convolved with window below).
- self.gaussian_taps = gr.firdes.gaussian(
+ self.gaussian_taps = filter.firdes.gaussian(
1.0, # gain
samples_per_symbol, # symbol_rate
bt, # bandwidth * symbol time
@@ -114,7 +115,7 @@ class gfsk_mod(gr.hier_block2):
self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps)
# FM modulation
- self.fmmod = gr.frequency_modulator_fc(sensitivity)
+ self.fmmod = frequency.frequency_modulator_fc(sensitivity)
# small amount of output attenuation to prevent clipping USRP sink
self.amp = gr.multiply_const_cc(0.999)
@@ -230,7 +231,7 @@ class gfsk_demod(gr.hier_block2):
# Demodulate FM
#sensitivity = (pi / 2) / samples_per_symbol
- self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity)
+ self.fmdemod = analog.quadrature_demod_cf(1.0 / sensitivity)
# the clock recovery block tracks the symbol clock and resamples as needed.
# the output of the block is a stream of soft symbols (float)
diff --git a/gr-digital/python/gmsk.py b/gr-digital/python/gmsk.py
index e7853dd0af..c0f5c439aa 100644
--- a/gr-digital/python/gmsk.py
+++ b/gr-digital/python/gmsk.py
@@ -2,7 +2,7 @@
# GMSK modulation and demodulation.
#
#
-# Copyright 2005,2006,2007 Free Software Foundation, Inc.
+# Copyright 2005-2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,7 @@
# See gnuradio-examples/python/digital for examples
from gnuradio import gr
+from gnuradio import analog
import modulation_utils
import digital_swig as digital
from math import pi
@@ -101,7 +102,7 @@ class gmsk_mod(gr.hier_block2):
# Form Gaussian filter
# Generate Gaussian response (Needs to be convolved with window below).
- self.gaussian_taps = gr.firdes.gaussian(
+ self.gaussian_taps = filter.firdes.gaussian(
1, # gain
samples_per_symbol, # symbol_rate
bt, # bandwidth * symbol time
@@ -113,7 +114,7 @@ class gmsk_mod(gr.hier_block2):
self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps)
# FM modulation
- self.fmmod = gr.frequency_modulator_fc(sensitivity)
+ self.fmmod = analog.frequency_modulator_fc(sensitivity)
if verbose:
self._print_verbage()
@@ -220,7 +221,7 @@ class gmsk_demod(gr.hier_block2):
# Demodulate FM
sensitivity = (pi / 2) / samples_per_symbol
- self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity)
+ self.fmdemod = analog.quadrature_demod_cf(1.0 / sensitivity)
# the clock recovery block tracks the symbol clock and resamples as needed.
# the output of the block is a stream of soft symbols (float)
diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py
index 1dc3cdf7cd..ace64a8089 100644
--- a/gr-digital/python/ofdm_receiver.py
+++ b/gr-digital/python/ofdm_receiver.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+# Copyright 2006-2008 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -23,6 +23,7 @@
import math
from numpy import fft
from gnuradio import gr
+from gnuradio import analog
import digital_swig as digital
from ofdm_sync_pn import ofdm_sync_pn
@@ -119,7 +120,7 @@ class ofdm_receiver(gr.hier_block2):
# Set up blocks
- self.nco = gr.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block
+ self.nco = analog.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block
self.sigmix = gr.multiply_cc()
self.sampler = digital.ofdm_sampler(fft_length, fft_length+cp_length)
self.fft_demod = gr.fft_vcc(fft_length, True, win, True)
diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py
index 750337a119..9d6f4c6427 100755
--- a/gr-digital/python/qa_constellation.py
+++ b/gr-digital/python/qa_constellation.py
@@ -23,7 +23,7 @@
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 as digital
diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py
index 871df2da28..6da3fc1066 100755
--- a/gr-digital/python/qa_constellation_receiver.py
+++ b/gr-digital/python/qa_constellation_receiver.py
@@ -22,10 +22,11 @@
import random
-from gnuradio import gr, blks2, gr_unittest
+from gnuradio import gr, gr_unittest
from utils import mod_codes, alignment
import packet_utils
import filter_swig as filter
+import analog_swig as analog
from generic_mod_demod import generic_mod, generic_demod
from qa_constellation import tested_constellations, twod_constell
@@ -38,7 +39,7 @@ SEED = 1239
# TESTING PARAMETERS
# The number of symbols to test with.
# We need this many to let the frequency recovery block converge.
-DATA_LENGTH = 2000
+DATA_LENGTH = 1000
# Test fails if fraction of output that is correct is less than this.
REQ_CORRECT = 0.7
@@ -51,6 +52,28 @@ TIMING_OFFSET = 1.0
FREQ_BW = 2*math.pi/100.0
PHASE_BW = 2*math.pi/100.0
+class channel_model(gr.hier_block2):
+ def __init__(self, noise_voltage, freq, timing):
+ gr.hier_block2.__init__(self, "channel_model",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex),
+ gr.io_signature(1, 1, gr.sizeof_gr_complex))
+
+
+ timing_offset = filter.fractional_interpolator_cc(0, timing)
+ noise_adder = gr.add_cc()
+ noise = analog.noise_source_c(analog.GR_GAUSSIAN,
+ noise_voltage, 0)
+ freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE,
+ freq, 1.0, 0.0)
+ mixer_offset = gr.multiply_cc();
+
+ self.connect(self, timing_offset)
+ self.connect(timing_offset, (mixer_offset,0))
+ self.connect(freq_offset, (mixer_offset,1))
+ self.connect(mixer_offset, (noise_adder,1))
+ self.connect(noise, (noise_adder,0))
+ self.connect(noise_adder, self)
+
class test_constellation_receiver(gr_unittest.TestCase):
@@ -131,9 +154,9 @@ class rec_test_tb(gr.top_block):
mod = generic_mod(constellation, differential=differential)
# Channel
if freq_offset:
- channel = filter.channel_model(NOISE_VOLTAGE, FREQUENCY_OFFSET, TIMING_OFFSET)
+ channel = channel_model(NOISE_VOLTAGE, FREQUENCY_OFFSET, TIMING_OFFSET)
else:
- channel = filter.channel_model(NOISE_VOLTAGE, 0, TIMING_OFFSET)
+ channel = channel_model(NOISE_VOLTAGE, 0, TIMING_OFFSET)
# Receiver Blocks
if freq_offset:
demod = generic_demod(constellation, differential=differential,
diff --git a/gr-digital/python/qa_cpm.py b/gr-digital/python/qa_cpm.py
index 2221d16b6f..bfeb2bcdd4 100755
--- a/gr-digital/python/qa_cpm.py
+++ b/gr-digital/python/qa_cpm.py
@@ -22,6 +22,7 @@
from gnuradio import gr, gr_unittest
import digital_swig as digital
+import analog_swig as analog
import numpy
class test_cpm(gr_unittest.TestCase):
@@ -51,16 +52,16 @@ class test_cpm(gr_unittest.TestCase):
msg="Phase shift was not correct for CPM method " + name)
def test_001_lrec(self):
- self.do_check_phase_shift(gr.cpm.LRC, 'LREC')
+ self.do_check_phase_shift(analog.cpm.LRC, 'LREC')
def test_001_lrc(self):
- self.do_check_phase_shift(gr.cpm.LRC, 'LRC')
+ self.do_check_phase_shift(analog.cpm.LRC, 'LRC')
def test_001_lsrc(self):
- self.do_check_phase_shift(gr.cpm.LSRC, 'LSRC')
+ self.do_check_phase_shift(analog.cpm.LSRC, 'LSRC')
def test_001_ltfm(self):
- self.do_check_phase_shift(gr.cpm.TFM, 'TFM')
+ self.do_check_phase_shift(analog.cpm.TFM, 'TFM')
def test_001_lgmsk(self):
sps = 2
@@ -82,7 +83,7 @@ class test_cpm(gr_unittest.TestCase):
msg="Phase shift was not correct for GMSK")
def test_phase_response(self):
- phase_response = gr.cpm.phase_response(gr.cpm.LREC, 2, 4)
+ phase_response = analog.cpm.phase_response(analog.cpm.LREC, 2, 4)
self.assertAlmostEqual(numpy.sum(phase_response), 1)
diff --git a/gr-digital/python/qa_fll_band_edge.py b/gr-digital/python/qa_fll_band_edge.py
index a4269931f5..1e699bbdd4 100755
--- a/gr-digital/python/qa_fll_band_edge.py
+++ b/gr-digital/python/qa_fll_band_edge.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -23,6 +23,7 @@
from gnuradio import gr, gr_unittest
import digital_swig as digital
import filter_swig as filter
+import analog_swig as analog
import random, math
class test_fll_band_edge_cc(gr_unittest.TestCase):
@@ -40,7 +41,7 @@ class test_fll_band_edge_cc(gr_unittest.TestCase):
ntaps = 45
# Create pulse shape filter
- rrc_taps = gr.firdes.root_raised_cosine(
+ rrc_taps = filter.firdes.root_raised_cosine(
sps, sps, 1.0, rolloff, ntaps)
# The frequency offset to correct
@@ -53,7 +54,7 @@ class test_fll_band_edge_cc(gr_unittest.TestCase):
self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps)
# Mix symbols with a complex sinusoid to spin them
- self.nco = gr.sig_source_c(1, gr.GR_SIN_WAVE, foffset, 1)
+ self.nco = analog.sig_source_c(1, analog.GR_SIN_WAVE, foffset, 1)
self.mix = gr.multiply_cc()
# FLL will despin the symbols to an arbitrary phase
diff --git a/gr-digital/python/qa_lfsr.py b/gr-digital/python/qa_lfsr.py
new file mode 100755
index 0000000000..d70c466ca7
--- /dev/null
+++ b/gr-digital/python/qa_lfsr.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+import digital_swig as digital
+import math
+
+
+class test_lfsr(gr_unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def test_lfsr_001(self):
+ reglen = 8
+ l = digital.lfsr(1, 1, reglen)
+
+ result_data = []
+ for i in xrange(4*(reglen+1)):
+ result_data.append(l.next_bit())
+
+ expected_result = 4*([1,] + reglen*[0,])
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data, 5)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_lfsr, "test_lfsr.xml")
+