Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Measure ready/valid handshake latency

Q051·Free·SystemVerilog

Measure ready/valid handshake latency

Difficulty
Medium
Topic
Temporal Checks
Language
SV
Interview prompt

Question

Track minimum, maximum, total, and average latency from the first valid sample of each transfer through its successful ready/valid handshake. Supply known 0/1 valid and ready samples. One instance observes at most 2^32 - 1 completed transfers, and each pending transfer has at most 2^32 - 1 stalled samples. These bounds keep individual counters and the 64-bit sum representable.

Candidate starting point

Implementation scaffold

class HandshakeLatency;
  local bit active;
  local int unsigned stalled_cycles;
  local int unsigned completed;
  local int unsigned min_delay;
  local int unsigned max_delay;
  local longint unsigned total_delay;

  function new();
    active = 0;
    stalled_cycles = 0;
    completed = 0;
    min_delay = 0;
    max_delay = 0;
    total_delay = 0;
  endfunction

  function void record_completion(int unsigned delay);
    // Implement here: record_completion.
  endfunction

  function void sample(bit valid, bit ready);
    // Implement here: sample.
  endfunction

  function real average_latency();
    // Implement here: average_latency.
  endfunction
  function int unsigned completed_count(); return completed; endfunction
  function int unsigned minimum_latency(); return min_delay; endfunction
  function int unsigned maximum_latency(); return max_delay; endfunction
  function longint unsigned total_latency(); return total_delay; endfunction
endclass
Reviewed example

Trace one case

Input
valid rises at cycle 4; ready first overlaps valid at cycle 7
Expected output
handshake_latency = 3 cycles

Latency is measured from the first pending-valid cycle through the accepting edge, without resetting while valid is stalled.

What to cover

Requirements

  1. Define a same-cycle valid-and-ready handshake as zero stalled cycles.
  2. Update statistics exactly once per successful transfer.
  3. Initialize minimum latency from the first completed transfer rather than from zero.
  4. Avoid division by zero and return a real-valued average.
  5. Do not add failed or incomplete transfers to the latency statistics.
Exact question handoffPractice Q051

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

Transfer Contracts

Review ready-valid, request-acknowledge, APB, and AHB transfer rules.

  • Temporal Checks
  • Ready-valid
  • Latency
  • Running statistics
Transfer Contracts →
Continue practicing

Related questions

Q140 · Temporal ChecksMonitor ready/valid without SVAMedium→Q1150 · Temporal ChecksCount successful ready/valid handshakesEasyP→Q1151 · Temporal ChecksCheck payload stability during ready/valid stallsMediumP→Q272 · Temporal ChecksCheck hold while stalledEasyP→Q381 · Temporal ChecksProcedural stall-stability checkerMediumP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi