Decode every read request into a target and an AxREGION, and refuse Non-secure requests to the boot ROM. Keep the user bits with the request they belong to.
Hardware context: The attribute path of an interconnect: write buffers, firewalls, decoders and the stages between. Implement the read-address decoder that adds the target and AxREGION and carries the user bits.
Lesson P2.14 called AxREGION a free decode of the upper address bits. Someone has to make it: the decoder at the interconnect port. It also carries the user bits, which the protocol never interprets and a careless stage easily misaligns.
Write module ar_decode, one register stage on the read address channel. Each request leaves with its target and AxREGION from the address map below. The ID, address, length, AxPROT and user bits leave unchanged, with the request they came with.
The boot ROM is Secure only. A Non-secure request to it goes to the default subordinate instead, which will answer DECERR. Addresses no target owns go there too.
A fixture streams up to 19 requests with stalls on both sides. It compares every request that leaves with the one that entered at the same position.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
n_req | 5 | input of each check |
Full specification
module ar_decode (
input logic clk,
input logic rst_n, // active low, asynchronous assert
// read requests from the manager
input logic in_valid,
output logic in_ready,
input logic [3:0] in_id,
input logic [31:0] in_addr,
input logic [7:0] in_len,
input logic [2:0] in_prot,
input logic [7:0] in_user,
// the same request, decoded, one register stage later
output logic out_valid,
input logic out_ready,
output logic [1:0] out_target, // 0 boot ROM, 1 peripheral block, 2 DRAM, 3 default subordinate
output logic [3:0] out_region, // AxREGION for the target
output logic [3:0] out_id,
output logic [31:0] out_addr,
output logic [7:0] out_len,
output logic [2:0] out_prot,
output logic [7:0] out_user
);
// your decoder
endmodule
| Address range | Target | AxREGION |
|---|---|---|
| 0x0000_0000 to 0x0000_ffff | 0, boot ROM (Secure only; Non-secure goes to 3) | 0 |
| 0x2000_0000 to 0x2000_0fff | 1, peripheral block: control registers | 0 |
| 0x2000_1000 to 0x2000_1fff | 1, peripheral block: FIFO window | 1 |
| 0x2000_2000 to 0x2000_3fff | 1, peripheral block: buffer (8 KB) | 2 |
| 0x8000_0000 and above | 2, DRAM | 0 |
| anything else | 3, default subordinate | 0 |
A request is Non-secure when AxPROT[1] is 1. Each region is a whole number of 4 KB spaces, so AxREGION never changes inside a 4 KB space.
The result is {taken_out[15:0], wrong_decode[7:0], wrong_payload[7:0], hold[7:0]}. wrong_decode counts requests with the wrong target or AxREGION. wrong_payload counts requests whose ID, address, length, AxPROT or user bits are not the ones that entered with them, and extra requests. hold counts outputs that changed while waiting for out_ready.
Examples
Example 1
The Edges of the Map- Input
0xfffc user 11, 0x10000 user 11, 0x1ffffffc user 11, 0x20000000 user 11, 0x20000ffc user 11, 0x20001000 user 11, 0x20003ffc user 11, 0x20004000 user 11, 0x7ffffffc user 11, 0x80000000 user 11 sender offers on 16'hffff, receiver ready on 16'hffff
- Output
taken_out = 10, wrong_decode = 0, wrong_payload = 0, hold = 0
0x20003ffc is the last word of the 8 KB buffer, region 2. 0x20004000 is a hole and goes to the default subordinate, as does 0x7ffffffc.
Example 2
The Boot ROM and AxPROT- Input
0x40 NS user 7a, 0x40 user 7b, 0xfff0 NS user 7c sender offers on 16'hffff, receiver ready on 16'hffff
- Output
taken_out = 3, wrong_decode = 0, wrong_payload = 0, hold = 0
The same address twice: Non-secure goes to target 3, Secure goes to target 0. The decoder looks at AxPROT[1], not only at the address.
Example 3
User Bits Under Stalls- Input
0x80000000 user 1, 0x80000010 user 2, 0x80000020 user 3, 0x80000030 user 4, 0x20001000 user a5, 0x20000004 user 5a sender offers on 16'hffff, receiver ready on 16'h5555
- Output
taken_out = 6, wrong_decode = 0, wrong_payload = 0, hold = 0
out_ready drops every other edge. Each request's user byte must leave with that request, not with the one behind it.
Constraints and Contract
- Keep the module name and the ports. out_valid and every output field must come from registers.
- The fixture drives its inputs after each edge and samples your outputs just before the next one.
- Do not reach outside your ports.
Hints
Hint 1
Write the map as one function of the address and AxPROT that returns {target, region}.
Hint 2
Load every output field in the same statement block, on the same condition. A field loaded on a different condition is a field that can drift away from its request.
Hint 3
Take a new request only when the output is empty or being taken at this edge.
What the grader checks: Your decoder runs eight streams of up to 19 requests under stalls on both sides. They include the edges of every region and Non-secure ROM requests. Every request that leaves is compared with the map and with the request that entered. Passing shows the map and the stage are right on these streams.
8 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