the width of the LFSR
a set of tap points to use when constructing the LFSR
an initial value for internal LFSR state. If None, then the LFSR state LSB will be set to a known safe value on reset (to prevent lock up).
the number of state updates per cycle
if true, when loading the seed the state will be updated as if the seed were the current state, if false, the state will be set to the seed
State update function
The method that will be used to update the state of this PRNG
The method that will be used to update the state of this PRNG
input state
the next state after step
applications of PRNG.delta
the reduction operation (either XOR or XNOR)
Allow implementations to override the reset value, e.g., if some bits should be don't-cares.
the initial state of the PRNG
the initial state of the PRNG
the width of the PRNG
the width of the PRNG
Fibonacci Linear Feedback Shift Register (LFSR) generator.
A Fibonacci LFSR can be generated by defining a width and a set of tap points (corresponding to a polynomial). An optional initial seed and a reduction operation (XOR, the default, or XNOR) can be used to augment the generated hardware. The resulting hardware has support for a run-time programmable seed (via PRNGIO.seed) and conditional increment (via PRNGIO.increment).
If the user specifies a seed, then a compile-time check is added that they are not initializing the LFSR to a state which will cause it to lock up. If the user does not set a seed, then the least significant bit of the state will be set or reset based on the choice of reduction operator.
In the example below, a 4-bit Fibonacci LFSR is constructed. Tap points are defined as four and three (using LFSR convention of indexing from one). This results in the hardware configuration shown in the diagram.
If you require a maximal period Fibonacci LFSR of a specific width, you can use MaxPeriodFibonacciLFSR. If you only require a pseudorandom UInt you can use the FibonacciLFSR companion object.
https://en.wikipedia.org/wiki/Linear-feedback_shift_register#Fibonacci_LFSRs