11#ifndef INCLUDED_DIGITAL_LFSR_H
12#define INCLUDED_DIGITAL_LFSR_H
15#ifndef HAVE_BUILTIN_PARITYL
85 uint64_t d_shift_register;
88 uint8_t d_shift_register_length;
91 lfsr(uint64_t
mask, uint64_t seed, uint8_t reg_len)
92 : d_shift_register(seed),
95 d_shift_register_length(reg_len)
98 throw std::invalid_argument(
"reg_len must be <= 63");
103 unsigned char output = d_shift_register & 1;
105#ifdef HAVE_BUILTIN_PARITYL
106 newbit = __builtin_parityl(d_shift_register & d_mask);
108 volk_64u_popcnt(&newbit, d_shift_register & d_mask);
113 ((d_shift_register >> 1) | (newbit << d_shift_register_length));
119 unsigned char output = d_shift_register & 1;
121#ifdef HAVE_BUILTIN_PARITYL
122 newbit = __builtin_parityl(d_shift_register & d_mask) ^ (input & 1);
124 volk_64u_popcnt(&newbit, d_shift_register & d_mask);
125 newbit = (newbit ^ input) & 1;
128 ((d_shift_register >> 1) | (newbit << d_shift_register_length));
134 unsigned char output;
135#ifdef HAVE_BUILTIN_PARITYL
136 output = __builtin_parityl(d_shift_register & d_mask) ^ (input & 1);
139 volk_64u_popcnt(&_tmp, d_shift_register & d_mask);
140 output = (_tmp ^ input) & 1;
142 uint64_t newbit = input & 1;
144 ((d_shift_register >> 1) | (newbit << d_shift_register_length));
151 void reset() { d_shift_register = d_seed; }
159 for (
int i = 0; i < num; i++) {
164 uint64_t
mask()
const {
return d_mask; }
Fibonacci Linear Feedback Shift Register using specified polynomial mask.
Definition: lfsr.h:83
void pre_shift(int num)
Definition: lfsr.h:157
void reset()
Definition: lfsr.h:151
unsigned char next_bit_descramble(unsigned char input)
Definition: lfsr.h:132
unsigned char next_bit()
Definition: lfsr.h:101
lfsr(uint64_t mask, uint64_t seed, uint8_t reg_len)
Definition: lfsr.h:91
uint64_t mask() const
Definition: lfsr.h:164
unsigned char next_bit_scramble(unsigned char input)
Definition: lfsr.h:117
GNU Radio logging wrapper.
Definition: basic_block.h:29