Skip to question
ASIC.FYI
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
ASIC.FYI/Interview questions/Monitor a credit-based link

Q121·Free·Design Verification

Monitor a credit-based link

Difficulty
Medium
Topic
Verification Utilities
Language
SV
Interview prompt

Question

Monitor a producer-consumer link in which each transmission consumes one credit and each return restores one credit. Detect a transmission with no available credit and a return that would exceed the legal maximum.

Starting point

Question code

class CreditMonitor;
  function new(int initial_credits = 16, int max_credits = 16);
  function void on_tx();
  function void on_credit_return();
  function int get_current_credits();
  function int error_count();
endclass
Reviewed example

Trace one case

Input
initial_credits=2, max_credits=4; transmit three times; return five times
Expected output
credits 1,0, then underflow rejected at 0; four legal returns restore 4; fifth return rejected; error_count=2

Rejected underflow and overflow events leave state unchanged while legal sequential events preserve the configured maximum.

What to cover

Requirements

  1. Validate that zero is less than or equal to initial_credits and initial_credits is less than or equal to max_credits.
  2. Leave state unchanged when underflow or overflow is detected.
  3. Track any legal sequential interleaving of transmit and return events.
  4. Expose current credits and the cumulative error count.
  5. Treat max_credits as the legal capacity even when initial_credits begins below it.
Exact question handoffPractice Q121

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

Open in question bank →
Solution accessA Free account unlocks the complete reviewed solution.
Continue learning

Design Verification

  • Verification Utilities
  • Credit flow control
  • Protocol monitor
Interview preparation guide →
Continue practicing

Related questions

Q097 · Temporal ChecksMonitor ready/valid without SVA→Q049 · Protocol CheckingAPB Protocol Monitor without SVA→Q120 · Reference ModelsBuild a behavioral synchronous FIFO model→
ASIC.FYI · Learn silicon end to end.info@asic.fyi