Advanced

Linear Feedback Shift Register (LFSR) Calculator

Simulate a Fibonacci LFSR using a known maximal-length primitive polynomial for 2–8 stages. Enter the initial state (any non-zero n-bit value) and number of steps to see the output bit sequence and the full period 2ⁿ − 1.

LFSR stages (n)

Non-zero n-bit integer, e.g. 1 to 2ⁿ − 1

bits

Maximal-length period
15

2ⁿ − 1 output bits before the sequence repeats

Stages (n)
4
Tap polynomial
x4 + x1 + 1
Ones in output
9 / 16
Zeros in output
7 / 16

Output bits: 1 0 0 0 1 0 0 1 1 0 1 0 1 1 1 1

100010011010First 12 output bits — tall bar = 1, sliver = 0
Step by step
  1. 1

    2ⁿ where n = 4

    2⁴ = 16
  2. 2

    Period = 2ⁿ − 1

    16 − 1 = 15
    The all-zero state is excluded, giving exactly 2ⁿ − 1 unique non-zero states.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

An n-stage LFSR XORs selected bit positions (taps) each clock cycle to form a feedback bit, right-shifts the register, and outputs one bit. With a primitive polynomial the sequence has period 2ⁿ − 1. The all-zero state is forbidden; any other initial state from 1 to 2ⁿ − 1 generates the full-length pseudo-random sequence.

Formula
feedback = XOR of tapped bits • next_state = (state >> 1) | (feedback << (n−1)) • output = state & 1
How this is calculated

A linear feedback shift register (LFSR) is an n-bit shift register whose new input bit is the XOR of certain tapped positions. Each clock cycle the register shifts one position right, the least-significant bit is emitted as output, and the feedback bit enters at the most-significant position. With tap positions chosen from a primitive polynomial over GF(2) the register visits all 2ⁿ − 1 non-zero states before repeating, generating a pseudo-random bit sequence (PRBS) of maximal length.

This calculator uses the Fibonacci (external XOR) form. Tap positions for each stage count are from standard tables (Xilinx XAPP052, converted to 0-indexed from LSB): n=2 [0,1], n=3 [0,1], n=4 [0,1], n=5 [0,2], n=6 [0,1], n=7 [0,1], n=8 [0,2,3,4]. The feedback bit is XOR of all tapped positions and the new state is formed by a right shift.

The all-zero state is a degenerate fixed point — XOR of all zeros is always zero, trapping the register. Any initial state from 1 to 2ⁿ − 1 produces the full maximal-length sequence. All non-zero initial states generate the same set of bits, merely starting at different points in the same cycle. LFSRs are widely used in hardware test-pattern generation, CRC computation, and spread-spectrum communications, though their linear structure makes them unsuitable for cryptographic use without nonlinear layers.

Frequently asked questions

A primitive polynomial over GF(2) is irreducible (cannot be factored) and its roots have multiplicative order 2ⁿ − 1 in GF(2ⁿ). For an LFSR this means the register visits every non-zero state exactly once before repeating — the maximum possible period. Not all irreducible polynomials over GF(2) are primitive, and not all tap combinations yield a maximal-length sequence.

No — LFSR sequences are entirely deterministic and repeat with period 2ⁿ − 1. They are "pseudo-random" in that they pass many statistical tests (balanced ones and zeros, even run-length distributions), but are trivially predictable after observing 2n bits using the Berlekamp–Massey algorithm. Modern stream ciphers combine multiple LFSRs or nonlinear filtering to break this linear predictability.

All non-zero initial states produce the same set of output bits — they are cyclic shifts of one another, starting at different points in the maximal-length cycle. Changing the initial state shifts the starting position within the period but does not change the period, the set of states visited, or the statistical properties of the sequence.

Also known as

lfsr sequence generator
pseudo random bit sequence
maximal length sequence calculator
prbs generator online
primitive polynomial shift register
lfsr output bits
hardware prng calculator

APA

TG we-Calculate Editorial Team. (2026). Linear Feedback Shift Register (LFSR) Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/linear-feedback-shift-register-calculator

Chicago

TG we-Calculate Editorial Team. "Linear Feedback Shift Register (LFSR) Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/linear-feedback-shift-register-calculator.

IEEE

TG we-Calculate Editorial Team, "Linear Feedback Shift Register (LFSR) Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/linear-feedback-shift-register-calculator

BibTeX

@misc{wecalculate_linear_feedback_shift_register_calculator, title = {Linear Feedback Shift Register (LFSR) Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/linear-feedback-shift-register-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?