Hardware interview practice
One-outstanding-event CDC handshake
A source clock sends events to an unrelated destination clock. At most one event may be in flight. Design synthesizable SystemVerilog for a request/acknowledge event crossing.
Starting point
Question code
input logic src_clk, src_rst_n, src_valid;
output logic src_ready;
input logic dst_clk, dst_rst_n;
output logic dst_pulse;Reviewed example
Work through one case
Input
Accept one source event while dst_clk runs four times slower than src_clk.Expected output
The destination produces exactly one dst_pulse.The request toggle persists until its synchronized acknowledgement returns, so the slower domain cannot miss or duplicate the event.
What to cover
Requirements
- Accept an event only on src_valid && src_ready; while src_valid&&!src_ready the source must keep src_valid asserted, and the crossing must hold its request or toggle until acknowledgement returns.
- Generate exactly one destination-clock pulse for each accepted event and accept no second event while one is pending.
- Every signal crossing a clock boundary must pass through two destination-domain flip-flops before use.
- Both resets must be asserted together for at least two edges of each clock; during reset, clear the handshake and drive src_ready=0 and dst_pulse=0, then recover without a phantom event.
