summaryrefslogtreecommitdiff
path: root/gr-digital/python
diff options
context:
space:
mode:
authorTom Rondeau2013-02-20 10:55:59 -0500
committerTom Rondeau2013-02-20 10:58:20 -0500
commit627958e8b21edabff55f3beb87c01cea5fd1dd77 (patch)
treeace781b805c853843492303b22aeca8a9f8ce957 /gr-digital/python
parentbbc4da8394b491058d35c94f4c4a934485df07b6 (diff)
downloadgnuradio-627958e8b21edabff55f3beb87c01cea5fd1dd77.tar.gz
gnuradio-627958e8b21edabff55f3beb87c01cea5fd1dd77.tar.bz2
gnuradio-627958e8b21edabff55f3beb87c01cea5fd1dd77.zip
digital: moved simple_correlator (inverse of simple_framer) to gr-digital.
Diffstat (limited to 'gr-digital/python')
-rwxr-xr-xgr-digital/python/qa_simple_correlator.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/gr-digital/python/qa_simple_correlator.py b/gr-digital/python/qa_simple_correlator.py
new file mode 100755
index 000000000..124201a55
--- /dev/null
+++ b/gr-digital/python/qa_simple_correlator.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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
+
+class test_simple_correlator(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_00(self):
+ expected_result = (
+ 0x00, 0x11, 0x22, 0x33,
+ 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb,
+ 0xcc, 0xdd, 0xee, 0xff)
+
+ # Filter taps to expand the data to oversample by 8
+ # Just using a RRC for some basic filter shape
+ taps = gr.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 21)
+
+ src = gr.vector_source_b(expected_result)
+ frame = digital.simple_framer(4)
+ unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
+ expand = gr.interp_fir_filter_fff(8, taps)
+ b2f = gr.char_to_float()
+ mult2 = gr.multiply_const_ff(2)
+ sub1 = gr.add_const_ff(-1)
+ op = digital.simple_correlator(4)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, frame, unpack, b2f, mult2, sub1, expand)
+ self.tb.connect(expand, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_simple_correlator, "test_simple_correlator.xml")