TLDR: Generating Pseudorandom Numbers with LFSR
Date: 2022-02-21 Source: https://arpitbhayani.me/blogs/pseudorandom-number-generation-lfsr
Overview
Explore LFSRs, a simple & efficient pseudorandom number generator widely used in microcontrollers. Learn how they work with code examples. A few essays back, we saw how pseudorandom numbers are generated using Cellular Automaton - Rule 30.
Key Points
- filled with the output bit forming a circular shift register
- filled with zero, like a pure right shift operation of a programming language
- filled with a result of some boolean logic on the latches
- A simple 4-bit LFSR: An LFSR has 3 configurable parameters We build a simple 4-bit LFSR with a seed value of 0b1001 and tap position of 1.
- LFSR Bits to Number: Although LFSR generates pseudorandom bits, generating random numbers is fairly simple using it.
- Scrambling using LFSR: LFSRs are computationally efficient and deterministic for a seed value, i.e., they generate the same set of numbers in the same order for a seed value, and here’s how they find their application in scrambling and unscrambling a stream of bytes.