Write the smoke test that guards the regression. It checks a reset value in every window of the map and reads a hole. It takes one interrupt and sends one byte out of a pad.
Hardware context: The smoke test that gates the regression of ap_soc v1.5. Accepting or refusing an RTL drop.
Write the smoke test that gates the regression of ap_soc, in assembly. It must touch every one of the twelve device windows of the map. Where a window has a value worth checking, it checks it. It must read one hole of the map, expect ERROR, and survive it.
It must also take one interrupt and send the byte S (0x53) out of the UART TX pad, IO0. Then print smoke ok on the console and write the pass word. On any failed check, write a fail word instead.
Full specification
| Window | Base | A value to check after reset |
|---|---|---|
| Boot ROM | 0x0000_0000 | This image leaves ROM empty: 0 |
| ap_clint | 0x0200_0000 | MTIME at 0xBFF8 counts; MTIMECMP at 0x4000 |
| ap_plic | 0x0C00_0000 | THRESHOLD at 0x20_0000 resets to 0 |
| SRAM | 0x8000_0000 | What you write, you read back |
| UART0 | 0x1000_0000 | DIV at 0x10 resets to 16 |
| GPIO | 0x1000_1000 | DIR at 0x00 resets to 0 |
| Timer and PWM | 0x1000_2000 | RUN at 0x00 resets to 0 |
| ap_sysctl | 0x1000_4000 | CHIP_ID at 0x00 is 0x2A53_10C5 |
| SPI | 0x1000_5000 | STATUS at 0x04 resets to 0 |
| DMA | 0x1000_6000 | STATUS at 0x14 resets to 0 |
| Watchdog | 0x1000_3000 | Write-only registers; a write of fewer than four bytes is ignored |
| ap_pwrctl | 0x1000_8000 | STATUS at 0x04 reads 0x40 when the domain is on |
The bench's region map sets a bit for each window your program touches. It sets bit 12 when the core gets an ERROR answer. The names of the bases (ROM, CLINT, PLIC, SRAM, UART, GPIO, TIMER, WDOG, SYSCTL, SPI, DMA, HOLE, PWRCTL) are defined for you.
Given Files
Read-only files supplied by the bench.
defs.S
# defs.S: addresses and helpers of the smoke programs of ap_soc v1.5 (stage E4).
# check-soc-top.mjs puts this text in front of every program. Numbers: gen/ap_soc_regs.h.
.equ ROM, 0x00000000
.equ CLINT, 0x02000000
.equ PLIC, 0x0C000000
.equ UART, 0x10000000
.equ GPIO, 0x10001000
.equ TIMER, 0x10002000
.equ WDOG, 0x10003000
.equ SYSCTL, 0x10004000
.equ SPI, 0x10005000
.equ DMA, 0x10006000
.equ HOLE, 0x10007000
.equ PWRCTL, 0x10008000
.equ SRAM, 0x80000000
.equ TB_STATUS, 0x20
.equ TB_PUTC, 0x24
.equ TB_EVENT, 0x28
.equ TB_ARG, 0x2C
ap_clint · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000000 | MSIP | 0 | msip | rw | 0x0 | block | Machine software interrupt request of hart 0. 1 raises the request. |
0x004000 | MTIMECMP_LOW | 31:0 | value | rw | 0xFFFFFFFF | block | Low word of mtimecmp. Compare value, low word. |
0x004004 | MTIMECMP_HIGH | 31:0 | value | rw | 0xFFFFFFFF | block | High word of mtimecmp. Compare value, high word. |
0x00BFF8 | MTIME_LOW | 31:0 | value | rw | 0x00000000 | block | Low word of mtime. Time, low word. |
0x00BFFC | MTIME_HIGH | 31:0 | value | rw | 0x00000000 | block | High word of mtime. Time, high word. |
## ap_clint (base 0x0200_0000, clk_sys, PD_MAIN) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000000` | MSIP | 0 | msip | rw | `0x0` | block | Machine software interrupt request of hart 0. 1 raises the request. | | `0x004000` | MTIMECMP_LOW | 31:0 | value | rw | `0xFFFFFFFF` | block | Low word of mtimecmp. Compare value, low word. | | `0x004004` | MTIMECMP_HIGH | 31:0 | value | rw | `0xFFFFFFFF` | block | High word of mtimecmp. Compare value, high word. | | `0x00BFF8` | MTIME_LOW | 31:0 | value | rw | `0x00000000` | block | Low word of mtime. Time, low word. | | `0x00BFFC` | MTIME_HIGH | 31:0 | value | rw | `0x00000000` | block | High word of mtime. Time, high word. |
ap_plic · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x004 + 4 × (n − 1), n = 1 to 16 | PRIORITY | 2:0 | level | rw | 0x0 | block | Priority of source n, 0 to 7. 0 never competes. Priority. |
0x001000 | PENDING | 16:1 | sources | ro | block | Pending bits; bit number = source ID. One bit for each source. | |
0x002000 | ENABLE | 16:1 | sources | rw | 0x0000 | block | Enable bits; bit number = source ID. One bit for each source. |
0x200000 | THRESHOLD | 2:0 | level | rw | 0x0 | block | The core sees a request only above this priority. Threshold. |
0x200004 | CLAIM | 4:0 | id | rw | 0x00 | block | Read: claim, returns the winner's ID and clears its pending bit. Write: complete, names the ID that is done. Source ID. |
## ap_plic (base 0x0C00_0000, clk_sys, PD_MAIN) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x004` + 4 × (n − 1), n = 1 to 16 | PRIORITY | 2:0 | level | rw | `0x0` | block | Priority of source n, 0 to 7. 0 never competes. Priority. | | `0x001000` | PENDING | 16:1 | sources | ro | | block | Pending bits; bit number = source ID. One bit for each source. | | `0x002000` | ENABLE | 16:1 | sources | rw | `0x0000` | block | Enable bits; bit number = source ID. One bit for each source. | | `0x200000` | THRESHOLD | 2:0 | level | rw | `0x0` | block | The core sees a request only above this priority. Threshold. | | `0x200004` | CLAIM | 4:0 | id | rw | `0x00` | block | Read: claim, returns the winner's ID and clears its pending bit. Write: complete, names the ID that is done. Source ID. |
Watchdog · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | KEY | 31:0 | value | wo | not stored | 0x51, then 0xA2 on the next watchdog write, unlocks one write to CONTROL. Key word. | |
0x004 | CONTROL | 31:0 | value | wo | not stored | Write 1 while unlocked: armed. Arms once. 1 arms the watchdog. | |
0x008 | SERVICE | 31:0 | value | wo | not stored | Write 1: the kick. 1 is a kick. |
## Watchdog (base 0x1000_3000, interrupt source 6, clk_aon, PD_AON) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | KEY | 31:0 | value | wo | | not stored | 0x51, then 0xA2 on the next watchdog write, unlocks one write to CONTROL. Key word. | | `0x004` | CONTROL | 31:0 | value | wo | | not stored | Write 1 while unlocked: armed. Arms once. 1 arms the watchdog. | | `0x008` | SERVICE | 31:0 | value | wo | | not stored | Write 1: the kick. 1 is a kick. |
ap_pwrctl · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | REQUEST | 0 | sleep | wo | not stored | Starts a power sequence of PD_PER. 1 starts the switch-off. | |
0x000 | REQUEST | 1 | wake | wo | not stored | 1 starts the switch-on. | |
0x004 | STATUS | 2:0 | state | ro | block | Where the sequencer is, and the levels it drives. 0 on, 1 isolate, 2 save, 3 off, 4 switch on, 5 restore. | |
0x004 | STATUS | 4 | isolate | ro | block | Isolation enable. | |
0x004 | STATUS | 5 | save | ro | block | Retention save level. | |
0x004 | STATUS | 6 | power_on | ro | block | Power switch closed. | |
0x008 | WAKE_ENABLE | 0 | pad | rw | 0x0 | regs | Which events may wake PD_PER. The wake detector. |
0x008 | WAKE_ENABLE | 1 | watchdog | rw | 0x0 | regs | The watchdog's early warning. |
0x00C | WAKE_CAUSE | 0 | pad | w1c | block | Why the last wake happened. A written 1 clears a bit. The wake detector. | |
0x00C | WAKE_CAUSE | 1 | watchdog | w1c | block | The watchdog's early warning. | |
0x00C | WAKE_CAUSE | 2 | software | w1c | block | REQUEST bit 1. | |
0x010 | IRQ_ENABLE | 2:0 | cause | rw | 0x0 | regs | Which wake causes raise interrupt source 9. Numbered as WAKE_CAUSE. |
## ap_pwrctl (base 0x1000_8000, interrupt source 9, clk_aon, PD_AON) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | REQUEST | 0 | sleep | wo | | not stored | Starts a power sequence of PD_PER. 1 starts the switch-off. | | `0x000` | REQUEST | 1 | wake | wo | | not stored | 1 starts the switch-on. | | `0x004` | STATUS | 2:0 | state | ro | | block | Where the sequencer is, and the levels it drives. 0 on, 1 isolate, 2 save, 3 off, 4 switch on, 5 restore. | | `0x004` | STATUS | 4 | isolate | ro | | block | Isolation enable. | | `0x004` | STATUS | 5 | save | ro | | block | Retention save level. | | `0x004` | STATUS | 6 | power_on | ro | | block | Power switch closed. | | `0x008` | WAKE_ENABLE | 0 | pad | rw | `0x0` | regs | Which events may wake PD_PER. The wake detector. | | `0x008` | WAKE_ENABLE | 1 | watchdog | rw | `0x0` | regs | The watchdog's early warning. | | `0x00C` | WAKE_CAUSE | 0 | pad | w1c | | block | Why the last wake happened. A written 1 clears a bit. The wake detector. | | `0x00C` | WAKE_CAUSE | 1 | watchdog | w1c | | block | The watchdog's early warning. | | `0x00C` | WAKE_CAUSE | 2 | software | w1c | | block | REQUEST bit 1. | | `0x010` | IRQ_ENABLE | 2:0 | cause | rw | `0x0` | regs | Which wake causes raise interrupt source 9. Numbered as WAKE_CAUSE. |
Examples
Example 1
The Region Map- Input
one smoke run
- Output
visited = 0x1fff
Bits 0 to 11 are the twelve windows; bit 12 is the ERROR answer of the hole.
Example 2
The Interrupt and the Pad- Input
one smoke run
- Output
interrupts >= 1, uart_bytes = 1 (the byte S)
The machine timer raises one interrupt; the UART sends one frame out of pad IO0.
Example 3
The Console- Input
one smoke run
- Output
console: "smoke ok\n", then the pass word
The line comes only after every check passed. A failed check writes a fail word instead.
Constraints and Contract
- Assembly for the SRAM layout.
- Graded: the pass word,
smoke ok, all thirteen region bits, at least one interrupt, and exactly the byte S on the UART pad. - A private run changes one value of the table by the back door before your smoke reads it. There your smoke must write a fail word.
Hints
Hint 1
Set mtvec before the first access that can fail.
Hint 2
A handler for a load fault must return past the faulting load.
Hint 3
The machine timer needs only ap_clint and two CSR bits.
What the grader checks: Two runs of the chip. The public run is graded by the bench's region map, its interrupt count and the UART pad. The private run changes one checked value and expects a fail word. The bench cannot see which values your program compares. A smoke that checks only some windows may still pass, so check every one. The region map cannot tell which address answered ERROR either. Reading the hole is your part of the bargain.
2 checks on ap_soc v1.5 · assembly · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your text only; the chip, the bench and the hidden checks stay on the server. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 problem on this path