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.

Where a Check May LookStep through the three places a chip check can look. Each one sees more, and costs more to keep.
  • Pads
  • Peripheral
  • Processor
  • Bus
  • Data
  • Interrupt
Where a Check May LookStep through the three places a chip check can look. Each one sees more, and costs more to keep. pads Pads UART line, GPIO pins,JTAG: black box peripheral GPIO request wire out peripheral ap_plic pending flops inside:white box processor Core retire trace port:white box bus Buses and mailbox AHB, APB,TB_STATUS: greybox pin 8request: grey boxexternal interruptloads, stores
  1. pads PadsUART line, GPIO pins, JTAG: black box
    • pin 8 → GPIO
  2. bus Buses and mailboxAHB, APB, TB_STATUS: grey box
  3. peripheral GPIOrequest wire out
    • request: grey box → ap_plic
  4. peripheral ap_plicpending flops inside: white box
    • external interrupt → Core
  5. processor Coreretire trace port: white box
    • loads, stores → Buses and mailbox
  1. 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.

  2. 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.

  3. 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.

Five questions this page answers
Question
1Why does a chip check need to choose where it looks?
2What can black, grey and white box checks each see?
3What does each cost to keep?
4What did each window show of one wiring fault?
5Which 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

New words on this page
WordMeaning
Black-box checkA check that uses only the pads and what the firmware reports.
Grey-box checkA check on a boundary between blocks: a bus, an interrupt wire, a register write.
White-box checkA check that reads state inside a block: a flop, a state machine, the core's retire port.
Probe pointThe signal a check reads, named by its path in the RTL.
Hierarchical nameThe full path of a signal through the design, such as soc_tb.dut.u_plic.core.pending_q.
PassiveA 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.

The checks of soc_tb, by window
CheckLooks atWindow
UART model, GPIO sampler, JTAG hostThe padsBlack
Self-checking firmware (pass or fail word)What the program reportsBlack
AHB and APB rule checkersEvery bus port between blocksGrey
Mailbox monitorWrites to four ap_sysctl registersGrey
Block monitors: UART0, SPI, timer, DMAThe outputs of each blockGrey
Retire trace against the modelThe core's own trace portWhite
Back-door peek and pokeFlops of SRAM and named registersWhite

From the bench manual. The bench uses all three, each where it pays.

The Price of Each Window

What each window costs
Black boxGrey boxWhite box
Says about a failureThat it failedWhich boundaryWhich flop or state
Survives an internal renameYesMostly: boundaries are named by the planNo
Runs on an emulatorYesUsuallyOnly with care
Runs on siliconYesOnly through debugNo
EffortPad modelsReuse block monitorsCheap 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

  1. Rule 1: Prove behaviour at the pads.

    The final verdict of a use case is black box: what a board would see.

  2. Rule 2: Localize at boundaries.

    Put passive checks on buses and interrupt wires, the joins that chip bugs live on.

  3. Rule 3: Look inside only for what the boundary cannot show.

    The core's instruction results, a pending bit, a retained register.

  4. Rule 4: Name white-box probes in one place.

    One file of probe paths, so a rename is one edit, not fifty.

  5. 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;.

Black box: the result blocks.
good chip:   verdict=pass reason=pass interrupts=3 ext_gpio=3
fault Q072: verdict=fail reason=cycle_limit interrupts=0 cycles=30008

The 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.

Grey and white box: the probe's wire events (cycle, signal, level).
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=1

On 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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has one interrupt controller and a dozen blocks.

  1. 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.

  2. Assertions at boundaries

    Grey-box checks are often assertions on interfaces, written by the block team and switched on at chip level.

  3. 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.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: cycle 276: gpio_irq rose and plic_in2 followed cycle 482: gpio_irq rose and plic_in2 followed wire check: 0 errors

Check Yourself

Predict the outputThe slice now reads the wire events of the chip with fault Q072. What is the last line it prints?
// Wire events one chip run recorded: the GPIO block's request and ap_plic's input 2, with the cycle.
// A grey-box check: a rise of gpio_irq must show at plic_in2 in the same cycle.
module tb;
  localparam int N = 1;
  int    cycle [N];
  string wire_name [N];
  bit    level [N];
  int    pending = -1, errors = 0;
  initial begin
    cycle[0] = 276; wire_name[0] = "gpio_irq"; level[0] = 1;
    for (int i = 0; i < N; i++) begin
      if (wire_name[i] == "gpio_irq" && level[i]) pending = cycle[i];
      if (wire_name[i] == "plic_in2" && level[i]) begin
        if (pending == cycle[i]) $display("cycle %0d: gpio_irq rose and plic_in2 followed", cycle[i]);
        pending = -1;
      end
      if (pending >= 0 && (i == N - 1 || cycle[i + 1] != pending)) begin
        $display("cycle %0d: gpio_irq rose, plic_in2 did not follow", pending);
        errors++;
        pending = -1;
      end
    end
    $display("wire check: %0d errors", errors);
  end
endmodule
ConceptWhich window can tell you that the GPIO request never reached ap_plic?
ConceptWhich check keeps working after a designer renames flops inside ap_plic?
ConceptWhy is most chip checking grey box?
ConceptSix seeded ALU faults reached the pass word. Which window caught them?

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.

Practice

Report a problem with this page