H5.5 AXI Engine Verification Campaign

ExpertFixVerilator · serverReview the topic

Fix the two bugs in a full AXI memory campaign: one in the write observer and one in the memory checker.

Hardware context: AXI4 burst engine using an explicitly limited protocol subset. Qualify the burst engine against channel-stall, beat-loss, response-order and reset defects.

This is the whole checking side of a small AXI memory system. A write engine and a read engine share one memory. write_observer checks the write channels. memory_read_checker and memory_read_expectation check memory and reads.

On correct engines, the campaign reports false errors in two kinds of test. One kind has a burst with a wrong WLAST. The other has a reset in the middle of traffic.

The tests run real engines, correct and faulty, on one memory. They compare both reports with the expected reports, character by character.

There are two bugs, one in each checker. Find both and fix them.

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
read_fault2input of each check
Full specification
The write observer (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
The memory checker (keep these names and types)
class memory_read_expectation;
  function new(input bit [1:0] id, input bit [15:0] address, input bit [1:0] length, burst,
               input bit [127:0] words);   // word j of the burst in bits 32*j+31 : 32*j
endclass
class memory_read_checker;
  bit [7:0] memory_bytes[8192];
  function new();
  function void sample(input int cycle, input bit resetn,
    arvalid, arready, input bit [1:0] arid, input bit [15:0] araddr, input bit [1:0] arlen, arburst,
    rvalid, rready, input bit [1:0] rid, rresp, input bit [31:0] rdata, input bit rlast);
  function void write_edge(input write_observer writer);
  function bit [79:0] finish();  // {error_cycles[63:0], error_kinds[7:0], pending_reads[7: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.
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.
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.

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.

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.
Memory ruleMeaning
Start8192 bytes. The byte at address a starts as ((17 × a) XOR 0x5a) & 0xff.
WriteA commit with OKAY changes only its enabled byte lanes, after the edge. SLVERR and DECERR commits change nothing.
Partial burstEarlier OKAY beats of a burst stay written even when a later beat fails.
ReadThe edge that accepts AR takes a snapshot of every beat of the burst, from memory before that edge.
Same edgeAn AR and a write commit on the same edge: the read sees the old bytes.
Late beatsR beats may come much later. They still carry the snapshot, not the current memory.
ResetReset cancels every read, write and response in flight. Bytes already written stay.
Each edgeWhat happens
1The tests call sample() with the AR and R channels before the edge.
2They call write_edge(writer). It applies the next predicted write to memory_bytes, from the write observer's queues before the edge.
3The clock rises. The real engines move, and real OKAY commits change the real memory.
4The write observer samples the write channels.
Step in sample()What it does
Reset edgeEmpty every queue and clear the stall record. ARREADY and RVALID must be 0.
AR creditARREADY must equal (fewer than 4 bursts outstanding before the edge).
HoldAfter an edge with RVALID = 1 and RREADY = 0, the beat must stay. RVALID stays 1, and RID, RDATA, RRESP and RLAST do not change.
OfferOn every edge with RVALID = 1, find the oldest burst of RID. Check its next beat: data, response and RLAST.
RetireOnly on RVALID and RREADY, move to the next beat. Pop the burst after its declared last beat, whatever RLAST said.
AppendLast, add a burst for an AR handshake on this edge. A new AR cannot explain a beat on the same edge.
error_kinds bitRaised when
0A beat has an RID with no outstanding burst.
1Wrong data or response for the oldest burst of the ID.
2Wrong RLAST.
3A stalled beat changed or vanished.
4finish() finds bursts still outstanding.
5ARREADY disagrees with the free credits.
6ARREADY or RVALID is 1 during reset.

write_edge() must predict from the observer's queues. It must not copy the real commit data, address or strobes.

All bursts here are fully mapped or fully unmapped. An unmapped read returns zero data and DECERR.

EnginesBehaviour
Write engineCorrect, or one of seven faults. Data faults: zeroed data, a flipped data bit, or all strobes on.
Other write faults: a wrong BID, a BID that moves in a stall, an early burst end, or the newest address first.
Read engineCorrect, or one fault: a flipped data bit, or a wrong RRESP with correct data.
TestsEach test runs 64 edges. One test keeps BREADY at 0, so a write response is still owed at the end.

The tests build the text write_report|read_report, each 20 hex digits. write_report is finish() of the write observer: {error_cycles, accepted_aw, accepted_w}. read_report is finish() of memory_read_checker.

They compare it with the expected text, character by character. reports_match = yes means both reports are exactly right. report_chars and expected_chars are the two lengths, normally 41.

Examples

Example 1

A Read Before the Write Keeps the Old Bytes
Input
Correct engines. Write: ID 1, INCR, 2 beats at 0x20, strobes 0x5 then 0xa; W on edges 0 and 1, AW on edge 6. Reads: ID 0 at 0x20 on edge 0, ID 1 at 0x30 on 6, ID 0 at 0x20 on 18, ID 2 at 0x80 on 32. RREADY from edge 10.
Output
report_chars = 41, expected_chars = 41, reports_match = yes

The first read of 0x20 is accepted before the write, so its beats carry the old bytes. They retire only after the commits on edges 7 and 8. The read on edge 18 sees the new lanes. Both reports are clean. Expected text: 00000000000000000102|00000000000000000000.

Example 2

A Wrong WLAST Makes the Rest of Its Burst SLVERR
Input
Correct engines. Write: ID 0, INCR, 2 beats at 0x100, with WLAST on both beats; then ID 3, 1 beat at 0x8000 with WLAST = 0. AW and W from edge 0. Same reads.
Output
report_chars = 41, expected_chars = 41, reports_match = yes

The first burst raises WLAST one beat early, on beat 0. That makes the burst SLVERR, so beat 1 must also expect SLVERR, although its WLAST is right. The write to 0x8000 is unmapped, so it gets DECERR whatever WLAST says. Both reports are clean. Expected text: 00000000000000000203|00000000000000000000.

Example 3

Reset Keeps Written Bytes
Input
Write: ID 1, 4 beats at 0x20 from edge 0, reset on edges 12 and 13, then ID 1, 2 beats at 0x80. BREADY is 0 until edge 30. Reads restart after the reset.
Output
report_chars = 41, expected_chars = 41, reports_match = yes

The first burst commits all four beats before the reset. Its response is still waiting, and reset cancels it. The bytes stay, so the read of 0x20 accepted on edge 21 must see them. Expected text: 00000000000000000206|00000000000000000000.

Example 4

Bad Write Data Shows up in a Later Read
Input
The first traffic on a write engine that stores zeros instead of the W data
Output
report_chars = 41, expected_chars = 41, reports_match = yes

The write observer flags the commits on edges 7 and 8. Real memory now holds zeros in the enabled lanes. The read on edge 18 expects the predicted bytes, so its two beats fail on edges 20 and 22. Expected text: 00000000000001800102|00000000005000000200.

Constraints and Contract

  • A reset cancels transactions, not bytes already written.
  • A wrong WLAST makes the rest of its burst SLVERR.
  • Keep the class names, the method names and the argument types.

Hints

Hint 1

Split the problem by scene. A wrong WLAST matters only to the write side. A reset matters to both sides. Which state does each scene depend on?

Hint 2

A WLAST error is sticky for the rest of its burst. A reset cancels the work in flight but keeps the bytes already written.

Hint 3

Look at how write_observer computes new_bad. Then look at the reset branch of memory_read_checker.sample().

What the grader checks: Real write and read engines share one byte memory. Faulty engines change real data, strobes, IDs, statuses and responses, and some tests reset in the middle. Both reports are compared exactly. This is the teaching subset of AXI, not full AXI.

147 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 Read Before the Write Keeps the Old Bytes

Input
Correct engines. Write: ID 1, INCR, 2 beats at 0x20, strobes 0x5 then 0xa; W on edges 0 and 1, AW on edge 6. Reads: ID 0 at 0x20 on edge 0, ID 1 at 0x30 on 6, ID 0 at 0x20 on 18, ID 2 at 0x80 on 32. RREADY from edge 10.
Expected output
report_chars = 41, expected_chars = 41, reports_match = yes

The first read of 0x20 is accepted before the write, so its beats carry the old bytes. They retire only after the commits on edges 7 and 8. The read on edge 18 sees the new lanes. Both reports are clean. Expected text: 00000000000000000102|00000000000000000000.

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

Verilator · server