Loading...
Searching...
No Matches
additive_scrambler.h
Go to the documentation of this file.
/* -*- c++ -*- */
/*
* Copyright 2008,2010,2012 Free Software Foundation, Inc.
* Copyright 2024 Daniel Estevez <daniel@destevez.net>
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef INCLUDED_DIGITAL_ADDITIVE_SCRAMBLER_H
#define INCLUDED_DIGITAL_ADDITIVE_SCRAMBLER_H
#include <gnuradio/digital/api.h>
#include <gnuradio/sync_block.h>
namespace gr {
namespace digital {
/*!
* \ingroup coding_blk
*
* \brief
* Scramble an input stream using an LFSR.
*
* \details
*
* The scrambler can work with soft symbols (gr_complex, float,
* int32_t, or int16_t) or with hard symbols (uint8_t). When working
* with soft symbols, the scrambler works by changing the sign of the
* input symbol whenever the output of the LFSR is one.
*
* When working with hard symbols, this block scrambles up to
* 8 bits per byte of the input data stream, starting at the LSB.
* In this case, the scrambler works by XORing the incoming bit stream
* by the output of the LFSR.
*
* In both cases, optionally, after \p count bits have been
* processed, the shift register is reset to the \p seed value.
* This allows processing fixed length vectors of samples.
*
* Alternatively, the LFSR can be reset using a reset tag to
* scramble variable length vectors. However, it cannot be reset
* between bytes in the hard symbol mode.
*
* For details on configuring the LFSR, see gr::digital::lfsr.
*/
template <class T>
class DIGITAL_API additive_scrambler : virtual public sync_block
{
public:
typedef std::shared_ptr<additive_scrambler<T>> sptr;
/*!
* \brief Create additive scrambler.
*
* \param mask Polynomial mask for LFSR
* \param seed Initial shift register contents
* \param len Shift register length
* \param count Number of bytes after which shift register is reset, 0=never
* \param bits_per_byte Number of bits per byte (must be 1 if T != uint8_t)
* \param reset_tag_key When a tag with this key is detected, the shift register is
* reset (when this is set, count is ignored!)
*/
static sptr make(uint64_t mask,
uint64_t seed,
uint8_t len,
int64_t count = 0,
uint8_t bits_per_byte = 1,
const std::string& reset_tag_key = "");
virtual uint64_t mask() const = 0;
virtual uint64_t seed() const = 0;
virtual uint8_t len() const = 0;
virtual int64_t count() const = 0;
virtual uint8_t bits_per_byte() = 0;
};
typedef additive_scrambler<gr_complex> additive_scrambler_cc;
typedef additive_scrambler<float> additive_scrambler_ff;
typedef additive_scrambler<int32_t> additive_scrambler_ii;
typedef additive_scrambler<int16_t> additive_scrambler_ss;
typedef additive_scrambler<uint8_t> additive_scrambler_bb;
} /* namespace digital */
} /* namespace gr */
#endif /* INCLUDED_DIGITAL_ADDITIVE_SCRAMBLER_H */
gr::digital::additive_scrambler
Scramble an input stream using an LFSR.
Definition additive_scrambler.h:51
gr::digital::additive_scrambler< gr_complex >::len
virtual uint8_t len() const=0
gr::digital::additive_scrambler< gr_complex >::mask
virtual uint64_t mask() const=0
gr::digital::additive_scrambler< gr_complex >::count
virtual int64_t count() const=0
gr::digital::additive_scrambler< gr_complex >::bits_per_byte
virtual uint8_t bits_per_byte()=0
gr::digital::additive_scrambler< gr_complex >::seed
virtual uint64_t seed() const=0
gr::digital::additive_scrambler::sptr
std::shared_ptr< additive_scrambler< T > > sptr
Definition additive_scrambler.h:53
gr::digital::additive_scrambler::make
static sptr make(uint64_t mask, uint64_t seed, uint8_t len, int64_t count=0, uint8_t bits_per_byte=1, const std::string &reset_tag_key="")
Create additive scrambler.
gr::sync_block::sync_block
sync_block(void)
Definition sync_block.h:28
api.h
DIGITAL_API
#define DIGITAL_API
Definition gr-digital/include/gnuradio/digital/api.h:18
gr::digital
Definition adaptive_algorithm.h:22
gr::digital::additive_scrambler_ii
additive_scrambler< int32_t > additive_scrambler_ii
Definition additive_scrambler.h:82
gr::digital::additive_scrambler_ss
additive_scrambler< int16_t > additive_scrambler_ss
Definition additive_scrambler.h:83
gr::digital::additive_scrambler_bb
additive_scrambler< uint8_t > additive_scrambler_bb
Definition additive_scrambler.h:84
gr::digital::additive_scrambler_ff
additive_scrambler< float > additive_scrambler_ff
Definition additive_scrambler.h:81
gr::digital::additive_scrambler_cc
additive_scrambler< gr_complex > additive_scrambler_cc
Definition additive_scrambler.h:80
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
sync_block.h