Hardware interview practice
Closed-loop pulse synchronizer
A one-cycle command pulse must cross unrelated clocks without loss, and the source may wait while one command is in flight. Implement a toggle-and-acknowledge synchronizer with source busy.
Starting point
Question code
input logic src_clk, src_rst_n, src_pulse;
output logic src_busy;
input logic dst_clk, dst_rst_n;
output logic dst_pulse;Reviewed example
Work through one case
Input
One src_pulse while src_busy=0; destination clocks at an unrelated rateExpected output
Exactly one dst_pulse; src_busy clears only after acknowledgement returnsThe toggle persists across arbitrary phase alignment, and busy prevents a second event from overwriting it.
What to cover
Requirements
- When src_pulse is sampled while src_busy is 0, toggle a source request bit; ignore or flag any src_pulse sampled while busy is 1.
- Synchronize the request through two destination flops and emit dst_pulse for exactly one destination cycle when the synchronized toggle changes.
- Return the observed toggle through a two-flop acknowledgement synchronizer; src_busy is 1 while request and synchronized acknowledgement differ.
- Both active-low resets are asserted together for at least two cycles of both clocks and initialize request, acknowledgement, history, busy, and dst_pulse to zero.
