Coordinated Reset Sequence
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_aandclk_bare positive-edge triggered and completely asynchronous to each other. - Global reset
rst_niis asynchronous and active-low. rst_a_nmust assert (go to 0) asynchronously the momentrst_nigoes to 0. It must deassert (go to 1) synchronously on the second positive edge ofclk_aafterrst_niis released.rst_b_nmust assert asynchronously the momentrst_nigoes to 0.- To release
rst_b_n, therst_a_nsignal must first be synchronized into theclk_bdomain using a 2-stage flip-flop synchronizer. - Once the second stage of the
clk_bsynchronizer outputs a 1, a counter increments on each subsequent positive edge ofclk_b. - Exactly on the 10th positive edge of
clk_bwhere the synchronizedrst_a_nis 1,rst_b_ntransitions to 1.
Worked Trace:
- Cycle 1:
rst_ni=0→rst_a_n=0,rst_b_n=0 - Cycle 2:
rst_ni=1,clk_aposedge →sync_a_1=1,rst_a_n=0 - Cycle 3:
clk_aposedge →rst_a_n=1(Domain A released) - Cycle 4:
clk_bposedge →sync_b_1=1(samplingrst_a_n) - Cycle 5:
clk_bposedge →sync_b_2=1(synchronized into Domain B) - Cycle 6:
clk_bposedge →count=1 - Cycle 7:
clk_bposedge →count=2 - ...
- Cycle 14:
clk_bposedge →count=9 - Cycle 15:
clk_bposedge →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_nandrst_b_nmust go to 0 asynchronously whenrst_niis 0. rst_a_nmust be generated using a 2-stage synchronizer clocked byclk_awith its input tied to 1.rst_a_nmust be synchronized into theclk_bdomain using a 2-stage synchronizer clocked byclk_b.- The 10-cycle delay in Domain B must be counted only when the 2nd stage of the
clk_bsynchronizer is 1. - The counter must not overflow; it must hold its value once
rst_b_nis asserted. - Every flip-flop in the design must use
rst_nias an asynchronous active-low reset.
Topics
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