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/lib/general/gri_lfsr.h | |
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/lib/general/gri_lfsr.h')
-rw-r--r-- | gnuradio-core/src/lib/general/gri_lfsr.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/general/gri_lfsr.h b/gnuradio-core/src/lib/general/gri_lfsr.h index 715da78a94..f691e36ecb 100644 --- a/gnuradio-core/src/lib/general/gri_lfsr.h +++ b/gnuradio-core/src/lib/general/gri_lfsr.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -86,6 +86,7 @@ class gri_lfsr private: uint32_t d_shift_register; uint32_t d_mask; + uint32_t d_seed; uint32_t d_shift_register_length; // less than 32 static uint32_t @@ -99,7 +100,10 @@ class gri_lfsr public: gri_lfsr(uint32_t mask, uint32_t seed, uint32_t reg_len) - : d_shift_register(seed), d_mask(mask), d_shift_register_length(reg_len) + : d_shift_register(seed), + d_mask(mask), + d_seed(seed), + d_shift_register_length(reg_len) { if (reg_len > 31) throw std::invalid_argument("reg_len must be <= 31"); @@ -126,6 +130,10 @@ class gri_lfsr return output; } + /*! + * Reset shift register to initial seed value + */ + void reset() { d_shift_register = d_seed; } /*! * Rotate the register through x number of bits |