V2.3.1 A Smoke That Touches Everything

MediumImplement35 minap_soc v1.5 · assembly · serverReview the topic

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
WindowBaseA value to check after reset
Boot ROM0x0000_0000This image leaves ROM empty: 0
ap_clint0x0200_0000MTIME at 0xBFF8 counts; MTIMECMP at 0x4000
ap_plic0x0C00_0000THRESHOLD at 0x20_0000 resets to 0
SRAM0x8000_0000What you write, you read back
UART00x1000_0000DIV at 0x10 resets to 16
GPIO0x1000_1000DIR at 0x00 resets to 0
Timer and PWM0x1000_2000RUN at 0x00 resets to 0
ap_sysctl0x1000_4000CHIP_ID at 0x00 is 0x2A53_10C5
SPI0x1000_5000STATUS at 0x04 resets to 0
DMA0x1000_6000STATUS at 0x14 resets to 0
Watchdog0x1000_3000Write-only registers; a write of fewer than four bytes is ignored
ap_pwrctl0x1000_8000STATUS 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
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000000MSIP0msiprw0x0blockMachine software interrupt request of hart 0. 1 raises the request.
0x004000MTIMECMP_LOW31:0valuerw0xFFFFFFFFblockLow word of mtimecmp. Compare value, low word.
0x004004MTIMECMP_HIGH31:0valuerw0xFFFFFFFFblockHigh word of mtimecmp. Compare value, high word.
0x00BFF8MTIME_LOW31:0valuerw0x00000000blockLow word of mtime. Time, low word.
0x00BFFCMTIME_HIGH31:0valuerw0x00000000blockHigh word of mtime. Time, high word.
ap_plic · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x004 + 4 × (n − 1), n = 1 to 16PRIORITY2:0levelrw0x0blockPriority of source n, 0 to 7. 0 never competes. Priority.
0x001000PENDING16:1sourcesroblockPending bits; bit number = source ID. One bit for each source.
0x002000ENABLE16:1sourcesrw0x0000blockEnable bits; bit number = source ID. One bit for each source.
0x200000THRESHOLD2:0levelrw0x0blockThe core sees a request only above this priority. Threshold.
0x200004CLAIM4:0idrw0x00blockRead: claim, returns the winner's ID and clears its pending bit. Write: complete, names the ID that is done. Source ID.
Watchdog · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000KEY31:0valuewonot stored0x51, then 0xA2 on the next watchdog write, unlocks one write to CONTROL. Key word.
0x004CONTROL31:0valuewonot storedWrite 1 while unlocked: armed. Arms once. 1 arms the watchdog.
0x008SERVICE31:0valuewonot storedWrite 1: the kick. 1 is a kick.
ap_pwrctl · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000REQUEST0sleepwonot storedStarts a power sequence of PD_PER. 1 starts the switch-off.
0x000REQUEST1wakewonot stored1 starts the switch-on.
0x004STATUS2:0stateroblockWhere the sequencer is, and the levels it drives. 0 on, 1 isolate, 2 save, 3 off, 4 switch on, 5 restore.
0x004STATUS4isolateroblockIsolation enable.
0x004STATUS5saveroblockRetention save level.
0x004STATUS6power_onroblockPower switch closed.
0x008WAKE_ENABLE0padrw0x0regsWhich events may wake PD_PER. The wake detector.
0x008WAKE_ENABLE1watchdogrw0x0regsThe watchdog's early warning.
0x00CWAKE_CAUSE0padw1cblockWhy the last wake happened. A written 1 clears a bit. The wake detector.
0x00CWAKE_CAUSE1watchdogw1cblockThe watchdog's early warning.
0x00CWAKE_CAUSE2softwarew1cblockREQUEST bit 1.
0x010IRQ_ENABLE2:0causerw0x0regsWhich 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

Report a problem with this page

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

The Region Map

Input
one smoke run
Expected output
visited = 0x1fff

Bits 0 to 11 are the twelve windows; bit 12 is the ERROR answer of the hole.

Run samples executes all 1 public checks. Check all tests runs 2 checks on the server.

ap_soc v1.5 · assembly · server