Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Check per-channel link credits

Hardware interview practice

Check per-channel link credits

HardComputer ArchitectureSystemVerilog

A two-channel link starts with four transmit credits per channel. Sending consumes one credit; a returned credit restores one. Write a SystemVerilog checker for credit accounting and protocol errors.

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 clk, rst_n;
input logic tx_fire, tx_ch;
input logic cr_valid, cr_ch;
output logic error;
Reviewed example

Work through one case

Input
Channel 1 has two credits and observes tx_fire and cr_valid for channel 1 on the same edge.
Expected output
Channel 1 remains at two credits and error remains clear.

At a non-boundary count, the legal send consumes exactly the credit restored by the same-channel return.

What to cover

Requirements

  1. Track an integer available[2], initialized to four for each channel on reset and constrained to 0..4.
  2. A tx_fire consumes one from tx_ch; if its pre-edge count is zero, leave the count unchanged and set sticky error.
  3. A return without a same-channel send adds one; if its pre-edge count is four, leave that count unchanged and set sticky error.
  4. For a same-channel send and return: counts 1..3 stay unchanged; at 0 flag the send and apply the return to reach 1; at 4 flag the return and apply the send to reach 3.
Continue practicing

Related questions

Computer ArchitectureControl a link with return credits→Computer ArchitectureForward bytes from a small pending-write queue→Computer ArchitectureMatch hit-under-miss responses by transaction ID→
asic.fyi · Learn silicon end to end.info@asic.fyi