H5.2 Independent-Channel Write Assembler

MediumFixVerilator · serverReview the topic

Fix an AXI write engine that loses write data when the data arrives before its address.

Hardware context: AXI4 burst engine using an explicitly limited protocol subset. Assemble independent accepted address/data channels into ordered writes.

In AXI, write data may arrive before its address. A write engine passed every test where the address came first. When the data came first, it wrote the wrong values to the backend.

The module submitted_write_core is the write side of a small AXI subordinate. It stores addresses from AW and data beats from W in separate buffers. It joins the oldest address with the oldest beats and sends each beat to a backend as a commit. One B response follows each burst.

The tests drive AW and W from separate sources that release them at different times. An independent queue model checks every ready, commit and B offer on each of 64 edges.

Find the bug and fix it. The full rules of the engine are in the specification.

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 ports (keep them)
module submitted_write_core(
input bit clk, resetn,
input bit awvalid, output wire awready, input bit [1:0] awid, input bit [15:0] awaddr,
input bit [1:0] awlen, awburst,
input bit wvalid, output wire wready, input bit [31:0] wdata, input bit [3:0] wstrb, input bit wlast,
input bit bready, output wire bvalid, output wire [1:0] bid, bresp,
output bit commit_valid, output bit [1:0] commit_id, output bit [15:0] commit_addr,
output bit [31:0] commit_data, output bit [3:0] commit_strb, output bit commit_last, output bit [1:0] commit_resp);
  // your engine
endmodule
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.

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.

Each test starts with reset and runs 64 edges. There is no reset in the middle of a test.

error_cycles has bit i set when edge i broke a rule, counting edges from 0. Bit 63 is also set when work is left at the end. accepted_aw and accepted_w count the AW and W handshakes.

Examples

Example 1

Data Six Edges Before Its Address
Input
ID 1, INCR, 2 beats at 0x20. W beats released on edge 0, AW on edge 6. BREADY is always 1.
Output
error_cycles = {}, accepted_aw = 1, accepted_w = 2

Both beats wait in the W buffer. The address is accepted on edge 6. The backend commits the beats on edges 7 and 8, at 0x20 and 0x24. One OKAY response follows.

Example 2

A WRAP Burst and a Held Response
Input
ID 2, WRAP, 4 beats at 0x3c. AW on edge 0, W beats on edges 4, 6, 8 and 10. BREADY is 0 until edge 20.
Output
error_cycles = {}, accepted_aw = 1, accepted_w = 4

The commits go to 0x3c, 0x30, 0x34 and 0x38. The response, ID 2 and OKAY, waits unchanged until BREADY rises. Nothing is lost.

Example 3

Wrong WLAST Values
Input
ID 0, INCR, 2 beats at 0x100 with WLAST 1, 1. Then ID 3, 1 beat at 0x8000 with WLAST 0. Everything released on edge 0.
Output
error_cycles = {}, accepted_aw = 2, accepted_w = 3

The first burst still uses both beats and returns SLVERR, because its first WLAST was wrong. The second burst is unmapped, so it returns DECERR, which wins over the wrong WLAST.

Constraints and Contract

  • One B response belongs to a whole burst, never to one beat.
  • Keep the module name and the ports.

Hints

Hint 1

AW and W are separate channels. A W beat can be accepted while no address is stored. Where does that beat go?

Hint 2

Trace the first example. The beats are accepted on edges 0 and 1, the address on edge 6. Which buffer slots hold the beats when the backend uses them?

Hint 3

Look at the line that writes an accepted beat into the W buffer. It stores the beat only when an address is stored (ac > 0). WREADY accepted it anyway, so the beat is lost.

What the grader checks: Sources that hold VALID until accepted drive AW and W at different times. A queue model checks every ready, commit field and B offer for 64 edges. This covers the bursts and timings of these tests, not every legal AXI trace.

51 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 Six Edges Before Its Address

Input
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 = {}, accepted_aw = 1, accepted_w = 2

Both beats wait in the W buffer. The address is accepted on edge 6. The backend commits the beats on edges 7 and 8, at 0x20 and 0x24. One OKAY response follows.

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

Verilator · server