TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

White Box Testing vs Black Box Testing in Verification

The Editor's Desk
by
0
Share Facebook X LinkedIn WhatsApp Email

When performing verification, the target device can be viewed as a white box or a black box. During white-box testing, detailed knowledge is available describing the internal workings of the device to be tested. This knowledge can be used to direct the verification effort. During black-box testing, it is assumed that there is no visibility into the internal workings of the device being tested.

White-box testing

An engineer verifying a digital circuit may have schematics, block diagrams, RTL code that may or may not be suitably annotated, and textual descriptions including timing diagrams and state transition graphs. All or a subset of these can be used to advantage when developing test programs. The logic designer responsible for the correctness of the design, armed with knowledge of the internal workings of the design, writes stimuli based on this knowledge; hence he or she is performing white-box testing.

In practice, white-box verification means you can look inside: you can probe internal signals, put assertions on a state machine, check that a FIFO never overflows, and measure which lines and branches of the RTL your tests have exercised.

Black-box testing

During black-box testing, a functional description exists which outlines, in more or less detail, how the device must respond to various externally applied stimuli. This description, or specification, may or may not describe the behavior of the device in the presence of all possible combinations of inputs. For example, a microprocessor may have op-code combinations that are left unused and unspecified. From one release to the next, these unused op-codes may respond very differently if invoked.

PCB designers, concerned with obtaining ICs that work correctly with other ICs plugged into the same PCB or backplane, are most likely to perform black-box testing, unless they are able to persuade their vendor to provide them with more detailed information.

The difference in one table

White boxBlack box
What you can seeRTL, schematics, internal signalsOnly the pins or the transaction-level interface
Tests are written fromThe implementation and the specThe spec alone
Typical authorThe designer, or a verification engineer with RTL accessAn independent verification team, a system or board team, a customer
Strong at findingCorner cases in the logic: counters wrapping, FIFO full, arbitration tiesMisreadings of the spec, interface and integration problems
Main riskTesting what the design does instead of what it should doMissing internal corner cases that the spec does not mention

Why most teams use both

The designer who wrote the RTL tends to test the cases they thought of while writing it. If they misread the specification, their tests will share the same misreading and pass. A black-box test written by someone else, from the specification alone, catches that kind of error. On the other hand, a black-box tester cannot know that an internal counter wraps at 255 or that two requests can collide in one cycle, so internal corner cases are best found with white-box knowledge.

Modern verification blends the two. The testbench drives and checks the design through its interfaces, which is black-box style, while assertions and coverage points inside the design add white-box visibility. This mix is sometimes called gray-box verification.

Deep dive: the numbers and details

This part holds the techniques used in each style, how coverage ties them together, a worked example and common interview questions. Skip it if the overview is all you need.

White-box techniques

  • Code coverage: line, branch (or block), condition, toggle and FSM state and transition coverage, collected by the simulator from the RTL. It tells you which parts of the implementation were never exercised.
  • Internal assertions: properties written against internal signals, for example "the FIFO write pointer never passes the read pointer" or "the grant vector is always one-hot".
  • Directed corner-case tests: tests aimed at a known structure, such as wrapping a counter, filling a FIFO exactly to its depth, or hitting every arc of a state machine.
  • Formal property checking: proving assertions on the internal logic for all input sequences, not just the simulated ones.

Black-box techniques

  • Specification-driven test plans: each feature in the specification becomes a test item, written without reference to the RTL.
  • Reference models and scoreboards: a model written from the specification predicts the expected outputs; the scoreboard compares them with the device's outputs.
  • Constrained-random stimulus at the interfaces: legal transactions generated at random within the protocol rules.
  • Functional coverage: covergroups defined from the specification, for example every packet length class crossed with every priority level.
  • Protocol compliance suites: standard tests for buses and interfaces, run against the device as a black box.

How coverage connects the two

Functional coverage and code coverage answer different questions, and comparing them shows which style has a gap:

Functional coverageCode coverageWhat it usually means
HighHighGood progress; look for missing items in the plan itself
HighLowLogic exists that the specification-driven tests never reach: dead code, or features missing from the plan
LowHighThe RTL is exercised but key scenarios from the spec are not; white-box tests may be passing on the wrong behavior
LowLowEarly in the project; more stimulus needed

Worked example: a 16-entry FIFO

Black-box view: the specification says the FIFO has 16 entries, asserts FULL when 16 words are stored, ignores writes when full and returns data in order. A black-box test writes random data at random times, reads it back, and checks order and the FULL and EMPTY flags against a reference queue in the testbench.

White-box view: the designer knows the pointers are 5 bits wide, with the extra bit used to tell full from empty. Extra tests and assertions target what the black-box test might hit only by luck:

  • Pointer wrap: at least 32 writes and reads so that both pointers wrap through all values.
  • Simultaneous read and write when the FIFO is full and when it is empty.
  • An assertion that the stored count is always between 0 and 16.
  • Toggle coverage on every pointer bit, including the wrap bit.

A random black-box test with balanced reads and writes rarely keeps a 16-entry FIFO full for long, so the "write while full" case may get only a handful of hits in thousands of cycles. A white-box coverage point on that condition makes the gap visible, and a directed test or a constraint change closes it.

The unused op-code problem in detail

The microprocessor example above is worth expanding, because it shows the limit of black-box testing. If a specification marks some op-codes as reserved without saying what happens when they are executed, a black-box tester has no expected result to check. Two releases of the same processor can both meet the specification and still behave differently. Good practice is to make the specification complete, for example by requiring an illegal-instruction exception for every reserved op-code, so that the behavior can be tested from outside.

Interview questions on this topic

  • Is a UVM testbench white box or black box? Mostly black box: it drives and monitors the design through interface agents. Assertions bound inside the design and code coverage add white-box visibility.
  • Why should the designer not be the only verifier? Because their tests share any misunderstanding they have of the specification.
  • Which coverage is white box? Code coverage, since it is measured on the implementation. Functional coverage is defined from the specification.
  • Where does a board designer fit? Usually black box: they see only the chip's pins and its datasheet, as described above.
The Editor's Desk
About the Author
The Editor's Desk
Share Facebook X LinkedIn WhatsApp Email

Post a Comment

0 Comments

Your comments will be moderated before it appears here.

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!