Build the block that answers every address nobody owns: DECERR for each write and each read beat, with every promised transfer completed.
Hardware context: The monitor hardware behind a subordinate that supports exclusive accesses. Implement the default subordinate that completes every transfer of a request no memory owns with DECERR.
Lesson P2.13 ended its opening story with a DMA engine stuck behind a default subordinate. That block sits inside every interconnect. It owns the holes in the address map and answers anything sent there.
Write module axi_default_sub. A write gets one response: DECERR with the write's AWID. It comes only after the address and the beat with WLAST have both been taken. The beats themselves are drained and thrown away.
A read of ARLEN + 1 beats gets exactly that many beats. Each one carries the read's ARID and DECERR, and RLAST marks the last. A short burst or a long one hangs the manager just as surely as silence.
A fixture plays scripts of writes and reads. It offers data before, after or with the address, and keeps up to two writes and two reads outstanding. It also stalls BREADY, RREADY and the write beats. It counts what your block answers and every rule it breaks.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
aclk | 1 | stimulus, the same for every design |
awvalid | 1 | stimulus, the same for every design |
awready | 1 | stimulus, the same for every design |
awid | 4 | stimulus, the same for every design |
awlen | 8 | stimulus, the same for every design |
wvalid | 1 | stimulus, the same for every design |
wready | 1 | stimulus, the same for every design |
wlast | 1 | stimulus, the same for every design |
bvalid | 1 | stimulus, the same for every design |
bready | 1 | stimulus, the same for every design |
bid | 4 | stimulus, the same for every design |
bresp | 2 | stimulus, the same for every design |
arvalid | 1 | stimulus, the same for every design |
arready | 1 | stimulus, the same for every design |
arid | 4 | stimulus, the same for every design |
arlen | 8 | stimulus, the same for every design |
rvalid | 1 | stimulus, the same for every design |
rready | 1 | stimulus, the same for every design |
rid | 4 | stimulus, the same for every design |
rresp | 2 | stimulus, the same for every design |
rlast | 1 | stimulus, the same for every design |
Full specification
module axi_default_sub (
input logic aclk,
input logic aresetn, // active low, asynchronous assert
// write address
input logic [3:0] awid,
input logic [31:0] awaddr,
input logic [7:0] awlen, // beats - 1
input logic awvalid,
output logic awready,
// write data
input logic [31:0] wdata,
input logic wlast,
input logic wvalid,
output logic wready,
// write response
output logic [3:0] bid,
output logic [1:0] bresp,
output logic bvalid,
input logic bready,
// read address
input logic [3:0] arid,
input logic [31:0] araddr,
input logic [7:0] arlen, // beats - 1
input logic arvalid,
output logic arready,
// read data
output logic [3:0] rid,
output logic [31:0] rdata,
output logic [1:0] rresp,
output logic rlast,
output logic rvalid,
input logic rready
);
// your default subordinate
endmodule
| Channel | What your block must do |
|---|---|
| AW and W | Accept the address and every beat up to WLAST, in either order. You may hold AWREADY or WREADY low while you are busy. |
| B | One response per write, after both the AW handshake and the WLAST handshake: BID = AWID, BRESP = 2'b11 (DECERR). |
| AR | Accept a read. You may hold ARREADY low while a read is being answered. |
| R | ARLEN + 1 beats, each with RID = ARID and RRESP = 2'b11. RLAST is 1 on the last beat and 0 on every other. RDATA is not checked. |
| VALID rules | BVALID and RVALID stay 1, with their payload unchanged, until the handshake. Both are 0 while ARESETn is 0. |
Bits 47 to 0 of the result are {writes_ok[7:0], reads_ok[7:0], beats[15:0], bad[7:0], early[3:0], hold[3:0]}. writes_ok counts writes answered DECERR with the right ID. reads_ok counts reads whose beats all came back right. beats counts every read beat taken.
bad counts broken rules. A wrong ID or response, RLAST on the wrong beat and a beat with no read outstanding each count. So does a VALID in reset. early counts edges where BVALID was 1 with no write complete and unanswered. hold counts VALIDs withdrawn or changed before their READY. Each case runs 340 edges after reset.
Examples
Example 1
One of Each- Input
Writes: ID 2, 1 beat, address first Reads: ID 3, 1 beat BREADY 16'hffff, RREADY 16'hffff, W offers 16'hffff (bit = edge mod 16)
- Output
writes_ok = 1, reads_ok = 1, beats = 1, bad = 0, early = 0, hold = 0
The write's address and its only beat arrive, then one B with BID 2 and DECERR. The read of one beat gets one beat with RID 3, DECERR and RLAST.
Example 2
Data Before the Address, and a Long Read- Input
Writes: ID 1, 4 beats, data first Reads: ID 6, 16 beats BREADY 16'hffff, RREADY 16'hffff, W offers 16'hffff (bit = edge mod 16)
- Output
writes_ok = 1, reads_ok = 1, beats = 16, bad = 0, early = 0, hold = 0
All four write beats arrive before the address is offered. B must still wait for the address. The read gets sixteen beats, and RLAST only on the sixteenth.
Example 3
Stalls on the Read Data Channel- Input
Writes: none Reads: ID 1, 1 beat; ID 1, 4 beats; ID 4, 8 beats BREADY 16'hffff, RREADY 16'h5a5a, W offers 16'hffff (bit = edge mod 16)
- Output
writes_ok = 0, reads_ok = 3, beats = 13, bad = 0, early = 0, hold = 0
RREADY drops every other edge. Each beat you offer must stay on the wires, unchanged, until RREADY takes it.
Constraints and Contract
- Keep the module name and the ports. IDs are 4 bits; ARLEN and AWLEN go up to 255.
- The fixture samples your outputs just before each rising edge and drives its own inputs after it. Registered outputs, or outputs computed from registers, both work.
- Do not reach outside your ports.
Hints
Hint 1
Two small state machines that never talk to each other: one for writes, one for reads.
Hint 2
For writes, remember two facts: the address has arrived (with its ID) and the WLAST beat has arrived. B goes out when both are true. Clear both when B is taken.
Hint 3
For reads, keep a count of beats still to send after the one on the wires. RLAST is 1 when that count is 0. Load it from ARLEN when the read is accepted.
What the grader checks: Your block runs ten scripts of up to four writes and four reads. They have data before and after the address, stalled readies and one 256-beat read. Its responses are compared with a model of a correct default subordinate. Passing shows the rules hold on these scripts, not under every possible manager.
10 checks on Icarus · browser samples / server checks. 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 4 steps and the final capstone