CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

LFSR: Self-Correction for All-Zeros Lockup

MediumLogic CircuitBuild

Linear Feedback Shift Registers (LFSRs) generate pseudo-random sequences for cryptography, bit-error-rate testing, and memory built-in self-test (BIST). A standard XOR-based LFSR contains a critical flaw: if the state ever becomes all zeros, the feedback remains zero and the circuit locks up permanently.

Construct a 4-bit LFSR with active lockup correction. The circuit evaluates the current state of Q3, Q2, Q1, and Q0 and shifts right on each rising edge of clk.

  • Q2 receives Q3
  • Q1 receives Q2
  • Q0 receives Q1
  • Q3 receives the feedback: Q1 XOR Q0

To prevent lockup, monitor the current state. If all four bits are 0, override the normal feedback to force Q3 to 1 on the next clock edge. The circuit will initialize to 0000 and must immediately escape to 1000 on the first rising clock edge, continuing through the standard 15-state pseudo-random sequence.

Constraints

  • Use D-type flip-flops for the state register.
  • Use exactly one 4-input NOR gate to detect the all-zeros state.
  • Combine the NOR gate output with the XOR feedback to drive the input of the Q3 flip-flop.
  • Do not use asynchronous preset or clear pins to escape the zero state.

Topics

CountersState MachinesLFSR

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

This problem is part of Codiode Pro. The statement above is free to read.

Sign in to solveSee what Pro unlocks

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Related problems

  • 3-bit Ripple Counter from Toggle Flip-FlopsEasy
  • D Latch from a 2:1 MUXEasy
  • 2-bit Ring CounterEasy
  • T Flip-Flop from a D Flip-FlopEasy
  • Handshake Deadlock Due to Early ResetHard
  • Reconvergence of Individually Synchronized BitsHard
  • Debug: Asynchronous Clear GlitchHard
  • Clock Gate Enable Crossing DomainsHard

Browse all problems · Learning tracks