Work out the configuration byte and the address word of four PMP entries, for a map that changes from product to product.
Hardware context: Four PMP entries (a configuration byte and an address word each) and a region check, as test code, over the SRAM and UART0 of ap_soc. Confining an untrusted task on a microcontroller that has no page tables
A family of microcontrollers runs one user program beside its firmware. The firmware confines the user program with four PMP entries. Each product of the family has a different map, so the entry values are worked out from the map.
Write that logic. Your block is given the map. It gives the eight values that the firmware writes into the entries. It has no clock.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
trial | 10 | input of each check |
Full specification
| Region | Where | Fetch | Load | Store |
|---|---|---|---|---|
| Code | from code_base up to, and not including, code_top | yes | yes | no |
| Data | 2 to the power data_log2 bytes, from data_base | no | yes | yes |
| Register | the four bytes at port_addr | no | yes | yes |
| Everything else | no | no | no |
| Bits | Meaning |
|---|---|
| 7 to 5 | 0 in this problem |
| 4 and 3 | the address mode. 0: OFF, 1: TOR, 2: NA4, 3: NAPOT |
| 2, 1, 0 | X, W and R |
How to read a result: the bench asks a PMP check about some words, as user code. The three counts say at how many of those words a fetch, a load and a store are allowed. The signature folds the three rights of every word together.
Examples
Example 1
Three Regions- Input
code from 20000000 up to 20003000, data of 4096 bytes at 20010000, register at 40000008; 26 words are tried, on both sides of every boundary
- Output
fetches_allowed = 4, loads_allowed = 10, stores_allowed = 6, signature = 0xcc8836
Fetches succeed only in the code. Stores succeed only in the data and at the register. Loads succeed in all three. The words just outside each region are refused.
Example 2
Code at Address 0, Data of 8 Bytes- Input
code from 00000000 up to 00000400, data of 8 bytes at 00001008, register at 00001004; 25 words are tried, on both sides of every boundary
- Output
fetches_allowed = 6, loads_allowed = 15, stores_allowed = 9, signature = 0x74d0827
The code starts at address 0, the data has only 8 bytes, and the register lies just below the data. Each region still ends exactly where the map says.
Example 3
Data of One Word- Input
code from 80000100 up to 80000104, data of 4 bytes at 80000200, register at 80000300; 26 words are tried, on both sides of every boundary
- Output
fetches_allowed = 2, loads_allowed = 7, stores_allowed = 5, signature = 0xb4e836
The code is one instruction, and the data is one word of 4 bytes. The word after each of them is refused.
Constraints and Contract
- After the firmware has written your eight values, the user program can do exactly what the first table allows.
- The entries follow the PMP rules of the lesson. Entry 0 is asked first. An address word holds an address divided by 4.
- You choose which entry serves which region, and which address mode each one uses.
- The three regions never overlap. The code may be empty: code_top is then equal to code_base.
- The outputs depend only on the inputs of the same moment. The bench waits 1 ns after it sets the map.
Hints
Hint 1
Sort the three regions by shape first: which sizes are powers of two, and which are not?
Hint 2
A range needs two address words. Check what the entry below it must hold.
Hint 3
Try the smallest data size by hand before you trust your formula.
What the grader checks: Every data size from 4 bytes to 1 MiB in two places each; data at the top and at the bottom of the address space; code that is empty, one word long, at address 0, and right against the data; a register beside each region; 40 random maps. For each map the bench tries up to 40 words: the first and last word of every region, the words just outside, and a word one region size away.
94 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