H5.6 Write Address and Data Rendezvous

HardFixVerilator · serverReview the topic

Fix a write checker that throws away write data accepted before its address.

Hardware context: AXI4 burst engine using an explicitly limited protocol subset. Join independently arriving AXI write-address and data channels with bounded buffering.

A checker raised errors on a correct AXI write engine whenever data arrived before its address. The engine had kept the early beats. The checker had thrown them away.

The class write_observer watches the engine from outside. It rebuilds three queues: accepted addresses, accepted data beats and expected B responses. From them it predicts every backend commit and every B offer.

The tests call sample() once per edge for 64 edges, then finish() and rendezvous(). They run the observer on a correct engine and on seven faulty ones. It must stay silent on the correct engine and report every failing edge on the others.

Find the bug and fix it.

Signals in the Timeline

SignalWidthRole
fault4input of each check
naddresses3input of each check
nbeats5input of each check
descriptors128input of each check
beats0256input of each check
beats1256input of each check
beats2128input of each check
address_release32input of each check
data_release128input of each check
ready_calendar64input of each check
reset_cycle8input of each check
restart_aw3input of each check
restart_w5input of each check
Full specification
The class (keep these names and types)
class write_observer;
  function new();
  function void sample(input int cycle, input bit resetn,
    awvalid, awready, input bit [1:0] awid, input bit [15:0] awaddr, input bit [1:0] awlen, awburst,
    input bit wvalid, wready, input bit [31:0] wdata, input bit [3:0] wstrb, input bit wlast,
    bready, bvalid, input bit [1:0] bid, bresp,
    input bit commit_valid, input bit [1:0] commit_id, input bit [15:0] commit_addr,
    input bit [31:0] commit_data, input bit [3:0] commit_strb, input bit commit_last, input bit [1:0] commit_resp);
  function bit [79:0] finish();     // {error_cycles[63:0], accepted_aw[7:0], accepted_w[7:0]}
  function bit [79:0] rendezvous(); // {error_cycles[63:0], error_kinds[7:0], pending_aw[3:0], pending_w[3:0]}
endclass
AXI ruleMeaning
HandshakeA transfer happens on a rising edge where VALID and READY are both 1.
StallA sender that is not yet taken keeps VALID and its payload unchanged.
Write data orderAW and W are separate channels. In AXI4, W beats follow the order of the addresses and carry no ID.
Response orderResponses with the same ID come back in request order. Different IDs may come back in any order.
This designChoice
Bus16-bit addresses, 32-bit data, four byte strobes and 2-bit IDs.
BurstsFull-word, aligned bursts. FIXED and INCR have 1 to 4 beats. WRAP has 2 or 4 beats. A burst stays inside one 4 KiB page.
MapAddresses 0x0000 to 0x1fff are memory. Any other address completes with DECERR (3).
ResponsesOKAY is 0, SLVERR is 2 and DECERR is 3. EXOKAY is not used.
Left outNarrow or unaligned transfers, longer bursts, exclusive access, cache, QoS, protection and user fields.
Write engine ruleMeaning
BuffersTwo AW descriptors, four W beats and two B responses.
ReadyAWREADY = 1 when fewer than 2 descriptors are stored before the edge. WREADY = 1 when fewer than 4 beats are stored.
Early dataA W beat accepted before its address waits in the W buffer.
JoinFrom the next edge on, each edge may use one beat: the oldest W beat with the oldest descriptor.
Burst endA descriptor stays until its declared last beat, AWLEN + 1 beats in all. WLAST does not end a burst.
B spaceThe last beat of a burst waits while the B buffer was full before the edge. A B handshake on that edge does not help.
CommitAfter the edge that uses a beat, commit_valid = 1 and the commit fields describe it. commit_last marks the declared last beat.
StatusDECERR for an unmapped address. Otherwise SLVERR once any beat of the burst had a wrong WLAST. Otherwise OKAY.
BOne response per burst. BVALID shows the oldest stored response from the edge after the last beat.
Resetresetn is active low. It empties every buffer and clears all valid outputs.
BurstAddress of beat i
FIXED (0)The start address on every beat.
INCR (1)start + 4 × i.
WRAP (2)The window is beats × 4 bytes, aligned to its own size. Add 4 per beat and wrap to the window start at its end.
Step in sample()What it does
Reset edgeEmpty all three queues. Clear the beat count, the sticky WLAST error and the stalled B record. Check that the ready outputs, BVALID and commit_valid are 0.
ReadyAWREADY must equal (fewer than 2 addresses stored). WREADY must equal (fewer than 4 beats stored). Use the queues before this edge.
B offerBVALID must equal (a response is expected). BID and BRESP must match the oldest expected response, even while BREADY is 0.
Stalled BIf the last edge had BVALID = 1 and BREADY = 0, this edge must show the same BID and BRESP with BVALID = 1.
PredictFrom the queues before this edge, decide whether a beat is used, as the engine rules say.
Commitcommit_valid must equal that decision. A used beat must match in ID, address, data, strobes, last and status.
RetirePop the oldest expected response on a real B handshake. A used last beat adds one expected response.
AppendLast, add the AW and W beats accepted on this edge. They count as handshakes even when a faulty engine should not have accepted them.
error_kinds bitRaised when
0AWREADY or WREADY disagrees with the free space.
1commit_valid disagrees with the predicted use of a beat.
2A commit field disagrees.
3A B offer is missing, unexpected or wrong.
4A stalled B offer changed or vanished.
5A ready, BVALID or commit_valid is 1 during reset.
6finish() finds an address, beat or response still expected.

A wrong WLAST is a test of this design only. A correct AXI manager never sends one. This design still uses exactly AWLEN + 1 beats and reports SLVERR once. That recovery is a choice of this design, not an AXI rule.

Faulty engineWhat is wrong
Lost dataStores zeros instead of the W data.
Bit flipFlips bit 0 of each commit.
Wrong BIDFlips bit 0 of BID.
Early endEnds each burst one beat early.
Moving BIDChanges BID while the response is stalled.
Newest addressUses the newest stored address when two are stored.
All strobesCommits every beat with all four strobes on.

error_cycles has bit i set when edge i failed, counting edges from 0. finish() also sets bit 63 when work is left. The tests call finish() and then rendezvous(). pending_aw and pending_w count the addresses and beats still queued, up to 15.

Examples

Example 1

Data First on a Correct Engine
Input
Correct engine. ID 1, INCR, 2 beats at 0x20. W beats released on edge 0, AW on edge 6. BREADY is always 1.
Output
error_cycles = {}, error_kinds = {}, pending_aw = 0, pending_w = 0

Both beats wait in the data queue until the address arrives. The observer then predicts their commits on edges 7 and 8 and one OKAY response. Nothing is reported.

Example 2

Accepted Data Cannot Vanish
Input
The same traffic on the engine that stores zeros instead of the W data
Output
error_cycles = {7, 8}, error_kinds = {2}, pending_aw = 0, pending_w = 0

The handshakes and the response look right. But the commits on edges 7 and 8 carry zeros, so both edges fail with bit 2.

Example 3

A Stall Does Not Excuse a Wrong BID
Input
ID 2, WRAP, 4 beats at 0x3c. W beats on edges 4 to 10. BREADY is 0 until edge 20. The engine changes BID during the stall.
Output
error_cycles = {13, 14, 15, 16, 17, 18, 19, 20}, error_kinds = {3, 4}, pending_aw = 0, pending_w = 0

The expected response is ID 2 and OKAY. The first offer on edge 12 is right. From edge 13 to the handshake on edge 20, the offers are wrong (bit 3) and keep changing (bit 4).

Example 4

An Early End Shifts Every Join
Input
ID 0, 2 beats at 0x100, then ID 3, 1 beat at 0x8000, with wrong WLAST values. The engine ends each burst one beat early.
Output
error_cycles = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}, error_kinds = {0, 1, 2, 3, 6}, pending_aw = 0, pending_w = 0

The engine ends the first burst after one beat. From then on it pairs the wrong beats, answers early and frees space early. Every edge from 1 to 63 fails, and a response is still owed at the end.

Constraints and Contract

  • A queued W beat is not an error just because no address has arrived yet.
  • Check the B offer before you pop a response or add this edge's new arrivals.
  • Keep the class name, the method names and the argument types.

Hints

Hint 1

A W beat accepted while no address is stored is still a real beat. It must wait in the data queue for its address.

Hint 2

Run the first example by hand. The beats are accepted on edges 0 and 1, the address on edge 6. How many beats should the data queue hold then?

Hint 3

Look at the line that appends an accepted W beat. It requires addresses.size() > 0. The engine took the beat, so the observer must record it.

What the grader checks: The observer sees the pins of eight real write engines: one correct and seven with a planted fault each. Every error mask is compared exactly. Passing shows that it predicts these engines on these traces.

100 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

Data First on a Correct Engine

Input
Correct engine. ID 1, INCR, 2 beats at 0x20. W beats released on edge 0, AW on edge 6. BREADY is always 1.
Expected output
error_cycles = {}, error_kinds = {}, pending_aw = 0, pending_w = 0

Both beats wait in the data queue until the address arrives. The observer then predicts their commits on edges 7 and 8 and one OKAY response. Nothing is reported.

Run samples executes all 4 public checks. Check all tests runs 100 checks on the server.

Verilator · server