Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Model credit-based flow control

Hardware interview practice

Model credit-based flow control

MediumReference ModelsPYTHON

Implement a small reference model for a transmitter that may send only when at least one credit is available. Sending consumes one credit and asynchronous returns replenish credits.

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 →
Reviewed example

Work through one case

Input
capacity=2, initial=2; send(), send(), send(), return_credits(1)
Expected output
credits: 1,0; third send raises underflow and stays 0; return restores credits to 1

The rejected send never makes the count negative, and every successful transition preserves 0 <= credits <= 2.

What to cover

Requirements

  1. Reject a send at zero credits without allowing the count to become negative.
  2. Reject negative credit returns and define whether returns may exceed the configured capacity.
  3. Expose the current count for scoreboard diagnostics.
  4. Maintain the invariant 0 <= credits <= capacity after every successful operation.
asic.fyi · Learn silicon end to end.info@asic.fyi