Codiode

Coordinated Reset Sequence

HardVerilog / SystemVerilogBuildFree

The datapath shouldn't leave reset before the controller that drives it is ready. A reset sequencer releases the domains one after another, in a fixed order.

The module receives a global asynchronous active-low reset. When asserted, both Domain A and Domain B resets are driven low immediately. When the global reset is released, Domain A's reset is deasserted synchronously to its own clock. The sequencer then waits for Domain A to be fully out of reset, synchronizes this state into Domain B's clock domain, and waits exactly ten clock cycles of Domain B before synchronously releasing Domain B's reset.

Timing and Reset Rules:

  • Clocks clk_a and clk_b are positive-edge triggered and completely asynchronous to each other.
  • Global reset rst_ni is asynchronous and active-low.
  • rst_a_n must assert (go to 0) asynchronously the moment rst_ni goes to 0. It must deassert (go to 1) synchronously on the second positive edge of clk_a after rst_ni is released.
  • rst_b_n must assert asynchronously the moment rst_ni goes to 0.
  • To release rst_b_n, the rst_a_n signal must first be synchronized into the clk_b domain using a 2-stage flip-flop synchronizer.
  • Once the second stage of the clk_b synchronizer outputs a 1, a counter increments on each subsequent positive edge of clk_b.
  • Exactly on the 10th positive edge of clk_b where the synchronized rst_a_n is 1, rst_b_n transitions to 1.

Worked Trace:

  • Cycle 1: rst_ni=0 → rst_a_n=0, rst_b_n=0
  • Cycle 2: rst_ni=1, clk_a posedge → sync_a_1=1, rst_a_n=0
  • Cycle 3: clk_a posedge → rst_a_n=1 (Domain A released)
  • Cycle 4: clk_b posedge → sync_b_1=1 (sampling rst_a_n)
  • Cycle 5: clk_b posedge → sync_b_2=1 (synchronized into Domain B)
  • Cycle 6: clk_b posedge → count=1
  • Cycle 7: clk_b posedge → count=2
  • ...
  • Cycle 14: clk_b posedge → count=9
  • Cycle 15: clk_b posedge → count=10, rst_b_n=1 (Domain B released)
Signal Direction Width Description
clk_a input 1 Clock for Domain A; positive-edge triggered
clk_b input 1 Clock for Domain B; positive-edge triggered
rst_ni input 1 Global asynchronous active-low reset
rst_a_n output 1 Domain A reset; asserts asynchronously, deasserts synchronously to clk_a
rst_b_n output 1 Domain B reset; asserts asynchronously, deasserts synchronously to clk_b after 10-cycle delay

Constraints

  • Both rst_a_n and rst_b_n must go to 0 asynchronously when rst_ni is 0.
  • rst_a_n must be generated using a 2-stage synchronizer clocked by clk_a with its input tied to 1.
  • rst_a_n must be synchronized into the clk_b domain using a 2-stage synchronizer clocked by clk_b.
  • The 10-cycle delay in Domain B must be counted only when the 2nd stage of the clk_b synchronizer is 1.
  • The counter must not overflow; it must hold its value once rst_b_n is asserted.
  • Every flip-flop in the design must use rst_ni as an asynchronous active-low reset.

Topics

Clock Domain CrossingResetState Machine

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.

Free to solve. A Codiode account keeps your progress.

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.

Part of Clock Domain Crossing and Synchronization

Problem 4 of 36 in the Clock Domain Crossing and Synchronization track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.