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

Programmable Modulus Counter: Comparator-Based Reset

HardLogic CircuitBuild

Frequency synthesizers, hardware timers, and test equipment require dividers that can change their modulus at runtime. A programmable modulus counter achieves this by comparing its current state against a target value provided by a control bus.

The circuit receives a clock clk, a synchronous reset rst, and a 3-bit target value PROG[2:0]. It outputs the current 3-bit count Q[2:0]. The counter increments by 1 on each rising edge of clk. A 3-bit equality comparator continuously checks if Q[2:0] equals PROG[2:0]. When a match occurs, the comparator output must force the counter to synchronously reset to 0 on the next clock edge. A high rst signal also forces Q[2:0] to 0 on the next clock edge.

| rst | Q == PROG | Next Q | |-------|-------------|----------| | 1 | X | 0 | | 0 | 1 | 0 | | 0 | 0 | Q + 1 |

For example, if PROG[2:0] is set to 3 (binary 011), the counter sequence will be 0, 1, 2, 3, 0, 1, 2, 3.

Constraints

  • Implement the counter state using D flip-flops.
  • Build the 3-bit equality comparator explicitly using XNOR and AND gates.
  • The reset triggered by the comparator must be fully synchronous.

Topics

Synchronous ResetCountersComparators

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