P3.12.1 The PAS Filter

MediumImplementIcarus · browser samples / server checksReview the topic

Guard a completer that has no protection of its own. Let each transfer through only if its address space and privilege may reach that region.

Hardware context: An address-space filter in front of an APB completer with no protection. Implement a PAS filter with four regions, each open to its own address spaces and privilege.

Lesson P3.12 showed a completer that checked the address space itself. Most peripherals do not. The usual fix is a filter in front of them, owned by the system designer, not the peripheral designer.

Write module apb_pas_filter. It sits between an APB5 requester with RME and a completer that ignores PPROT and has no PNSE. The address space comes from PNSE and PPROT[1], the privilege from PPROT[0].

A transfer that may pass goes through untouched: the filter raises the completer's PSEL and hands back its PREADY, PRDATA and PSLVERR. A transfer that may not must never reach the completer, not even its setup cycle. The filter answers it alone, with PSLVERR and PRDATA 0, in its first access cycle.

Signals in the Timeline

SignalWidthRole
transfers4input of each check
Full specification
The module you write (keep these ports)
module apb_pas_filter (
  input  logic        pclk,
  input  logic        presetn,     // active low
  // from the requester
  input  logic        psel,
  input  logic        penable,
  input  logic        pwrite,
  input  logic [11:0] paddr,
  input  logic [2:0]  pprot,
  input  logic        pnse,
  output logic        pready,
  output logic [31:0] prdata,
  output logic        pslverr,
  // to and from the completer (PENABLE, PWRITE, PADDR and PWDATA reach it directly)
  output logic        m_psel,
  input  logic        m_pready,
  input  logic [31:0] m_prdata,
  input  logic        m_pslverr
);
  // your filter
endmodule
Region (paddr[11:10])Who may pass
0: 0x000 to 0x3ffEvery address space, reads and writes.
1: 0x400 to 0x7ffSecure only.
2: 0x800 to 0xbffRealm only.
3: 0xc00 to 0xfffReads from every space. Writes only from Root with PPROT[0] = 1 (privileged).

PPROT[2] is a hint and decides nothing. The fixture checks that the completer never sees PSEL for a refused transfer and never loses PSEL inside an allowed one. It also counts refused reads that returned anything but 0.

The result is {done, errs, completer_transfers, bad, leaks, last_read, ram_sum}. errs has bit i set when transfer i ended with PSLVERR. ram_sum adds the low 24 bits of the completer's sixteen words after the run.

Examples

Example 1

The Secure Region
Input
Secure write 0x404 = 55; Non-secure write 0x404 = 66; Root read 0x404; Secure read 0x404
The completer: four words per 1 KB region, 0 wait states per transfer
Output
done = 4, errs = 'b00000110, completer_transfers = 2, bad = 0, leaks = 0, last_read = 0x55, ram_sum = 0xa307f8

The Secure write passes. The Non-secure write and the Root read are refused and never reach the completer. The Secure read returns 55.

Example 2

Root Is Not Secure
Input
Root write 0x408 = 77; Root read 0x408; Secure read 0x408
The completer: four words per 1 KB region, 1 wait state per transfer
Output
done = 3, errs = 'b00000011, completer_transfers = 1, bad = 0, leaks = 0, last_read = 0xa0660066, ram_sum = 0xf807f8

Root has PPROT[1] = 0, like Secure, but PNSE = 1. A filter that looks only at PPROT[1] would let it into the Secure region.

Example 3

Root Writes Need Privilege
Input
Non-secure read 0xc04; Root unprivileged write 0xc04 = ab; Secure write 0xc04 = ac; Root write 0xc04 = ad; Realm read 0xc04
The completer: four words per 1 KB region, 2 wait states per transfer
Output
done = 5, errs = 'b00000110, completer_transfers = 3, bad = 0, leaks = 0, last_read = 0xad, ram_sum = 0x1b07c8

The Non-secure read of region 3 passes. An unprivileged Root write and a Secure write are refused. The privileged Root write lands, and the Realm read sees it.

Constraints and Contract

  • Keep the module name and the ports. The completer never answers PSLVERR in these scripts.
  • The fixture drives its outputs after each rising edge and samples yours just before the next one.
  • Do not reach outside your ports.

Hints

Hint 1

The decision depends only on signals that are stable for the whole transfer, so it can be combinational.

Hint 2

Gate the completer's PSEL with the decision. Then choose PREADY, PRDATA and PSLVERR from the completer or from your own answer.

Hint 3

Your own answer can have PREADY high all the time: the requester only looks at it in the access phase.

What the grader checks: Your filter runs nine scripts of up to eight transfers from all four address spaces, with and without privilege. The completer inserts zero to two wait states. Responses, completer traffic and data are compared with a model of the region table.

9 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 1 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 Secure Region

Input
Secure write 0x404 = 55; Non-secure write 0x404 = 66; Root read 0x404; Secure read 0x404
The completer: four words per 1 KB region, 0 wait states per transfer
Expected output
done = 4, errs = 'b00000110, completer_transfers = 2, bad = 0, leaks = 0, last_read = 0x55, ram_sum = 0xa307f8

The Secure write passes. The Non-secure write and the Root read are refused and never reach the completer. The Secure read returns 55.

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

Icarus · browser samples / server checks