P2.13.3 The Exclusive Rules Checker

HardVerify50 minIcarus · browser samples / server checks6 hidden designsReview the topic

Write the checker that judges every exclusive request. Check its size, alignment and length, when its write may start, and whether the write repeats its read.

Hardware context: The monitor hardware behind a subordinate that supports exclusive accesses. Check every exclusive request a manager issues against the restrictions, the read-before-write rule and the matching pair.

Lesson P2.13 raced two managers through an exclusive monitor and named one rule, exclusive, on its checker. The specification asks more of a manager than the bench's checker shows. This checker holds managers to all of it.

Write module excl_checker. It watches the two address channels and the read data channel of one link. For every exclusive request it adds one to errors for each rule the request breaks. Normal requests are not its business.

Seven scripted managers drive it. One keeps every rule. Its traffic has a pair and its retry, sizes at the limits, and normal requests that would be illegal as exclusives. It also has a write with no read before it, a monitor moved by a second read, and two IDs at once. Each of the other six breaks one rule. You pass with zero on the first and at least one on each of the others.

Signals in the Timeline

SignalWidthRole
aclk1stimulus, the same for every design
aresetn1stimulus, the same for every design
arvalid1output of the design under test
arid4output of the design under test
araddr32output of the design under test
arlen8output of the design under test
arsize3output of the design under test
arlock1output of the design under test
awvalid1output of the design under test
awid4output of the design under test
awaddr32output of the design under test
awlen8output of the design under test
awsize3output of the design under test
awburst2output of the design under test
awlock1output of the design under test
rvalid1output of the design under test
rid4output of the design under test
rlast1output of the design under test
your errors32output of the design under test
Full specification
The module you write (keep these ports)
module excl_checker (
  input  logic        aclk,
  input  logic        aresetn,
  // read address
  input  logic        arvalid,
  input  logic        arready,
  input  logic [3:0]  arid,
  input  logic [31:0] araddr,
  input  logic [7:0]  arlen,
  input  logic [2:0]  arsize,
  input  logic [1:0]  arburst,
  input  logic        arlock,
  // write address
  input  logic        awvalid,
  input  logic        awready,
  input  logic [3:0]  awid,
  input  logic [31:0] awaddr,
  input  logic [7:0]  awlen,
  input  logic [2:0]  awsize,
  input  logic [1:0]  awburst,
  input  logic        awlock,
  // read data
  input  logic        rvalid,
  input  logic        rready,
  input  logic [3:0]  rid,
  input  logic        rlast,
  output int          errors
);
  // your checker
endmodule
RuleFor every exclusive request (AxLOCK = 1)
transfersAxLEN is at most 15: no more than 16 transfers.
sizeThe bytes, (AxLEN + 1) x 2^AxSIZE, are a power of two and at most 128.
alignmentAxADDR is a multiple of that number of bytes.
read firstAn exclusive write must not be taken while an exclusive read with the same ID still waits for its RLAST beat.
same pairAn exclusive write repeats AxADDR, AxLEN, AxSIZE and AxBURST of the latest exclusive read with its ID. With no earlier exclusive read of that ID, there is nothing to compare.

Sample at the rising edge. A request is taken where its VALID and READY are both 1. A read ends at the edge where rvalid, rready and rlast are all 1. Responses with one ID come back in the order of their requests.

The bus is 64 bits wide, so AxSIZE goes up to 3. Each of the five scenarios starts with two reset edges and runs 30 more. The subordinate is always ready and starts each read's beats two edges after the request.

For each manager 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 Correct Manager Must Not Raise an Alarm
Input
Manager: keeps every rule
Scenarios: A legal pair and its retry; Exclusive sizes at the limits; Normal requests the rules do not cover; A write with no read, and a monitor that moved; Two IDs interleaved
Output
alarm = no

Scenario 3 has a 12-byte read and a 32-beat read, but neither is exclusive. Scenario 4 has an exclusive write with no read before it, which is legal.

Example 2

Aligned Beats, Misaligned Transaction
Input
Manager: Not aligned to its total size
Scenarios: A legal pair and its retry; Exclusive sizes at the limits; Normal requests the rules do not cover; A write with no read, and a monitor that moved; Two IDs interleaved
Output
alarm = yes

Two 4-byte beats at 0x604. Each beat sits on a 4-byte boundary, but the 8-byte total needs an 8-byte boundary.

Example 3

A Write That Cannot Wait
Input
Manager: The write starts before the read ends
Scenarios: A legal pair and its retry; Exclusive sizes at the limits; Normal requests the rules do not cover; A write with no read, and a monitor that moved; Two IDs interleaved
Output
alarm = yes

The exclusive write of ID 1 is taken two edges before the last beat of ID 1's exclusive read.

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

Remember the latest exclusive read per ID: address, length, size and burst.

Hint 2

For the read-first rule you need to know which outstanding reads of an ID are exclusive. Same-ID reads finish in order, so a small queue of lock bits per ID is enough.

Hint 3

Compute the byte count as (AxLEN + 1) << AxSIZE in an int. A power of two n has n & (n - 1) equal to 0. Test alignment against the byte count, not the beat size.

What the grader checks: Your checker watches one correct and six faulty scripted managers over five scenarios. Passing shows that it catches these six faults and stays silent on legal traffic that looks suspicious. It does not show that it catches every exclusive-access bug.

7 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

The Correct Manager Must Not Raise an Alarm

Input
Manager: keeps every rule
Scenarios: A legal pair and its retry; Exclusive sizes at the limits; Normal requests the rules do not cover; A write with no read, and a monitor that moved; Two IDs interleaved
Expected output
alarm = no

Scenario 3 has a 12-byte read and a 32-beat read, but neither is exclusive. Scenario 4 has an exclusive write with no read before it, which is legal.

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

Icarus · browser samples / server checks