Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Cross a burst count with a Gray counter

Hardware interview practice

Cross a burst count with a Gray counter

MediumCDC & RDCSystemVerilog

A fast source may produce several events between destination edges. The destination needs the modulo-16 event delta, not one pulse per source event. Design the dual-clock SystemVerilog counter crossing.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

input logic src_clk, src_rst_n, src_event;
input logic dst_clk, dst_rst_n;
output logic [3:0] dst_delta;
output logic [3:0] dst_total;
Reviewed example

Work through one case

Input
The prior settled destination sample is binary 3, the new synchronized Gray sample decodes to 6, and dst_total is 9.
Expected output
dst_delta=3 and the registered dst_total becomes 12 modulo 16.

Four-bit subtraction computes 6-3=3, and the destination accumulates that same delta on the sampling edge.

What to cover

Requirements

  1. Increment a 4-bit source binary count on each src_event and continuously derive its Gray-code value.
  2. Synchronize each Gray bit through two destination flip-flops, convert the synchronized Gray value back to binary, and compute modulo-16 delta from the prior destination sample.
  3. Accumulate dst_total modulo 16 and present dst_delta for each destination cycle; a stable source count yields delta zero after synchronization settles.
  4. Assume fewer than 8 source events occur between settled destination samples and constrain physical Gray-bus skew below one source period; both resets are asserted together and clear all state.
Continue practicing

Related questions

CDC & RDCCross a long-lived mode bit→Clock Domain CrossingEight-entry asynchronous FIFO→CDC and ResetOne-outstanding-event CDC handshake→
asic.fyi · Learn silicon end to end.info@asic.fyi