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

Johnson Counter: Self-Correction for 2-State Lockup Cycle

HardLogic CircuitBuild

Uncorrected Johnson counters can become permanently trapped in invalid state cycles due to noise or power-up glitches. The most notorious trap is the 1010 state, which requires dedicated detection logic to force a safe recovery.

Design a self-correcting 4-bit Johnson counter. The circuit must follow the standard Johnson sequence, but if it enters the invalid 1010 state, it must synchronously clear to 0000 on the next clock edge. A synchronous load input is provided to inject specific states for testing.

Behavioral Specification: * When rst is 1: Q synchronously clears to 0000. * When rst is 0 and load is 1: Q synchronously loads D_in. * When rst is 0 and load is 0: * If Q equals 1010: Q synchronously clears to 0000. * For all other states: Q performs a standard Johnson shift where Q[3] receives ~Q[0], and Q[2:0] receives Q[3:1].

| Port | Direction | Width | Description | |------|-----------|-------|-------------| | clk | Input | 1-bit | Clock signal | | rst | Input | 1-bit | Synchronous reset (active high) | | load | Input | 1-bit | Synchronous load enable | | D_in | Input | 4-bit | Data input for state injection | | Q | Output | 4-bit | Counter state output |

Constraints

  • Implement the state register using D flip-flops.
  • Trigger all state transitions and corrections synchronously on the clock edge.
  • Detect the 1010 state using only combinational logic gates.
  • Do not use asynchronous resets to clear the 1010 state.

Topics

CountersState MachinesError Recovery

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