Skip to main content
Skip to calculator
Advertisement

Last updated: August 1, 2026

LFSR Calculator

Quick Answer

This LFSR calculator validates a binary seed and tap list, simulates XOR feedback shifts, returns the generated output bits, every visited state, the detected period, and whether the sequence is maximal-length.

An LFSR updates a binary register by XORing tapped bits, shifting the register, and emitting a repeatable output bit stream.

Helpful
Not helpful
Save as image
Share
Embed
Cite
Write feedback

Formula

feedbackBit = tap1 ⊕ tap2 ⊕ ... ⊕ tapk, nextState = feedbackBit followed by the shifted register

Where:

  • b_i=Current register bits(bit)
  • f=Feedback bit from XOR taps(bit)
  • S_{next}=Next register state after shifting(bit string)
  • t_i=Tap positions used in the XOR(position)
LFSR IllustrationA four-bit shift register with XOR taps feeding the leftmost bit.Linear Feedback Shift RegisterXOR selected taps, shift the register, emit the rightmost bitb₁0/1b₂0/1b₃0/1b₄0/1Feedback Rulefeedback = tap₁ ⊕ tap₂ ⊕ ... ⊕ tapₖ
The taps decide which bits are XORed to form the new input bit, while the register shifts right and emits one output bit per step.

Worked Examples

3-bit maximal sequence

Start from 101 with taps at positions 3 and 1 for 7 steps.

  1. 1Use bits 3 and 1 to compute the feedback XOR.
  2. 2Shift right and insert the feedback bit on the left each step.
  3. 3Collect the output bit that leaves on the right.
  4. 4The seed returns after 7 steps, so the period is 7.
Final Answer: Generated bits 1010011, period 7 bit string

4-bit register

Use a 4-bit seed with taps that produce a longer cycle.

  1. 1Compute each feedback bit from the tapped positions.
  2. 2Record the state list after each shift.
  3. 3Compare the period with 2^4 - 1 = 15.
  4. 4The output stays deterministic for the same seed and taps.
Final Answer: A repeatable 8-bit prefix of a 15-state cycle bit string

Short custom run

Simulate only 5 steps to inspect intermediate states.

  1. 1Normalize the tap positions.
  2. 2Perform five XOR-and-shift updates.
  3. 3Read the output bit stream.
  4. 4Inspect the final register state for the next run.
Final Answer: Five output bits and six total states including the seed bit string

Tap validation

See how the calculator rejects impossible tap positions.

  1. 1Count seed length first.
  2. 2Compare each tap against the valid range.
  3. 3Reject taps outside the register width.
  4. 4Request a new valid tap list.
Final Answer: Validation error: taps must be inside the register length bit string

Introduction

An LFSR, or linear feedback shift register, is a compact deterministic generator that updates a binary register by XORing selected taps and shifting the bits. It appears in testing, coding theory, stream ciphers, and pseudo-random sequence design.

What an LFSR Is

An LFSR stores a binary state and updates it through feedback and shifting.

  • Each step produces one output bit

  • Tap positions define the feedback rule

  • The same seed always gives the same sequence

  • The all-zero state locks permanently

How Tap Logic Works

Selected register bits are XORed to create the next leftmost bit.

  • Tap positions are counted from the left

  • XOR returns 1 when an odd number of tapped bits are 1

  • The rightmost bit becomes the output bit

  • Every update shifts the remaining bits right

Understanding the Period

The period is the number of shifts required before the seed appears again.

  • Maximum period is 2^n - 1 for n bits

  • Only non-zero states participate in the main cycle

  • Tap choice controls the cycle length

  • Short periods indicate a weaker sequence

How to Use the Calculator

Choose a seed, list the taps, and decide how many steps to simulate.

  • Enter a binary seed

  • List taps such as 3,1

  • Set the step count

  • Read generated bits and visited states

Common Applications

LFSRs are useful anywhere repeatable bit patterns matter.

  • Built-in self-test patterns

  • Scramblers and descramblers

  • Toy stream-cipher demonstrations

  • Pseudo-random test data

Validation Rules

Good input is essential because some states or tap sets are mathematically invalid.

  • Seed must contain only 0 and 1

  • Seed cannot be all zeros

  • Taps must be unique integers

  • Steps must be a positive whole number

Reading the Results

The calculator reports the output stream, every visited state, and whether the cycle is maximal-length.

  • Generated bits help compare prefixes

  • States show internal transitions

  • Period reveals cycle efficiency

  • Final state can seed the next batch

FAQs

Why is the all-zero seed rejected?

In a standard XOR-feedback LFSR, the all-zero state feeds back to itself forever and produces no useful sequence.

How are taps numbered?

This calculator counts taps from the leftmost bit starting at 1.

What does maximal length mean?

A maximal-length LFSR visits every non-zero n-bit state before repeating, so its period is 2^n - 1.

Can two different tap sets give different periods?

Yes. The tap polynomial controls the cycle structure, so different taps can shorten or lengthen the period.

What bit becomes the output?

The rightmost bit shifted out during each update is appended to the generated bit stream.

Can I use spaces between taps?

Yes. Commas, spaces, and semicolons are all accepted as tap separators.

Is an LFSR truly random?

No. It is deterministic and repeatable, which is useful for engineering tests but not equivalent to true randomness.