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

LFSR as a Counter: 4-Bit Maximal-Length Sequence

HardLogic CircuitBuild

Pseudo-random bit sequences (PRBS) and cyclic redundancy checks (CRC) rely on linear feedback shift registers to generate maximal-length sequences with minimal hardware. The 4-bit LFSR acts as a pseudo-random address counter that cycles through 15 unique non-zero states.

Implement a 4-bit LFSR using the primitive polynomial x^4 + x + 1. The circuit maintains a 4-bit state represented by outputs Q3 (MSB), Q2, Q1, and Q0 (LSB).

On every rising clock edge, the register shifts right. The feedback is generated by XORing specific taps: * Q2 receives the value of Q3. * Q1 receives the value of Q2. * Q0 receives the value of Q1. * Q3 receives the feedback value: Q3 XOR Q0.

When rst is 1, the state must synchronously reset to 0001 (Q3=0, Q2=0, Q1=0, Q0=1) to prevent initialization into the all-zeros lockup state.

Constraints

  • Use exactly four D flip-flops.
  • Use only XOR gates for the feedback path.
  • The rst signal must act synchronously on the clock edge.
  • Do not implement self-correction logic for the 0000 lockup state.

Topics

Sequential LogicCountersLFSR

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