Where You May Look: Black, Grey and White Box
A chip check can look at the pads, at the boundaries between blocks, or inside a block. Each window sees a different part of a bug and costs a different amount to keep. Watch one wiring fault through all three, and learn which checks may read inside.
You Will Be Able To
- Place a chip check as black, grey or white box by where it looks.
- Say what each window tells you about a failure: that it failed, where, or what.
- Weigh the price of each: survival through RTL changes, use on emulators and silicon, effort to build.
- Choose the window for a new check on ap_soc.
- Lesson
- V2.4
- Time
- 24 min
- Runs on
- Your browser
- Check
- 5 questions
The test hangs until its cycle limit. The console is empty, the pass word never came, and the log says nothing else. Somewhere between a pin and a handler, one wire went to the wrong place. And the only window you opened was the one a customer has.
- Pads
- Peripheral
- Processor
- Bus
- Data
- Interrupt
- Black box: the pads
The bench sees what a board would: the pins, and what the firmware chooses to report. Nothing inside the chip is named.
- Grey box: the boundaries
Checks watch the wires and buses between blocks: the request into ap_plic, every AHB and APB transfer, the mailbox writes.
- White box: inside a block
Checks read flops inside a block, such as ap_plic's pending bits, or the core's own retire port.
Read the diagram as text
- Pads: UART line, GPIO pins, JTAG: black box
- GPIO: request wire out
- ap_plic: pending flops inside: white box
- Core: retire trace port: white box
- Buses and mailbox: AHB, APB, TB_STATUS: grey box
- Pads → GPIO: pin 8
- GPIO → ap_plic: request: grey box
- ap_plic → Core: external interrupt
- Core → Buses and mailbox: loads, stores
Probe points on ap_soc v1.5 for one interrupt. The names are those of the chip's RTL.
Before You Start
Read Interrupt Handlers in C and The Smoke Test as the Entry Gate first.
| Question | |
|---|---|
| 1 | Why does a chip check need to choose where it looks? |
| 2 | What can black, grey and white box checks each see? |
| 3 | What does each cost to keep? |
| 4 | What did each window show of one wiring fault? |
| 5 | Which checks may name signals inside a block? |
The Idea: Every Window Has a Price
A board has only pads, and so does silicon. A chip bench can do much more: it can name any wire and any flop of the RTL. That power is tempting, and it has a cost. A check that names pending_q breaks the day a designer renames it, and it can never run on the real chip.
So chip teams sort checks by where they look. Black-box checks use only the pads and what firmware reports. Grey-box checks watch the boundaries between blocks: buses, interrupt wires, the mailbox. White-box checks read inside a block. The deeper a check looks, the better it says where a bug is, and the more it costs to keep.
New Words
| Word | Meaning |
|---|---|
| Black-box check | A check that uses only the pads and what the firmware reports. |
| Grey-box check | A check on a boundary between blocks: a bus, an interrupt wire, a register write. |
| White-box check | A check that reads state inside a block: a flop, a state machine, the core's retire port. |
| Probe point | The signal a check reads, named by its path in the RTL. |
| Hierarchical name | The full path of a signal through the design, such as soc_tb.dut.u_plic.core.pending_q. |
| Passive | A check that only reads; it never drives a signal. |
The Smallest Example: Sort the Bench's Own Checks
The chip bench of this track already holds checks of all three kinds. Sort them by where they look.
| Check | Looks at | Window |
|---|---|---|
| UART model, GPIO sampler, JTAG host | The pads | Black |
| Self-checking firmware (pass or fail word) | What the program reports | Black |
| AHB and APB rule checkers | Every bus port between blocks | Grey |
| Mailbox monitor | Writes to four ap_sysctl registers | Grey |
| Block monitors: UART0, SPI, timer, DMA | The outputs of each block | Grey |
| Retire trace against the model | The core's own trace port | White |
| Back-door peek and poke | Flops of SRAM and named registers | White |
From the bench manual. The bench uses all three, each where it pays.
The Price of Each Window
| Black box | Grey box | White box | |
|---|---|---|---|
| Says about a failure | That it failed | Which boundary | Which flop or state |
| Survives an internal rename | Yes | Mostly: boundaries are named by the plan | No |
| Runs on an emulator | Yes | Usually | Only with care |
| Runs on silicon | Yes | Only through debug | No |
| Effort | Pad models | Reuse block monitors | Cheap to write, costly to keep |
A summary of common practice; module V3 builds each kind on this bench.
Read the table as a trade. Black-box checks are portable and robust, but a failure only says "something is wrong". White-box checks point at the exact flop, but they are tied to one version of the RTL. Grey box sits between, which is why most chip checks live there.
The Rules
Rule 1: Prove behaviour at the pads.
The final verdict of a use case is black box: what a board would see.
Rule 2: Localize at boundaries.
Put passive checks on buses and interrupt wires, the joins that chip bugs live on.
Rule 3: Look inside only for what the boundary cannot show.
The core's instruction results, a pending bit, a retained register.
Rule 4: Name white-box probes in one place.
One file of probe paths, so a rename is one edit, not fifty.
Rule 5: Stay passive.
A check that drives an internal signal tests a chip that does not exist.
Sources for These Rules
The bench and its checks: tools/soc/ap_soc/bench/soc_tb/README.md; docs/soc-verification-plan.md 3.4.
Passive block monitors reused at chip level: plan section 2.1 (vertical reuse); UVM Cookbook, testbench architecture.
Black, grey and white box testing: common practice; not tied to one book of the library.
Now Run It: One Fault, Three Windows
The interrupt lab from the lesson on handlers ran twice, on an Icarus build of the bench with a probe. It ran once on the chip, and once on a copy with one line changed. The change is fault Q072 of the chip's seeded-fault set: "PLIC source two samples the SPI interrupt". In the generated interrupt map, assign irq[2] = irq_2; became assign irq[2] = irq_4;.
good chip: verdict=pass reason=pass interrupts=3 ext_gpio=3
fault Q072: verdict=fail reason=cycle_limit interrupts=0 cycles=30008The black-box window says only this: the faulty chip never finished. The console is empty and no interrupt was taken. Was it the GPIO block, the pin, ap_plic, the core, the handler? Rule 1 found the bug, but cannot name its place.
good: WIRE 276 gpio_irq=1
good: WIRE 276 plic_in2=1
good: WIRE 277 pending2=1
good: WIRE 277 meip=1
good: WIRE 282 trap mcause=8000000b
Q072: WIRE 276 gpio_irq=1On the good chip, gpio_irq rose at cycle 276, and ap_plic's input 2 followed in the same cycle. Its pending flop and the core's interrupt followed one cycle later. On the faulty chip, gpio_irq rose and nothing else ever moved. The grey-box window says where: between the GPIO block and ap_plic, rule 2. The white-box line, pending2, confirms that ap_plic never saw the request.
Why It Is Built This Way
Why not make every check white box, since it says the most? Because ap_soc will change. Every renamed flop would break a check, and none of them could follow the firmware onto an emulator or the first silicon. The bench keeps white-box looks for what nothing else can see.
The chip's seeded faults show both sides. Of 130 faults, firmware tests caught 105 and passive checkers 33; a fault can be caught by both. Six ALU faults reached the pass word. Only the model compare caught them: a white-box window into the core. Nine others left every read right, for example a bus bit that no register keeps. Only a grey-box checker, watching a bus or the reset lines between blocks, saw them.
The Trap: The Probe That Outlives Its Signal
A white-box check reads u_plic.core.pending_q[2]. Months later a designer restructures ap_plic, and the flop becomes gate_q[2]. If the old name is gone, the bench stops compiling, and someone must hunt down every probe. If a new flop later takes the old name with another meaning, the check compiles and quietly watches the wrong thing.
Either way the cost lands on verification, not on the designer. Keep white-box probes few, in one file, and checked by a test that fails when a probe stops moving. The practice problems ask you to choose windows for new checks, and to write a grey-box checker of your own.
At Scale
This section looks ahead. ap_soc has one interrupt controller and a dozen blocks.
Bound checkers
SystemVerilog bind places a checker inside a block without editing its RTL. Module V3 binds the block monitors of this chip that way.
Assertions at boundaries
Grey-box checks are often assertions on interfaces, written by the block team and switched on at chip level.
Silicon
On real chips only the pads and the debug port remain. Tests that are black box from the start move to the lab bench with no change.
Try It
Run the slice: it checks the recorded wire events of the good chip.
Change the check so plic_in2 may follow one cycle later. Does the good chip still pass?
Feed it the faulty chip's events (the predict question below) before you look at the answer.
cycle 276: gpio_irq rose and plic_in2 followed cycle 482: gpio_irq rose and plic_in2 followed wire check: 0 errorsCheck Yourself
Common Mistakes
Wrong Name internal flops in every check.
Each rename breaks them, and none can run on silicon.
Fix Check at the pads and boundaries; look inside only where they cannot see.
Wrong Rely only on the pass word.
Six of the chip's seeded ALU faults reach the pass word.
Fix Add grey-box checkers and the model compare.
Wrong Let a check drive an internal signal to make a test easier.
The test then exercises a chip that does not exist.
Fix Keep checks passive; drive only pads, or use the bus-manager seat.
Remember
- Black box: the pads and the firmware's report. Grey box: boundaries between blocks. White box: inside a block.
- Deeper windows locate bugs better and cost more to keep; white-box checks cannot run on silicon.
- One wiring fault: black box saw a hang, grey box saw where, white box confirmed inside ap_plic.
- Keep checks passive, keep white-box probes few and in one place.