V5.6.1 Test the Core's Boundary

HardVerify40 minap_soc v1.5 · assembly · serverReview the topic

Write the integration test of the core: every pin it shares with the chip, checked from inside. It passes on ap_soc and fails visibly on each faulty chip of a hidden set, all faults at the core's boundary.

Hardware context: The boundary pins of ap_rv32 in ap_soc v1.5: reset vector, hart ID, bus errors, interrupt lines, sleep. A boundary test against hidden faulty chips.

Write the test that proves the core is wired into the chip. It runs once on ap_soc and once on each chip of a hidden set. Each hidden chip has one fault at the core's boundary: between the core's pins and the rest of the chip. The model compare takes what crosses those pins from the record, so it misses most of them. Your test has to see them.

Check every pin from inside: where the core started and which hart it is. Check a bus error on every path an ERROR can take to the core, and each of the three interrupt lines. Check a sleep in wfi and its wake. A wait that never ends is not a catch: every wait needs a limit and a fail code.

Pass with the pass word when every check holds. A faulty chip is caught when your test ends with a fail word, or a check of the bench fails. A chip that passes your test, or runs to the cycle limit, is not caught.

Full specification
Pin of the coreChip-level questionHow a test can ask it
reset_vectorDid the core start where the BOOT strap says?auipc in SRAM; ap_sysctl STRAPS bit 0
hart_idIs this hart 0, the only one?mhartid
d_hresp (data port)Does an ERROR from any target become a load fault, cause 5, with mtval = the address?Load from HOLE (0x1000_7000): the fabric answers. Load ap_pwrctl REQUEST, which is write-only: the slow APB answers. Load from the Timer and PWM block while PD_PER is off: the power guard answers.
irq_softwareDoes MSIP reach the core's software line?MSIP = 1, mie bit 3: cause 0x8000_0003
irq_timerDoes MTIMECMP reach the timer line?MTIMECMP = MTIME + n, mie bit 7: cause 0x8000_0007
irq_externalDoes ap_plic reach the external line?GPIO pin 8 edge, ap_plic source 2, mie bit 11: cause 0x8000_000B
core_sleep, wakeDoes wfi sleep, and wake on the right line?wfi with the timer armed; a later pad pulse as a backstop
The bench, on requestEffect
TB_EVENT 5One pulse on IO8, at once
TB_EVENT 0x02dd_ddwpA pulse of w + 1 cycles on pad p after dddd cycles of the board's clock
The pass word ends the test; the bench answers nothing else
ap_pwrctl (0x1000_8000)Use
REQUEST 0x00, writeBit 0 SLEEP starts the switch-off of PD_PER (Timer and PWM, SPI); bit 1 WAKE starts the switch-on
STATUS 0x04, readBits 2:0: 0 on, 3 off; the steps between take a few cycles each

Three instructions are put in front of your program (TB_STATUS = 2, "main entered"). MTIMECMP resets to all ones, so writing its low word first is safe. ap_plic source 2 is GPIO.

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.
GPIO · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000DIR15:0valuerw0x0000regs1 turns the output driver of that pin on. One bit for each pin.
0x004IN15:0valueroblockThe pin levels, after two sampling flip-flops. One bit for each pin.
0x008OUT15:0valuerw0x0000regsThe saved output value. One bit for each pin.
0x00CSET15:0valuew1sacts on OUT.valueA 1 sets that bit of OUT. One bit for each pin.
0x010CLR15:0valuew1cacts on OUT.valueA 1 clears that bit of OUT. One bit for each pin.
0x014TGL15:0valuew1tacts on OUT.valueA 1 inverts that bit of OUT. One bit for each pin.
0x018IRQ_ENABLE15:0valuerw0x0000regsA 1 lets that pin's status bit raise interrupt source 2. One bit for each pin.
0x01CLEVEL_MODE15:0valuerw0x0000regs1: the pin is a level cause. 0: an edge cause. One bit for each pin.
0x020ACTIVE_HIGH15:0valuerw0xFFFFregs1: a high level, or a rising edge, is the event. One bit for each pin.
0x024STATUS15:0valuew1cblockRaw status. A written 1 clears the saved edge flag of that pin. One bit for each pin.
0x028MASKED_STATUS15:0valueroblockSTATUS AND IRQ_ENABLE. One bit for each pin.
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.
ap_sysctl · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000CHIP_ID31:0valuero0x2A5310C5constThe chip's identity: the IDCODE of the TAP. Fixed number.
0x004RESET_CAUSE0power_onroblockSticky record of reset sources since power-on. Power-on reset.
0x004RESET_CAUSE1pinroblockReset pin.
0x004RESET_CAUSE2watchdogroblockWatchdog.
0x004RESET_CAUSE3softwareroblockSoftware request.
0x004RESET_CAUSE4debugroblockDebug request.
0x008SOFT_RESET0timerwonot storedReset requests from software. 1 arms one restart of the timer.
0x008SOFT_RESET1chipwonot stored1 requests the software reset (new in v1.5).
0x00CSTRAPS0bootroblockStraps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM.
0x010PINMUX31:0selectrw0x00000000regsTwo bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n.
0x014CLK_GATE0uart0rw0x1regs1 lets that block's clock run (new in v1.5). UART0.
0x014CLK_GATE1gpiorw0x1regsGPIO.
0x014CLK_GATE2timerrw0x1regsTimer and PWM.
0x014CLK_GATE3spirw0x1regsSPI.
0x014CLK_GATE4dmarw0x1regsDMA.
0x018LOCK0pinmuxw1s0x0regsWrite-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes.
0x018LOCK1clk_gatew1s0x0regs1: CLK_GATE ignores writes.
0x018LOCK2debugw1s0x0regs1: the debug lock is closed.
0x020TB_STATUS31:0valuerw0x00000000regs (power-on reset only)Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage.
0x024TB_PUTC31:0valuerw0x00000000regs (power-on reset only)Scratch word 1. The firmware kit writes one character here. Plain storage.
0x028TB_EVENT31:0valuerw0x00000000regs (power-on reset only)Scratch word 2. The firmware kit writes an event number here. Plain storage.
0x02CTB_ARG31:0valuerw0x00000000regs (power-on reset only)Scratch word 3. A bench leaves a word for the firmware here. Plain storage.

Examples

Example 1

The Good Chip
Input
one run
Output
pass; traps 2 or more, interrupts 3 or more

Every pin answers. Three load faults carry the right mtval, three lines give their own causes, and the timer ends the wfi.

Example 2

A Line That Never Comes
Input
a hidden chip
Output
your fail word

The limit of the wait turns a missing interrupt into a fail code, not a hang.

Example 3

An Error That Never Comes
Input
a hidden chip
Output
your fail word

A load that should have faulted returned data. Counting the faults finds it.

Constraints and Contract

  • Assembly for the SRAM layout, with the names of defs.S.
  • One case, run on the good chip and on every hidden chip. The good chip must pass, take at least two traps and three interrupts.
  • The hidden set holds faults on five paths. They are the hart ID, the data port's error response, the power guard's ERROR, the timer line and the external line. No hidden chip breaks the reset vector, the software line or the wake from wfi. Check them anyway: the grader cannot see whether you do.

Hints

Hint 1

How many separate paths can an ERROR answer take to reach the core? Is a hole of the map the only one? What answers for a block whose power is off?

Hint 2

Three interrupt lines enter the core. Which of them does a test of one line say nothing about?

Hint 3

If the timer never wakes your wfi, what ends the sleep? Make that end a fail.

What the grader checks: Your test runs once on the good chip and once on each hidden faulty chip. The good chip must pass with at least two traps and three interrupts. Each faulty chip must end with a fail word or a bench check. The page says only whether a faulty chip passed. The hidden set covers five paths. They are the hart ID, the data port's error response, the power guard's ERROR, the timer line and the external line. It holds no fault at the software line. The chip does have faults at the reset vector and at the wake, but no test can catch them here. The program never starts, or never wakes, and a run that ends at the cycle limit does not count. So a test without those checks can be accepted, though it is incomplete for a real chip.

1 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 2 problems 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 Good Chip

Input
one run
Expected output
pass; traps 2 or more, interrupts 3 or more

Every pin answers. Three load faults carry the right mtval, three lines give their own causes, and the timer ends the wfi.

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

ap_soc v1.5 · assembly · server