---
title: Verification and test
heading: Making sure a design is right before it's built and each chip is good after, simulation, coverage and formal checks, stuck-at faults and fault coverage, the defect level that reaches customers, scan chains and test time, and built-in self-test
eyebrow: D7 · Lesson 6 · Verification and test
xp: 40
---

::: hook
Two different questions decide whether a chip ships. **Verification** asks whether the design is right: does the logic do what the specification says, in every corner case, before a single wafer is made? On large chips it takes more engineers than the design itself. **Test** asks whether each manufactured chip matches the design: every die off the line is probed, and any with a broken wire or a shorted transistor is thrown away. Both are probability games, because neither can try every possibility, and a few untested faults let a few bad chips through.
:::

::: play
- The **defect level**, bad chips that pass test, in parts per million, against the test's fault coverage, for a process yield Y: $DL = 1 - Y^{1 - FC}$ (Williams and Brown).
- Even 99% coverage lets about a thousand bad chips per million through at 90% yield; reaching under 100 ppm takes about 99.9%.
- Lower yields make it worse, since there are more bad chips for the gaps in coverage to miss.
:::

```sim plot
view: graph
x: F = 0.9..0.9999
y: D = 1..100000 log
slider: Y = 0.3..0.98 step 0.01 = 0.9
plot: 1e6*(1 - Y^(1 - F)) | samples: 400 | label: defect level, ppm (F = fault coverage)
readout: defect level at 99% coverage, ppm = 1e6*(1 - Y^0.01) | digits: 4
readout: coverage needed for 100 ppm = 1 - ln(1 - 1e-4)/ln(Y) | digits: 5
```

::: predict
## A process yields 90% good dies, and the test catches 99% of possible faults. About how many shipped chips per million are defective?

- [ ] 10
- [ ] 100
- [x] About 1000
- [ ] About 10,000

::: reveal
$DL = 1 - 0.9^{0.01}$ = 0.00105: about 1050 parts per million, roughly one in a thousand. Automotive customers demand single-digit ppm, so their chips need coverage near 99.99% and extra tests.
:::
:::

::: nameit
## Verification

- **Simulation** runs the RTL against testbenches, increasingly with constrained-random stimulus and self-checking models of the expected behavior.
- **Coverage** measures what's been exercised: lines of code, branches, and functional points such as every opcode with every operand type. Random tests hit the last few bins slowly: covering n equally likely bins takes about $n(\ln n + 0.577)$ random tests on average.
- **Formal verification** proves properties mathematically for all inputs, and **equivalence checking** proves that the synthesized netlist matches the RTL.

## Test

Manufacturing defects are modeled as **faults**, most simply **stuck-at** faults: a node stuck at 0 or 1. **Fault coverage** is the fraction of modeled faults a test set detects. The **defect level**, the fraction of shipped parts that are bad, is

$$DL = 1 - Y^{1 - FC}$$

for yield Y and fault coverage FC.

## Scan

Testing deep sequential logic through the chip's pins is nearly impossible, so every flip-flop is joined into **scan chains**: in test mode they form shift registers, so a tester can load any state, run one clock, and shift the result out. Patterns are generated automatically (ATPG). Each pattern costs a shift of the chain's length, so test time is roughly

$$t = \frac{N_\text{patterns} \times L_\text{chain}}{f_\text{shift}}$$

and splitting the flip-flops into many short chains in parallel shortens it.

## Built-in self-test

Memories and some logic test themselves: on-chip generators produce patterns (march tests for memory, LFSR patterns for logic, C7) and compress the responses into a signature, saving tester time. Spare rows and columns let memories repair themselves.
:::

::: example
## What coverage gets the defect level under 100 ppm at 90% yield? How long does it take to apply 10,000 scan patterns through chains 1000 flip-flops long at 50 MHz?

::: solution
1. **Coverage for 100 ppm.** Solve $DL = 1 - Y^{1 - FC}$ for $1 - FC$:
   $$\begin{aligned} 1 - FC &= \frac{\ln(1 - 10^{-4})}{\ln 0.9} \\ &= 0.000949 \end{aligned}$$
   so FC ≥ 99.905%.
2. **Scan time.** Each pattern shifts through 1000 flip-flops:
   $$\frac{10\,000 \times 1000}{50\ \text{MHz}} = 0.2\ \text{s}$$
   per chip, which on an expensive tester is real money.

**Answer:** a fault coverage of at least 99.905%, and 0.2 s of scan per chip.
:::
:::

::: example
## A random testbench must hit each of 1000 equally likely coverage bins. About how many tests does it need?

::: solution
1. **Expected tests.**
   $$\begin{aligned} &1000 \times (\ln 1000 + 0.577) \\ &= 7485\ \text{tests} \end{aligned}$$
   on average, 7.5 times the number of bins.
2. **The last bins.** Targeted tests for the last stubborn bins are usually cheaper.

**Answer:** about 7485 tests on average.
:::
:::

::: example
## A built-in self-test uses a 16-bit maximal-length LFSR to generate patterns. How many distinct patterns does it give, and how long does a full run take at 100 MHz?

::: solution
1. **Patterns.** Every state except all zeros:
   $$2^{16} - 1 = 65\,535$$
2. **Run time.** One pattern per clock:
   $$\frac{65\,535}{100\ \text{MHz}} = 0.66\ \text{ms}$$
3. **What it misses.** The patterns are pseudorandom, so faults that need very specific patterns may still escape, which is why BIST is combined with targeted scan tests.

**Answer:** 65,535 distinct patterns, applied in 0.66 ms.
:::
:::

::: check
given: Y = 0.5 | 0.8 | 0.95; F = 0.95 | 0.99 | 0.999
answer: 1e6*(1 - Y^(1 - F))
tolerance: 0.5%

## A process yields {Y} and testing reaches {F} fault coverage. What's the defect level, in parts per million?

::: right
Right. $1 - Y^{1 - FC}$ = {answer} ppm.
:::

::: misses
- [1e6*(1 - Y)*(1 - F)] That's a linear guess; Williams and Brown's formula is $1 - Y^{1 - FC}$.
- [any] Not yet. $DL = 1 - Y^{1 - FC}$.
:::
:::

::: check
given: Y = 0.6 | 0.8 | 0.9; D = 10 | 100 | 500
answer: 100*(1 - ln(1 - D*1e-6)/ln(Y))
tolerance: 0.001%

## A process yields {Y}. What fault coverage, in percent, holds the defect level to {D} ppm?

::: right
Right. $1 - \ln(1 - DL)/\ln Y$ = {answer}%.
:::

::: misses
- [any] Not yet. Solve $DL = 1 - Y^{1 - FC}$ for FC.
:::
:::

::: check
given: p = 2000 | 10000 | 50000; L = 200 | 1000 | 5000; f = 25 | 100
answer: p*L/(f*1e6)
unit: s
tolerance: 0.5%

## A chip needs {p} scan patterns through chains {L} flip-flops long, shifted at {f} MHz. How long does the scan test take?

::: right
Right. $N_\text{patterns}L/f$ = {answer} s.
:::

::: misses
- [any] Not yet. Each pattern shifts the whole chain.
:::
:::

::: check
given: n = 50 | 200 | 5000
answer: n*(ln(n) + 0.5772)
tolerance: 1%

## About how many random tests does it take to hit all {n} equally likely coverage bins?

::: right
Right. $n(\ln n + 0.577)$ = {answer}.
:::

::: misses
- [n] Random tests repeat bins; the last few take many tries.
- [n*ln(n)] Close: add 0.577 to the logarithm.
- [any] Not yet. The coupon collector's problem.
:::
:::

::: check
kind: parts
given: Y = 0.7 | 0.9 | 0.95; F = 0.99 | 0.999

## Chips are made at yield {Y} and tested with fault coverage {F}.

::: part
answer: (1 - Y^(1 - F))*1e6
unit: ppm
tolerance: 0.5%

### What defect level ships, by Williams and Brown?

::: misses
- [any] $1 - Y^{1 - FC}$.
:::
:::

::: part
answer: 1 - ln(1 - 1e-4)/ln(Y)
tolerance: 0.01%

### What coverage would bring it to 100 ppm?

::: misses
- [any] Solve $Y^{1 - FC} = 1 - 10^{-4}$.
:::
:::
:::

::: check
kind: parts
given: p = 1000 | 10000; L = 500 | 2000; f = 25 | 100

## {p} scan patterns are shifted through chains {L} flip-flops long at {f} MHz.

::: part
answer: p*L/(f*1e6)*1000
unit: ms
tolerance: 0.5%

### How long does the test take per chip?

::: misses
- [any] Patterns × chain length ÷ clock.
:::
:::

::: part
answer: p*L/(f*1e6)*1000/4
unit: ms
tolerance: 0.5%

### And with the flip-flops split into four times as many, shorter chains?

::: misses
- [any] A quarter.
:::
:::
:::

::: check
kind: parts
given: n = 100 | 1000 | 5000

## A random testbench must hit each of {n} equally likely coverage bins at least once.

::: part
answer: n*(ln(n) + 0.5772)
tolerance: 0.5%

### About how many tests does it need on average?

::: misses
- [n] Repeats make it much more than {n}.
- [any] $n(\ln n + \gamma)$.
:::
:::

::: part
answer: ln(n) + 0.5772
tolerance: 0.5%

### How many times the number of bins is that?

::: misses
- [any] $\ln n + \gamma$.
:::
:::
:::

::: check
kind: parts
given: k = 8 | 16 | 24; f = 10 | 100

## A built-in self-test uses a {k}-bit maximal-length LFSR at {f} MHz.

::: part
answer: 2^k - 1
tolerance: 0

### How many patterns does it give before repeating?

::: misses
- [2^k] All zeros never occurs.
- [any] $2^k - 1$.
:::
:::

::: part
answer: (2^k - 1)/(f*1e6)*1000
unit: ms
tolerance: 0.5%

### How long does a full run take?

::: misses
- [any] Patterns ÷ clock.
:::
:::
:::

::: explain
## Why do scan chains make a chip testable?

::: model
A large chip's logic is buried behind many layers of flip-flops, so to test a particular gate deep inside, a tester working only through the pins would have to find a sequence of inputs that drives the internal state to exactly the right values and then propagates any error back out, which for millions of flip-flops is practically impossible. Scan design adds a test mode in which all the flip-flops are linked into long shift registers. The tester shifts in any state it wants, clocks the logic once in normal mode, and shifts the captured results out, so every block of combinational logic between flip-flops can be tested directly as if its inputs and outputs were pins.
:::
:::

::: practice

::: check
given: Y = 0.3 | 0.98; F = 0.9 | 0.9999
answer: 1e6*(1 - Y^(1 - F))
tolerance: 0.5%

## Defect level, ppm: Y = {Y}, FC = {F}?

::: misses
- [any] $1 - Y^{1 - FC}$.
:::
:::

::: check
given: p = 100 | 100000; L = 50 | 10000; f = 10 | 200
answer: p*L/(f*1e6)
unit: s
tolerance: 0.5%

## Scan time: {p} patterns, {L}-bit chains, {f} MHz?

::: misses
- [any] $N_pL/f$.
:::
:::
:::
