Put a firewall between the APB bridge and the ap_soc peripherals. It refuses each transfer its page does not allow, keeps the target from ever seeing it, and logs the first refusal.
Hardware context: ap_soc key vault, APB firewall and AHB security filter. SoC access control and key protection
In ap_soc the bridge hands every APB transfer to the peripheral bus. Your firewall sits between them. paddr is the offset inside the 64 KiB APB window, so paddr[15:12] is the page. Page 8 holds the lab key vault from S9.5.
PPROT follows Arm IHI 0024E section 3.5. PPROT[0] = 1 is privileged, PPROT[1] = 1 is Non-secure and PPROT[2] = 1 is an instruction access. Section 3.5 calls PPROT[2] a hint; this policy trusts it. The policy below is the ap_soc exercise policy.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
sample | 10 | input of each check |
Full specification
| Page | Block | Allowed transfers |
|---|---|---|
| 0, 1, 2, 5 | UART0, GPIO, Timer and PWM, SPI | Every data access |
| 3 | Watchdog | Any read; writes only when privileged |
| 4 | ap_sysctl | Any read; writes only when privileged and Secure |
| 6 | DMA control | Only privileged accesses, read or write |
| 7, 9 to 15 | Hole and reserve | Every data access (the downstream decoder answers) |
| 8 | Key vault | Only accesses that are privileged and Secure |
An instruction access is refused on every page.
A refused transfer must never reach the peripherals: psel_out and penable_out stay low for both its phases. The firewall answers it itself with pready = 1 and prdata = 0. pslverr is 1 in its access phase and 0 in its setup phase.
An allowed transfer passes through unchanged, and so does an idle bus (psel = 0). psel_out = psel and penable_out = penable. pready, pslverr and prdata come from the peripheral side.
The log records the first refusal. At the rising pclk edge that ends a refused access phase, set fault_valid and record pwrite, the page and pprot. Keep that record until reset; later refusals do not change it. A setup edge records nothing. presetn is a synchronous active-low reset that clears all four log outputs.
Examples
Example 1
An Open Page- Input
Reset, then a user write to UART0 in its access phase
- Output
prdata = 0x85be6ea2, pslverr = 1, pready = 0, penable_out = 1, psel_out = 1, fault_prot = 'b000, fault_page = 0x0, fault_write = 0, fault_valid = 0
UART0 allows user writes, so every signal passes through from the peripheral side.
Example 2
The Vault Refuses User Mode- Input
User read of the key vault page, access phase
- Output
prdata = 0x0, pslverr = 1, pready = 1, penable_out = 0, psel_out = 0, fault_prot = 'b000, fault_page = 0x0, fault_write = 0, fault_valid = 0
The firewall answers the access phase itself: ready, an error and zero data. The target never sees psel.
Example 3
The Log- Input
Clock that refused read: the log records it
- Output
prdata = 0x0, pslverr = 1, pready = 1, penable_out = 0, psel_out = 0, fault_prot = 'b000, fault_page = 0x8, fault_write = 0, fault_valid = 1
The edge that ends the refused access phase records page 8, a read and PPROT 000.
Constraints and Contract
- Implement module ap_apb_firewall. The pass and refuse outputs are combinational; only the log is clocked.
- Use only your ports. Force, release, defparam, bind and hierarchical names are refused.
Hints
Hint 1
Write the policy as one decision per page first, then add the instruction rule on top.
Hint 2
A refused transfer has two phases. Which outputs does the firewall drive in each, and which outputs must stay low?
Hint 3
The log has three conditions on its edge. One of them keeps the first record.
What the grader checks: Every page, PPROT value and direction is tested in both phases with random peripheral responses. The log is tested at setup and access edges, for first-record retention and reset.
592 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path