Linear Feedback Shift Register Calculator
LFSR calculator: step a linear feedback shift register — XOR the tap bits, shift right, insert the feedback bit — and see exactly how the next state forms.
Linear Feedback Shift Register Calculator
Background.
A linear feedback shift register is the cheapest pseudo-randomness hardware can buy: a row of bits that shifts one place each clock tick, with the vacated position filled by the XOR of a few chosen ‘tap’ bits. From a handful of gates comes a sequence that looks noise-like, repeats only after up to 2ⁿ−1 steps for an n-bit register with well-chosen taps, and can be reproduced exactly by anyone who knows the taps and the starting state.
That mix of chaos and reproducibility put LFSRs everywhere: CRC error-checking in Ethernet and ZIP files, scramblers and spreading codes in GPS, Bluetooth and mobile standards, built-in self-test pattern generators on chips, white-noise voices in classic sound hardware (the drum sounds of 8-bit consoles are LFSR noise), and stream ciphers — including, infamously, ones broken precisely because LFSRs are linear.
This page executes one step so you can watch the mechanism rather than take it on faith: give it the current register value, the tap mask (a bit set in the mask means that bit position feeds the XOR), and the register width, and it returns the feedback bit and the next state. In the right-shift (Galois-style output, Fibonacci-tap) convention used here, the tapped bits are XORed together, every bit moves one place toward the low end, the old low bit falls off, and the feedback enters at the top.
Single-stepping is deliberately the whole scope: it is how you debug a software LFSR against hardware, verify a textbook example, or trace a short cycle by hand. Choosing maximal-period tap sets, polynomial notation, and whole-sequence generation sit outside the page, as the scope note says — though the FAQs point at them.
What is linear feedback shift register calculator?
A linear feedback shift register (LFSR) is a register of n bits whose next state is produced by shifting all bits one position and inserting, at the vacated end, a feedback bit computed as the XOR of selected ‘tap’ positions of the current state. Because XOR is linear over the two-element field, the whole state sequence is linear algebra in disguise — predictable to anyone with the recipe, statistically noise-like to anyone without it. With taps chosen from a primitive polynomial, an n-bit LFSR visits all 2ⁿ−1 nonzero states before repeating; the all-zero state is a fixed point it must avoid.
How to use this calculator.
- Enter the current register value as an unsigned integer — 11 means bit pattern 1011 in a 4-bit register.
- Enter the tap mask, also as an integer: each set bit marks a position that feeds the XOR (mask 3 = 0011 taps bits 0 and 1).
- Set the register width (2–16 bits here); it defines which position the feedback bit enters (the top bit) and where bits fall off (the bottom).
- Read the feedback bit and next state; feed the next state back in repeatedly to trace a cycle by hand and measure its period.
- Avoid the all-zero register with XOR feedback — it maps to itself forever — and if your cycle is short, your mask is not a maximal-period tap set for that width (try the classic ones: 0b1100 for 4 bits, 0b10110100 for 8).
The formula.
One step is three operations. Feedback: AND the register with the tap mask to isolate the tapped bits, then XOR them together — equivalently, the parity of (register AND mask) — yielding one bit. Shift: move the register right one place, discarding bit 0. Insert: place the feedback bit at position n−1. Linearity is the load-bearing property: XOR is addition modulo 2, so each state is a linear function of the previous one, and the whole evolution is multiplication by a fixed matrix over GF(2). That is why the tap mask corresponds to a polynomial — the register's characteristic polynomial — and why period analysis reduces to algebra: the sequence attains the maximal period 2ⁿ−1 exactly when that polynomial is primitive. The same linearity is the cryptographic weakness: observing 2n output bits lets the Berlekamp–Massey algorithm solve for the taps and state, which is why raw LFSRs scramble and self-test but never encrypt on their own. The engine performs the mask, parity, shift, and insert on exact integers, with range checks on width and inputs.
A worked example.
Take a 4-bit register holding 11 — bit pattern 1011 — with tap mask 3 (0011: taps at bit positions 0 and 1). Feedback first: the tapped bits are bit 0 = 1 and bit 1 = 1, and their XOR is 1 ⊕ 1 = 0 — the feedback bit for this step. Now shift right: 1011 loses its low bit (the 1 at position 0 falls off) and slides to 0101. Insert the feedback at the top — position 3 — which here writes a 0 onto a bit that is already 0, leaving 0101 = 5. Next state: 5, feedback bit: 0, matching the engine outputs exactly. Run the mechanism one more tick to feel the rhythm: from 0101, taps read bit 0 = 1, bit 1 = 0, feedback 1 ⊕ 0 = 1; shift gives 0010, inserting 1 at the top makes 1010 = 10. Continue and the walk 11 → 5 → 10 → … unfolds — with mask 3 it closes after fewer than the maximal 15 states, which is the hands-on way to discover that 0011 is not a maximal tap set for width 4, while the classic 1100 (taps 3 and 2) visits all fifteen nonzero states before repeating.
Frequently asked questions.
What do the taps do, and how does the mask encode them?
Why does a well-chosen LFSR have period 2ⁿ−1 and not 2ⁿ?
Where are LFSRs used in practice?
Are LFSRs cryptographically secure?
What is the difference between Fibonacci and Galois LFSR forms?
References& sources.
- [1]OpenStax, Rice University. College Algebra 2e, 2021. Algebra and function chapters. Retrieved 2026-08-06. independence: primary; access: open.
- [2]OpenStax, Rice University. Precalculus 2e, 2021. Trigonometry and analytic geometry chapters. Retrieved 2026-08-06. independence: secondary-check; access: open.
- [3]NIST/SEMATECH. e-Handbook of Statistical Methods, 2012. Chapter 1.3 and Chapter 4. Retrieved 2026-08-06. independence: primary; access: open.
How this page was produced
- Published by
- Quanta Calculator
- Primary sources
- 3 cited below
- Method
- feedback = XOR of selected tap bits; shift right and insert feedback at the high bit
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled