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

4-Bit LFSR Pseudo-Random Counter

HardLogic CircuitBuild

Hardware security modules, test pattern generators, and communication scramblers rely on pseudo-random bit sequences. The Linear Feedback Shift Register (LFSR) generates these sequences using specific feedback polynomials to guarantee maximal length without repeating prematurely.

Implement a 4-bit LFSR using the primitive polynomial x^4 + x + 1. The circuit must maintain a 4-bit output bus Q. At each rising edge of clk, the register shifts right: Q[2] receives Q[3], Q[1] receives Q[2], and Q[0] receives Q[1]. The new bit entering Q[3] must be the XOR of the current Q[3] and Q[0] taps.

Choosing incorrect taps, such as Q[3] and Q[2], produces a non-maximal-length sequence. The specified primitive polynomial guarantees a full 15-cycle period before repeating.

| rst | clk | Q (Current) | Q (Next) | |-------|-------|---------------|------------| | 1 | X | X | 1 | | 0 | ↑ | 1 | 8 | | 0 | ↑ | 8 | 12 | | 0 | ↑ | 12 | 14 | | 0 | ↑ | 14 | 15 | | 0 | ↑ | 15 | 7 |

Constraints

  • Use standard D flip-flops for the state register.
  • Implement exactly one XOR gate for the feedback path.
  • Shift the data linearly from Q[3] down to Q[0].
  • Implement an asynchronous active-high rst signal that forces Q to 1 (binary 0001).

Topics

FeedbackCountersLFSRPseudo-Random

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