Write the checker that watches requests go into an interconnect stage and come out, and knows which changes the attributes allow.
Hardware context: The attribute path of an interconnect: write buffers, firewalls, decoders and the stages between. Check an interconnect stage for every modification the request attributes forbid.
Lesson P2.14 listed what an interconnect may do to a request. A Modifiable one may be split, a Non-modifiable one may not, and nobody may touch AxPROT or AxLOCK. Each rule has an exception or two, and real interconnects use every one of them.
Write module mod_checker. It watches the write requests that enter a stage and the requests that leave it. For each request that leaves, it finds the request it came from. It adds one to errors for every rule the change breaks.
Eight stages drive it. One uses only legal changes. It splits Modifiable bursts and a 32-beat Non-modifiable one, drops Bufferable, renumbers IDs and resizes an exclusive write. Each of the other seven makes one illegal change. You pass with zero on the first and at least one on each of the others.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
aclk | 1 | stimulus, the same for every design |
u_awvalid | 1 | output of the design under test |
u_awid | 4 | output of the design under test |
u_awaddr | 32 | output of the design under test |
u_awlen | 8 | output of the design under test |
u_awsize | 3 | output of the design under test |
u_awcache | 4 | output of the design under test |
u_awprot | 3 | output of the design under test |
u_awlock | 1 | output of the design under test |
d_awvalid | 1 | output of the design under test |
d_awid | 4 | output of the design under test |
d_awaddr | 32 | output of the design under test |
d_awlen | 8 | output of the design under test |
d_awsize | 3 | output of the design under test |
d_awcache | 4 | output of the design under test |
d_awprot | 3 | output of the design under test |
d_awlock | 1 | output of the design under test |
your errors | 32 | output of the design under test |
Full specification
module mod_checker (
input logic aclk,
input logic aresetn,
// the write requests that enter the stage
input logic u_awvalid,
input logic u_awready,
input logic [3:0] u_awid,
input logic [31:0] u_awaddr,
input logic [7:0] u_awlen,
input logic [2:0] u_awsize,
input logic [1:0] u_awburst,
input logic [3:0] u_awcache,
input logic [2:0] u_awprot,
input logic u_awlock,
// the write requests that leave it
input logic d_awvalid,
input logic d_awready,
input logic [3:0] d_awid,
input logic [31:0] d_awaddr,
input logic [7:0] d_awlen,
input logic [2:0] d_awsize,
input logic [1:0] d_awburst,
input logic [3:0] d_awcache,
input logic [2:0] d_awprot,
input logic d_awlock,
output int errors
);
// your checker
endmodule
| Rule | For every request that leaves the stage |
|---|---|
| pairing | It belongs to the oldest request that entered and is not yet fully covered. It starts at the next byte of that request and does not run past its end. |
| always | AxPROT and AxLOCK equal those of its request. The ID may change. |
| Non-modifiable | AxBURST is unchanged. AxCACHE is unchanged, except that the Bufferable bit may be cleared. |
| Non-modifiable, not exclusive | AxSIZE is unchanged. A request of 16 beats or fewer leaves as one burst; a longer one may be split. |
| Non-modifiable, exclusive | It leaves as one burst covering the same bytes; AxSIZE and AxLEN may change. |
| Modifiable | It may be split. AxCACHE is not checked. |
The bytes of a request are [AxADDR, AxADDR + (AxLEN + 1) x 2^AxSIZE). Every request is INCR and aligned to its size. A request with nothing upstream to pair with is an error too.
Each of the five scenarios starts with two reset edges and runs 16 more. Both sides are always ready, so a request is taken at the edge after it is offered.
For each stage you get alarm = yes or no. For the correct one you also get first_alarm_scenario and first_alarm_cycle, the first edge where your count rose.
Examples
Example 1
The Legal Stage Must Not Raise an Alarm- Input
Stage: makes only legal changes Scenarios: Modifiable bursts split in two; A Non-modifiable burst of 32 beats split at 16; Bufferable dropped and the ID changed; An exclusive write resized on a wide link; Requests passed as they are
- Output
alarm = no
It splits Modifiable bursts and a 32-beat Non-modifiable one, drops Bufferable, changes IDs and resizes an exclusive. All of that is allowed.
Example 2
A Forbidden Split- Input
Stage: Splits a Non-modifiable burst Scenarios: Modifiable bursts split in two; A Non-modifiable burst of 32 beats split at 16; Bufferable dropped and the ID changed; An exclusive write resized on a wide link; Requests passed as they are
- Output
alarm = yes
An 8-beat Device write is cut into two 4-beat bursts. Device memory is Non-modifiable, and 8 beats is not over 16.
Example 3
Same Bytes, Wrong Request- Input
Stage: Resizes a normal Non-modifiable burst Scenarios: Modifiable bursts split in two; A Non-modifiable burst of 32 beats split at 16; Bufferable dropped and the ID changed; An exclusive write resized on a wide link; Requests passed as they are
- Output
alarm = yes
Four 4-byte beats become two 8-byte beats. That is legal for an exclusive write; this one is not exclusive.
Constraints and Contract
- IDs are 4 bits. Every input is always 0 or 1.
- Use only your ports. Do not reach into the traffic or other checkers by name.
- errors never decreases; a reset edge leaves it as it is.
Hints
Hint 1
Keep a small queue of the upstream requests: their bytes, their attributes and the next byte still to be covered.
Hint 2
When a request leaves, compare it with the head of the queue and move the head's next byte forward. Pop the head once its last byte is covered.
Hint 3
Write the Non-modifiable rules as three cases: always, not exclusive, exclusive. The exceptions live in the last two.
What the grader checks: Your checker watches one legal and seven faulty stages over five scenarios of write requests. Passing shows it catches these seven changes and allows the legal ones, not that it catches every illegal modification.
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