H3.6 Grant Retention Under Backpressure

MediumFixVerilator · serverReview the topic

Fix an arbiter checker that forgets the retained client, so it flags a correct arbiter during stalls.

Hardware context: Round-robin arbiter with accepted-grant priority updates. Retain an offered arbitration winner through downstream backpressure.

An arbiter checker flagged a correct design. Every false error came during a stall, just after another client raised its request. The arbiter was right to keep its offer. The checker was wrong.

The class grant_retention_checker watches one round-robin arbiter that keeps a stalled offer. After each edge, sample() gets the requests, the offer, the receipts, and the arbiter state on both sides. The checker predicts every value from its own model and records each mismatch. report() returns a one-line summary.

The tests run it on a correct arbiter and on eight faulty ones. It must stay silent on the correct one and report the exact mismatches on the others. The tests check report() after every edge.

Find the bug in the checker and fix it. The rules in brief: a stalled offer is kept until it transfers, is withdrawn or is reset. The full rules are in the specification.

Signals in the Timeline

SignalWidthRole
clients4input of each check
initial_priority4input of each check
hardware_fault4input of each check
Full specification
The class (keep these names and types)
class grant_retention_checker;
  function new(input int clients, initial_priority);
  function void sample(input int cycle, input bit reset, ready, input bit [7:0] requests,
                       input int pre_pointer, input bit pre_locked, input bit [7:0] pre_owner,
                       input bit valid, input bit [7:0] grant, winner,
                       input bit accepted, input bit [7:0] accepted_client, input bit canceled,
                       input int post_pointer, input bit post_locked, input bit [7:0] post_owner);
  function string report();
endclass
RuleWhat the arbiter does
ClientsN is the number of clients. Clients are 0 to N - 1. Request bits at N and above are ignored.
Fresh choiceWith no retained client, scan the clients in circular order, starting at priority_state. The first one that requests is offered.
Offervalid = 1, winner = the client and grant = its one-hot bit. With no offer, valid = 0, winner = 0xff and grant = 0.
TransferA transfer happens at an edge with reset = 0, valid = 1 and ready = 1. priority_state then becomes winner + 1, wrapping to 0 after N - 1.
StallAt an edge with valid = 1 and ready = 0, the offered client becomes the retained client. priority_state does not move.
Retained offerWhile the retained client keeps requesting, it stays offered. Requests from other clients cannot take its place.
WithdrawalIf the retained client drops its request, the offer is idle for that whole cycle. This holds even when others request and ready = 1.
After a withdrawalAt that edge canceled = 1 and the retained client is released. priority_state does not move. A fresh choice starts in the next cycle.
Resetreset is synchronous and active high. While it is 1 the offer is idle. Its edge accepts nothing, sets priority_state to 0 and releases the retained client.
Receiptsaccepted and accepted_client describe the transfer at the last edge. accepted_client is 0xff when there was none. Reset clears both, and canceled stays 0.
Lock registerslocked and locked_client show the retained client. With none, locked = 0 and locked_client = 0xff.

Each sample() call describes one edge. Check the old state against your model first. Then predict the edge, check the offer and receipts, and update your model. Check the new state last.

BitFieldCompares
0PREPpriority_state before the edge
1PRELOCKlocked before the edge
2PREOWNERlocked_client before the edge
3VALIDvalid of the offer
4GRANTthe whole grant bitmap
5WINNERwinner of the offer
6ACCEPTaccepted after the edge
7CLIENTaccepted_client after the edge
8CANCELcanceled after the edge
9POSTPpriority_state after the edge
10POSTLOCKlocked after the edge
11POSTOWNERlocked_client after the edge

Your model follows the rules, never the hardware. It must not copy the pointer or the lock from the pins, even after a mismatch. Keep checking after errors and through resets.

Report itemMeaning
FIRSTThe first mismatch, as FIELD@cycle:expected>actual with both values in 8 hex digits. Within one edge, the lowest bit wins. OK when there is none.
MASKAll field bits that ever failed, in 3 hex digits.
BADThe number of edges with at least one mismatch.
ATransfers your model predicts.
SEENEdges where the accepted pin was 1.
MATCHPredicted transfers where the pin was 1 and accepted_client was right.
OPENRetained clients started: the first stalled edge of a fresh offer. A transfer with no stall opens nothing.
RETRetained clients that ended in a transfer.
WITHDRAWRetained clients that ended by withdrawal.
RESET_CANCELRetained clients that ended by reset.
RESETSReset edges.
PYour predicted priority_state after the last edge.
OWNERYour predicted retained client in 2 hex digits, or ff.

The report joins the items with |, as FIRST=OK|MASK=000|... in the order above. Every retained client ends exactly once, so OPEN = RET + WITHDRAW + RESET_CANCEL, plus 1 if one is still retained.

Faulty arbiterWhat is wrong
1It makes a fresh choice even while a client is retained.
2The pointer moves on a stalled offer.
3It keeps offering a retained client that has withdrawn.
4It never retains a stalled offer.
5The pointer wraps to 1 instead of 0, so client 0 is skipped. With N = 1 it behaves correctly.
6The retained client survives reset.
7grant also has a bit for every other client that asks.
8The old receipt survives reset.

Inputs are steady 1 ns before each rising edge. The tests read the offer and the old state just before the edge. They read the receipts and the new state 1 ns after it.

N is 1, 2, 3, 5 or 8. The tests do not tell the checker which arbiter it is watching.

The line the tests compare
PREFIX=<edges where report() was wrong>|<your final report>|TRACE=<the arbiter trace>

The result compares this line with the expected text, character by character. It shows both lengths and whether the two lines match. On a mismatch the log prints your line.

Examples

Example 1

A New Request Cannot Steal the Offer
Input
N = 3, priority 0, correct arbiter. Edge 0: client 2 stalls. Edge 1: clients 0 and 2 ask. Edge 2: only client 0 asks. Then transfers, stalls and two resets.
Output
your_line_length = 1613, expected_line_length = 1613, lines_match = yes

Client 2 stays offered when client 0 arrives. When client 2 withdraws, edge 2 is idle and canceled = 1. Client 0 transfers on edge 3. The report is clean: OPEN=3, RET=1, WITHDRAW=1, RESET_CANCEL=1.

Example 2

A Stolen Offer Shows Before Any Count Changes
Input
The same traffic with faulty arbiter 1, which makes a fresh choice while a client is retained
Output
your_line_length = 1636, expected_line_length = 1636, lines_match = yes

On edge 1 the arbiter offers client 0 instead of client 2. The first mismatch is GRANT@1:00000004>00000001, because VALID agrees. Later edges add WINNER and lock mismatches.

Example 3

A Withdrawn Client Is Still Offered
Input
The same traffic with faulty arbiter 3, which keeps offering a withdrawn client
Output
your_line_length = 1636, expected_line_length = 1636, lines_match = yes

On edge 2 client 2 has withdrawn, so no offer is expected. The arbiter still shows valid = 1. The first mismatch is VALID@2:00000000>00000001.

Constraints and Contract

  • Predict from your own model. Use the pointer and lock pins only for comparison.
  • A reset ends a retained client before any transfer or withdrawal is counted.
  • Keep the class name, the method names and the argument types.

Hints

Hint 1

Keep the retained client in your own model. It is set on the first stalled edge and cleared by a transfer, a withdrawal or a reset.

Hint 2

When a client is retained, the expected offer is that client if it still asks, and no offer if it has withdrawn. Only an empty model makes a fresh choice.

Hint 3

Look at how sample() picks the expected winner. It always scans the requests and never checks owner first.

What the grader checks: The checker watches real retained-offer arbiters with N = 1, 2, 3, 5 and 8: one correct and eight with distinct faults. Every report after every edge is compared. The traces are 32 edges long, so this is strong evidence but not a proof.

93 checks on Verilator · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 8 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

A New Request Cannot Steal the Offer

Input
N = 3, priority 0, correct arbiter. Edge 0: client 2 stalls. Edge 1: clients 0 and 2 ask. Edge 2: only client 0 asks. Then transfers, stalls and two resets.
Expected output
your_line_length = 1613, expected_line_length = 1613, lines_match = yes

Client 2 stays offered when client 0 arrives. When client 2 withdraws, edge 2 is idle and canceled = 1. Client 0 transfers on edge 3. The report is clean: OPEN=3, RET=1, WITHDRAW=1, RESET_CANCEL=1.

Run samples executes all 3 public checks. Check all tests runs 93 checks on the server.

Verilator · server