Test Hooks at Chip Level
A tester checks a new chip by loading its flip-flops and reading them back. To do that it must own their data, their clock and their reset, even behind a closed clock gate.
You Will Be Able To
- Name the three moves of a scan test, and say what scan enable selects in each.
- Explain why a test clock must join the clock route after the clock gate.
- Predict the order in which the bits of a scan chain come out.
- Lesson
- S8.5
- Time
- 25 min
- Runs on
- Your browser
- Check
- 5 questions
A new chip sits on the tester at the factory. One part of it sleeps, exactly as designed: its clock gate is closed. Three flip-flops in that part must be loaded and read, and the tester can touch only the pins.
Before You Start
You need Reset Across Clock Domains, the Reset Tree and Scan: the tester, a scan chain, test mode and the reset bypass.
You need Dividers and Clock Gates: a clock gate holds its output low while it is closed.
| Question | |
|---|---|
| 1 | What are the three moves of a scan test? |
| 2 | What does scan enable choose? |
| 3 | Why does the test clock join the route after the clock gate? |
| 4 | Which bit of a chain comes out first? |
| 5 | A pattern is captured in three flip-flops: what does the scan output show, pulse by pulse? |
The Idea: Load, Capture, Read
A factory cannot open a chip to look at a flip-flop. It has the pins, and nothing else. So the flip-flops are built to help. In test mode they link into a scan chain, a shift register that ends on a pin.
A scan test has three moves. First the tester shifts a pattern in, one bit for each clock pulse. Then it lets the chip work for one pulse, and each flip-flop takes what the logic offers. That one pulse is the capture pulse. Last, the tester shifts the result out and compares it with the right answer.
One signal chooses between the moves. It is called scan enable. At 1, a flip-flop takes the bit of its neighbour. At 0, it takes what the logic offers.
The moves need more than data. They need clock pulses on demand, and a reset that the tester alone controls. A part of the chip that sleeps gets no clock at all. So the chip carries test hooks: extra routes that give the tester the clock and the reset of every flip-flop.
New Words
| Word | Meaning |
|---|---|
| Hook for the tester | A route added to a chip for the tester alone. In normal work it does nothing. This page calls it a test hook. |
| Scan enable | A signal from the tester. At 1 the flip-flops shift along the scan chain. At 0 they take what the logic offers. |
| Scan input and scan output | The two ends of a scan chain, each on a pin. Bits go in at one end and come out at the other. |
| Capture pulse | One clock pulse with scan enable at 0. Each flip-flop takes what the logic offers. The move is called the capture. |
| Clock of the tester | A clock that the tester drives from a pin, one pulse when the tester wants one. This page calls it the test clock. |
| Test clock mux | A mux in a clock route. In test mode it passes the test clock in place of the chip clock. |
One Picture: The Tester Takes the Clock
- Peripheral
- Clock / reset
- Debug
- Memory
- At work
On each clock pulse the three flip-flops take what the logic offers. The tester cannot see them.
- A chain
With scan enable at 1, each flip-flop takes the bit of its neighbour. Flop 0 takes the scan input. The three are now one shift register.
- A closed gate
A shift needs clock pulses. This island sleeps: its clock gate is closed, so the chip clock never arrives.
- The test clock
A mux after the clock gate lets the tester feed its own clock. Now a pulse reaches the flip-flops whatever the gate does.
- The whole hook
The tester owns the data through the scan input and the clock through the mux. It owns the reset through the reset bypass you already know.
Read the diagram as text
- Logic: what the chip computes for these flip-flops
- Chip clock: through a clock gate that may be closed
- Tester: scan input, scan enable, test clock, test reset
- Test clock mux: after the clock gate: chip clock or test clock
- Three scan flip-flops: flop 0, flop 1, flop 2, linked as a scan chain
- Scan output: the content of flop 2, on a pin
- Logic → Three scan flip-flops: while scan enable is 0
- Chip clock → Test clock mux: gated clock
- Test clock mux → Three scan flip-flops: clock of the flip-flops
- Tester → Three scan flip-flops: scan input, while scan enable is 1
- Tester → Test clock mux: test clock
- Three scan flip-flops → Scan output: one bit for each pulse
The clock and data routes of the lab. The reset bypass is not drawn: it is the one of the reset lesson.
The Smallest Example, Worked by Hand
Take a chain of three flip-flops. Flop 0 is next to the scan input. Flop 2 drives the scan output. No simulator yet. The table writes the three as flop 2, flop 1, flop 0.
| Move | Scan enable | Scan input | Flops after the pulse | What happened |
|---|---|---|---|---|
| Shift in | 1 | 1 | 001 | Flop 0 took the 1. |
| Shift in | 1 | 0 | 010 | The 1 moved to flop 1. Flop 0 took a 0. |
| Shift in | 1 | 0 | 100 | The 1 reached flop 2, the far end. |
| Capture | 0 | not used | 011 | The logic offered 0, 1 and 1. Each flop took its own bit. |
| Shift out | 1 | 0 | 110 | Before the pulse the scan output showed flop 2: a 0. |
| Shift out | 1 | 0 | 100 | Before the pulse it showed a 1. |
| Shift out | 1 | 0 | 000 | Before the pulse it showed a 1. |
Read the three rows of the shift in. The first bit that went in is the one that travelled farthest. It ends in flop 2.
Read the three rows of the shift out. The tester saw 0, then 1, then 1. Flop 2 came out first, then flop 1, then flop 0. A tester that reads the answer backwards would report 110, and reject a good chip.
The Rules
Rule 1: A scan test has three moves: shift in, capture, shift out.
Scan enable is 1 for the shifts and 0 for the one capture pulse.
Rule 2: In test mode the tester owns the clock of every flip-flop.
A test clock mux gives it the clock. No clock gate may stand between that mux and the flip-flop.
Rule 3: In test mode the tester owns the reset of every flip-flop.
That is the reset bypass. Check it on known ones, with both clocks low.
Rule 4: The flip-flop next to the scan output comes out first.
It is also where the first bit that went in ends up.
Rule 5: A shift proves the chain. Only a capture tests the logic.
A chain can shift perfectly in front of logic that is broken.
Rule 6: Clocks are low while the tester changes mode.
A mux that switches during a pulse can cut the pulse short.
Sources for These Rules
Scan design, and the scan flip-flop with a mux on its data input: Weste and Harris, CMOS VLSI Design, fourth edition, section 15.6.2.
The warning that a clock stopped by a clock enable must still toggle in scan mode: the same book, section 15.6.2.2.
Rule 3, the reset bypass, and rule 6 are common practice. Our reference library has no source that states them. They are labelled as practice in the reset lesson too.
Where the test clock mux sits, the three flip-flops and their order are choices of our lab.
Now Run It
The lab at the end of this page has the three flip-flops, their clock gate and the two hooks. The clock gate stays closed in every row. Test code plays the tester.
chip clock, gate closed: flops=000
shift in 1: flops=001
shift in 0: flops=010
shift in 0: flops=100
test reset, both clocks low: flops=000
capture: flops=011
scan out=0
scan out=1
scan out=1
scan out, first bit first: 0 1 1Rule 2 at work, in the first four rows. A pulse of the chip clock changes nothing: the closed gate stops it. Three pulses of the test clock then walk a 1 through all three flip-flops.
Rule 3, in the row "test reset". The flops held 100, a known 1. With both clocks low, the test reset clears them. A shift alone could never show that the reset wire is connected.
Rule 1, in the row "capture". Scan enable is 0 for this one pulse, and the flops take 011 from the logic.
Rule 4, in the last four rows. The scan output shows 0, then 1, then 1: flop 2 first.
This lab leaves things out. Three flip-flops stand for the hundred thousand of a real chain. The logic is three fixed bits. The test clock mux is one line of code. A real one is a special cell, and needs the rule about low clocks.
Why It Is Built This Way
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| Flip-flops linked into a chain | A pin for every flip-flop | Any number of flip-flops through two pins. A long chain takes long to shift. |
| The test clock joins after the clock gate | Force every clock gate open in test mode | A pulse reaches the flip-flop whatever software left in the gate. One mux in each gated route. |
| One scan enable, apart from test mode | One signal for both | The tester can capture, with scan enable at 0, and still own clock and reset. |
The Trap: A Capture That Shifted
A test program reported a broken part of a chip. Every chip failed the same pattern, in the same way: the answer was all zeros. The designers looked at the logic for two days and found nothing wrong.
The fault was in the test program. Scan enable was still 1 on the capture pulse. The chain shifted one more bit, and the logic was never sampled. Our lab shows it. With scan enable left at 1, the row reads "capture: flops=000", and the scan output gives 0 0 0.
A second trap hides behind a passing test. On the tester, every clock gate was forced open by a test pin. In the field one gate stayed closed, because of a bug in its enable. The scan patterns had never used that enable, so they could not see it.
The third is the order. The tester and the designer must agree which flip-flop comes out first. A pattern that reads the same in both directions, such as 101, hides a wrong answer to that question.
At Scale
This section looks ahead. Three flip-flops become a hundred thousand, and the patterns come from a tool.
Many chains
A long chain takes too long to shift. A large chip has thousands of short ones, and logic at the pins packs their data.
Patterns from a tool
Nobody writes scan patterns by hand. A tool works out which patterns show each possible fault, and what a good chip answers.
Power domains
A chain cannot pass through a part whose supply is off. The test plan says which parts are powered for each pattern.
Memories, pads and analog circuits
A scan chain does not test a memory cell, a pad or an amplifier. The next three lessons give each its own hook.
Try It
Run the lab. Find the three rows that start with "shift in", and follow the single 1 from flop 0 to flop 2.
Change events from 011 to 110. Predict the last row before you run it.
Set gate_open to 1. Which row changes, and why only that one?
Names Printed by the Lab
| Name | Meaning |
|---|---|
| flops | The three flip-flops, written as flop 2, flop 1, flop 0. |
| shift in | The bit on the scan input during one pulse of the test clock, with scan enable at 1. |
| capture | One pulse of the test clock with scan enable at 0. |
| scan out | The level of the scan output before the next pulse. It is the content of flop 2. |
chip clock, gate closed: flops=000 shift in 1: flops=001 shift in 0: flops=010 shift in 0: flops=100 test reset, both clocks low: flops=000 capture: flops=011 scan out=0 scan out=1 scan out=1 scan out, first bit first: 0 1 1Read included file: soc-s85-crg.sv
// Teaching slice. Change mode and gate controls only while both clocks are low.
// Physical clock switching needs characterized cells and a switch protocol.
module ap_crg_scan_slice (
input logic functional_clk, test_clk, scan_mode, gate_open,
input logic functional_reset, test_reset, shift, serial_in,
input logic [2:0] events,
output logic [2:0] pending
);
wire leaf_clk = scan_mode ? test_clk : (functional_clk & gate_open);
wire leaf_reset = scan_mode ? test_reset : functional_reset;
always_ff @(posedge leaf_clk or posedge leaf_reset) begin
if (leaf_reset)
pending <= 3'b000;
else if (scan_mode && shift)
pending <= {pending[1:0], serial_in};
else
pending <= events;
end
endmodule
Check Yourself
Common Mistakes
Wrong Leave scan enable at 1 for the capture pulse.
The chain shifts once more and the logic is never sampled.
Fix Scan enable is 0 for exactly one pulse between the two shifts.
Wrong Bring the test clock in before the clock gate.
A closed gate stops the test clock as well.
Fix Put the test clock mux after the gate, next to the flip-flops.
Wrong Test the chain with a pattern such as 101.
It reads the same in both directions, so a reversed order passes.
Fix Use a pattern such as 100 or 110.
Remember
- A scan test shifts a pattern in, captures for one pulse, and shifts the result out.
- Scan enable chooses between the neighbour and the logic.
- In test mode the tester owns data, clock and reset. The test clock joins after the clock gate.
- The flip-flop next to the scan output comes out first.