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

Frequency Comparator

HardLogic CircuitBuild

Fault-tolerant systems must continuously monitor primary oscillators to detect if a clock has failed or drifted out of specification. A frequency comparator measures two asynchronous clock domains against each other to determine which is running faster.

The circuit receives two independent clocks, clk_a and clk_b, and an active-high reset rst. When rst is deasserted, the circuit must count the edges of both clocks over a fixed measurement window. The window is defined by exactly 4 cycles of clk_a.

Once the 4-cycle window completes, the circuit must assert done to 1. If clk_a had more cycles than clk_b during this period, assert a_faster to 1 and b_faster to 0. If clk_b had more cycles, assert b_faster to 1 and a_faster to 0. If the counts are equal, both are 0. The outputs must remain stable until the next reset.

Constraints

  • Implement independent edge counters in both the clk_a and clk_b domains.
  • Use a synchronization protocol to cross domain boundaries for the comparison.
  • Do not use combinational logic to directly compare the raw clock signals.
  • All outputs must be glitch-free and registered.

Topics

SynchronizationCountersClocking

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