diff options
author | Johnathan Corgan <jcorgan@corganenterprises.com> | 2010-03-21 16:17:15 -0700 |
---|---|---|
committer | Johnathan Corgan <jcorgan@corganenterprises.com> | 2010-03-21 16:17:15 -0700 |
commit | 1ae689ff9238dcffbf65881b8ca03aa8df3844aa (patch) | |
tree | 84592461ca6427fa63c62a846ae75fe2d86e3059 /gnuradio-core/src/python | |
parent | 769b8bbe0aed088b6d1582d2d81d0966cee4c604 (diff) |
Add new block gr.additive_scrambler_bb()
This block performs scrambling by XORing the input sequence with
the output of an LFSR. Repeating this operation restores the original
sequence.
(This differs from gr.scrambler_bb(), which convolves the input sequence
with the LFSR output.)
The additive scrambler allows an optional bit count after which the LFSR
is reset to its initial seed. This allows use with, e.g., packetized
fixed length payloads.
Diffstat (limited to 'gnuradio-core/src/python')
-rwxr-xr-x | gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py index 76b0e62fa4..aecf492933 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py @@ -40,5 +40,25 @@ class test_scrambler(gr_unittest.TestCase): self.tb.run() self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization + def test_additive_scrambler(self): + src_data = (1,)*1000 + src = gr.vector_source_b(src_data, False) + scrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7) + descrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7) + dst = gr.vector_sink_b() + self.tb.connect(src, scrambler, descrambler, dst) + self.tb.run() + self.assertEqual(src_data, dst.data()) + + def test_additive_scrambler_reset(self): + src_data = (1,)*1000 + src = gr.vector_source_b(src_data, False) + scrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7, 100) + descrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7, 100) + dst = gr.vector_sink_b() + self.tb.connect(src, scrambler, descrambler, dst) + self.tb.run() + self.assertEqual(src_data, dst.data()) + if __name__ == '__main__': gr_unittest.main () |