Core Integration Checks
The core arrives proved, and the model compare checks every instruction. Neither can see how the core is wired into the chip. This page lists the core's boundary pins, the question each one carries, and runs a test that the model compare cannot replace.
You Will Be Able To
- List the core's boundary pins and the chip-level question of each.
- Explain why the model compare is silent on a wiring fault at the core's pins.
- Write a pin check with a limit and a fail code.
- Plan a check for every boundary question, including each error path and the sleep.
- Lesson
- V5.6
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
The model compare ran every record of a test and found nothing. The test still failed, with its own fail code: an interrupt never came. Both statements are true at once, and the reason is the point of this page.
- Processor
- Clock / reset
- Bus
- Peripheral
- Power
- Debug
- Clock
- Data
- Interrupt
- Power
- Debug
- reset_vector
Where does the first instruction come from?
- hart_id
Which hart is this?
- d_hresp, i_hresp
Does every ERROR become a precise trap?
- irq_software, irq_timer
Do MSIP and MTIMECMP reach their lines?
- irq_external
Does ap_plic reach the external line?
- core_sleep, core_wake
Does wfi sleep, and wake on the right line?
Read the diagram as text
- ap_rv32: proved on its own bench
- reset_vector, hart_id: strap and tie-off
- i_ and d_ ports: hresp: an ERROR from any target
- Three interrupt lines: ap_clint and ap_plic
- core_sleep, wake: wfi
- Debug port: halt, step, registers
- reset_vector, hart_id → ap_rv32: at reset
- i_ and d_ ports → ap_rv32: answers
- Three interrupt lines → ap_rv32: lines
- ap_rv32 → core_sleep, wake: sleeps
- Debug port → ap_rv32: requests
ap_core_slot of ap_soc v1.5 (tools/soc/ap_soc/rtl/ap_core_slot.sv lists every port). The debug port is module V11's.
Before You Start
Read Interrupts and the Model first. Where You May Look helps too. The Core as an IP lists the ports from the core's side.
| Question | |
|---|---|
| 1 | What does the core's own bench prove, and what can it not? |
| 2 | Which pins does the core share with the chip? |
| 3 | Why is the model compare silent on a fault at a pin? |
| 4 | What makes a pin check catch a fault rather than hang? |
| 5 | Why does every sleep in a pin check need a backstop? |
The Idea: A Proved Core in an Unproved Chip
The core's own bench drives every pin of the core and checks it against the ISA. It cannot know what the chip connects to those pins. Take a reset vector tied to the wrong value, or a timer wire crossed with the software line. Take an error answer that never reaches the core. Each is a chip bug in a proved core.
The model compare cannot see them either. It takes what crosses the pins from the record: the device's answer, the error, the lines the core sampled. A wrong wire changes what the core sees, and the model agrees with the core about what it saw.
So the pins are checked by tests that ask for an effect and check it. Raise a line, and wait for the trap of that line. Read a hole, and check the fault and its address. Each pin gets its question, and each question gets a limit.
New Words
| Word | Meaning |
|---|---|
| Boundary pin | A port of the core that the chip connects to something: a strap, a bus, an interrupt line, a sleep signal. |
| Integration check | A test of how a block is wired into the chip, not of the block itself. |
| Precise trap | A trap with mepc at the instruction that caused it and nothing after it done. |
| Backstop | A second event armed to end a wait whose first event may never come. |
| Tie-off | A port fixed to a constant at the top level, such as the hart ID. |
The Smallest Example: One Pin, One Question
Take the external line. On the good chip, the board pulses IO8 and GPIO raises source 2. Then ap_plic raises the core's external line, and the core traps with cause 0x8000_000B. A test asks for exactly that, and gives up after a limit.
| The test sees | It means | The test does |
|---|---|---|
| cause 0x8000_000B within the limit | the line works | goes on |
| another cause | a line is crossed | fails with code 4 |
| nothing within the limit | the line, the source or the map is broken | fails with code 3 |
The fail codes of the lab program BOUNDARY_S.
The Rules
Rule 1: Give every pin its own question.
A test of the external line says nothing about the timer line.
Rule 2: Check the effect, with its exact cause.
Wait for the mcause of the line raised, not for any trap.
Rule 3: Every wait has a limit and a code.
And every wfi has a backstop on another line.
Rule 4: Check every path of an error.
A hole of the map, a register block behind each bridge and a block whose power is off answer through different logic.
Rule 5: Do not leave the pins to the model.
It takes the pins' values from the record, so it cannot check them.
Sources for These Rules
The core's ports in the chip: tools/soc/ap_soc/rtl/ap_core_slot.sv; who drives them: tools/soc/ap_soc/connect.csv. The reset vector from the BOOT strap and STRAPS in ap_sysctl: docs/soc/ap_soc-facts.md 27.3 and 27.11. The error rule of every register block: facts 27.6.
The interrupt lines and causes: blueprint 7.4; mie bits 3, 7 and 11. ap_plic source 2 is GPIO (tools/soc/ap_soc/irq.csv).
What the model takes from the record: facts 27.12. The fault of the lab is a seeded fault of stage E9 (docs/soc/fault-table.md), also shown in lesson V2.4.
Now Run It: Three Pins, Two Chips
The lab checks three pins. The reset vector, by the BOOT strap and auipc; the hart ID; and the external line, through GPIO and ap_plic. It is part of an integration test, not the whole of one.
auipc a0, 0 # where is the core running?
la t0, trap
csrw mtvec, t0
li s0, SYSCTL
li a7, 1
lw t1, 0x0C(s0) # STRAPS: bit 0 is the BOOT strap as sampled
andi t1, t1, 1
beqz t1, fail # this bench boots from SRAM: BOOT = 1
srli t2, a0, 16
li t1, 0x8000
bne t2, t1, fail # ... so the core must be running in SRAM, not in the boot ROMgood chip: pass, 105 cycles, external interrupts 1, 60 records compared, mismatches 0
first record at 80000000; auipc at 8000000cplic source two samples the spi interrupt: fail, status_fail, TB_STATUS bad00003, 2573 cycles
external interrupts 0, 1542 records compared, mismatches 0The test failed with code 3: no external interrupt within its limit. The model compared all 1542 records and found nothing. The core and the model both saw a line that never rose: rule 5. The limit turned the missing line into a report: rule 3.
The pins this lab left unchecked are the work of the practice problem. They are every path of an error, the other two lines, and a bounded sleep.
Why It Is Built This Way
Pin checks are firmware, not bench monitors, because the question is whether the core sees the chip right. Only code running on the core can ask for an effect and see it as the core sees it. It sees a trap, a cause, an mtval.
They are few and short. One check a pin, a few hundred cycles each, run in every regression. They find the faults the model compare cannot, at a cost the run hardly notices. The lab's check of three pins took 105 cycles on the good chip.
A real integration test checks every pin, even where a check seems unable to fail. A core that starts at the wrong address, or never wakes from wfi, runs no test at all. Only the bench's end rules see that run, as a cycle limit. Write the checks anyway. A smaller fault on the same pin lets the program run, and then only your check sees it.
The Trap: The Wait That Hid the Wire
A first integration test waits for each interrupt in a loop with no exit. On a chip with a broken line it runs to the cycle limit. The report says "cycle limit", the regression marks it a timeout, and someone raises the limit.
The cure is a limit and a code on every wait, and a backstop on every sleep. The practice problems build the whole test against hidden faulty chips. They also read a recorded run in which two external sources asked at once, and the test failed.
At Scale
This section looks ahead. ap_soc has one core, three lines and two bus ports.
Many harts
Each hart has its own ID, lines and reset; the checks repeat per hart, generated from the integration table.
Generated checks
Large chips generate these tests from the connection list, the same data the formal connectivity proofs of module V8 use.
Cores from outside
A licensed core arrives with its own proofs; the integrator owns only the wiring, and these checks.
Try It
Run the slice: it lists the core's pins and whether the lab's test checks each one.
Which pins does the lab leave unchecked?
The predict question marks the interrupt lines as checked.
reset_vector started in SRAM, as the BOOT strap says hart_id mhartid is 0 d_hresp NOT CHECKED irq_software NOT CHECKED irq_timer NOT CHECKED irq_external ap_plic raises cause 11, within a limit core_sleep and wake NOT CHECKED debug port NOT CHECKED 3 of 8 pins checkedCheck Yourself
Common Mistakes
Wrong Trust the model compare with the core's pins.
The model takes the pins' values from the record, so a wrong wire looks right to it.
Fix Test each pin with an effect and its exact cause.
Wrong Wait for an interrupt with no limit.
A missing line becomes a cycle limit that names nothing.
Fix Give every wait a limit and a fail code; give wfi a backstop.
Wrong Test bus errors on one path.
Each bridge and the default target answer through their own logic.
Fix Read a hole and a register on each bus segment.
Remember
- A proved core can still be wired wrong; each pin it shares with the chip has a chip-level question.
- The model compare takes the pins' values from the record, so it cannot check them.
- Check every pin with its exact effect, every wait with a limit, every sleep with a backstop.
- Errors travel several paths into the core; test each one.