A **Linear Feedback Shift Register (LFSR)** is a shift register whose input bit is a linear function of its previous state. The most common linear function used is the **Exclusive-OR (XOR)** operation. LFSRs are ubiquitous in digital systems due to their ability to generate pseudo-random sequences, high-speed counters, and error detection codes with minimal hardware.
An LFSR consists of a chain of Flip-Flops (the register) and a feedback network.
The standard form. The outputs of the tapped flip-flops are all XORed together in a single logic cloud, and the result is fed back to the input of the first flip-flop.
Downside: As the number of bits grows, the logic depth of the XOR chain increases, limiting the maximum clock frequency (propagation delay).
The output of the last flip-flop is fed back to the input of the first, but it is also XORed into specific intermediate stages along the chain.
Upside: The XOR gates are placed between flip-flops. This breaks the critical path, allowing each stage to resolve in parallel. It is preferred for high-speed hardware.
An LFSR with $n$ bits has $2^n$ possible states. However, the state of all zeros is a "lock-up" state (0 XOR 0 = 0, so it never changes). Therefore, the maximum number of unique states an LFSR can cycle through is **$2^n - 1$**.
To achieve this maximum length, the feedback taps must correspond to a **Primitive Polynomial** over the Galois field GF(2). If the taps are chosen incorrectly, the sequence will repeat much sooner, creating a shorter cycle.