Free digital logic calculator

LFSR Calculator

Generate binary sequences using a linear feedback shift register. Configure the register width, starting seed, feedback taps and number of clock steps. Inspect each state, find the cycle length, and check whether the sequence reaches the maximum possible period.

Linear feedback shift register calculator

This calculator uses a right-shifting Fibonacci-style LFSR. Tap positions are numbered from the least significant bit (LSB), starting at position 1.

Comma-separated positions counted from the LSB.
Maximum output length: 4,096 bits.
An XOR-based LFSR must use a non-zero seed. An all-zero state remains zero indefinitely and cannot produce a useful sequence.

Generated output stream

—

Sequence summary

Initial state 0001
Final state —
Detected cycle length —
Maximum possible period 15
Maximum period reached? —
Ones in one full cycle —

Final register state

State transition table

Each row shows the current state, emitted output bit, feedback bit and next state.

Step Current state Output Feedback Next state

What is a linear feedback shift register?

A linear feedback shift register (LFSR) is a sequential digital circuit or software model that stores a binary state and updates it at each clock step. Selected state bits, called taps, are combined with XOR to calculate a feedback bit. The register shifts, and the feedback bit enters the new state.

LFSRs are used in digital testing, communications, scrambling, error-detection systems and pseudorandom sequence generation. Their behavior is deterministic: the same seed, taps and update convention always produce the same sequence.

How this calculator updates the register

Let \(S\) be the current \(n\)-bit state. The calculator uses the following right-shifting recurrence:

feedback = XOR of all selected tap bits

nextState = (state >> 1) OR (feedback << (n - 1))

Tap position 1 refers to the least significant bit, and tap position \(n\) refers to the most significant bit. The output bit can be selected separately. The feedback tap convention and shift direction must match the implementation you want to reproduce.

How to use the LFSR calculator

  1. Choose the register width between 2 and 16 bits.
  2. Enter a seed using exactly the selected number of binary bits.
  3. Enter one or more feedback tap positions separated by commas.
  4. Choose the output bit and the number of steps to generate.
  5. Click Run LFSR to generate the sequence.
  6. Review the state table, detected period and maximal-length result.

Maximum LFSR period

An \(n\)-bit register has \(2^n\) possible states. In an ordinary XOR-feedback LFSR, the all-zero state is a lockup state, so the longest possible non-zero cycle has:

Maximum period = 2n − 1

A primitive feedback polynomial can produce a maximal-length sequence that visits every non-zero state before repeating. Other tap selections may generate shorter cycles. The calculator measures the cycle for your selected seed and taps rather than assuming that every tap combination is maximal.

Example maximal-length tap configurations

These examples use tap positions counted from the LSB and the right-shifting recurrence implemented above. They are useful starting points for testing the calculator.

Width Tap positions Maximum period Load
21,23
31,37
41,415
52,531
61,663
71,7127
81,2,3,4,8255

Tap conventions vary between diagrams, polynomial notation and hardware implementations. Confirm the recurrence before using a tap list from another source.

Frequently asked questions

What does LFSR stand for?

LFSR stands for linear feedback shift register. It is a register that shifts its state and calculates new bits using a linear feedback function, commonly XOR.

Why must the seed be non-zero?

In an XOR-feedback LFSR, an all-zero state produces a feedback bit of zero. Shifting it therefore leaves the register at zero forever.

What are feedback taps?

Taps are selected register positions whose bits are combined to calculate the next feedback bit. Different tap configurations can produce different sequence periods and state transitions.

What is a maximal-length LFSR?

It is an LFSR that visits every non-zero state before repeating. For an \(n\)-bit XOR LFSR, its period is \(2^n-1\). Achieving that period requires an appropriate feedback polynomial and a non-zero seed.

Does an LFSR generate true random numbers?

No. LFSR output is deterministic and repeatable, not cryptographically secure randomness. Do not use a basic LFSR as a cryptographic key generator, password generator or substitute for a cryptographically secure random number generator.

Why does my LFSR produce a different sequence?

Implementations can differ in shift direction, bit numbering, tap interpretation, output bit and whether feedback is calculated before or after shifting. Make sure all these conventions match.

Related binary tools