Home / Learn / Chip Design / Scan Chain Insertion Explained

On this pageThe problem scan solvesThe scan flip-flopHow a scan test runsHow insertion is doneDesign rules for scanMultiple chains and compressionDesign choicesWhat scan costsTesting for speed defectsScan and securityHow it connects to the rest of testCommon questionsRelated guides

Scan Chain Insertion Explained

Scan chain insertion links a chip’s flip-flops into long shift registers so that the logic inside the chip can be tested after manufacture. Each flip-flop is replaced by a version that can either work normally or pass data to its neighbor. In test mode, values are shifted in through one pin, the chip’s logic runs for a single cycle, and the results are shifted out through another. It is the basic technique that makes large digital chips testable.

The problem scan solves

A chip’s logic sits between storage elements called flip-flops. To test a piece of logic, you need to set the values going into it and read the values coming out. On a real chip, those values are held in flip-flops buried far from any external pin.

Without scan, reaching a particular internal state might require running the chip through thousands of clock cycles of carefully chosen inputs, and observing the result might be just as hard. For a large design this is impractical.

Scan gives direct access to every flip-flop.

The scan flip-flop

A scan flip-flop is an ordinary flip-flop with a small selector added at its input. It has two extra connections.

  • Scan input. An alternative source of data, connected to the previous flip-flop in the chain.
  • Scan enable. A control signal that selects which input is used.

When scan enable is off, the flip-flop takes its normal data and the chip behaves as designed. When scan enable is on, the flip-flop takes data from its neighbor, and the whole chain behaves as a shift register.

How a scan test runs

Each test pattern follows the same three steps.

  • Shift in. With scan enable on, the clock is pulsed repeatedly and a chosen pattern of values is shifted into the chain until every flip-flop holds its intended value.
  • Capture. Scan enable is turned off and the clock is pulsed once. The logic computes its outputs from the loaded values, and the flip-flops capture the results.
  • Shift out. Scan enable is turned on again and the captured values are shifted out to the tester, which compares them with the expected response. The next pattern is shifted in at the same time.

If any captured value differs from what a good chip would produce, the chip has a defect.

How insertion is done

Scan insertion is automated and usually happens during or just after synthesis.

  • Rule checking. The design is checked for structures that would prevent scan from working.
  • Replacement. Each flip-flop is swapped for its scan equivalent.
  • Stitching. The scan flip-flops are connected into chains, each with its own input and output.
  • Reordering. After the cells are placed on the chip, the order within each chain is rearranged so that neighbors in the chain are neighbors physically. This keeps the connecting wires short.

Design rules for scan

For scan to work, the test equipment must be able to control every flip-flop’s clock and reset directly. Designs follow a set of rules to guarantee this.

  • Clocks must be controllable from external pins in test mode
  • Asynchronous resets must be controllable in test mode
  • Logic that generates clocks internally needs a bypass
  • Feedback loops through combinational logic are avoided
  • Latches and unusual storage elements need special handling

Violations do not break the chip’s normal function. They leave parts of it untestable, which lowers fault coverage.

Multiple chains and compression

A single chain containing every flip-flop in a large chip would be millions of elements long. Shifting each pattern through it would take far too long.

Designs therefore use many shorter chains shifted in parallel. But each chain needs pins, and pins are limited. Test compression resolves this. A small decompressor on the chip takes data from a few pins and spreads it across hundreds or thousands of internal chains. A compactor combines their outputs back down to a few pins.

Compression reduces both the time each chip spends on the tester and the volume of test data by a large factor. It is standard practice on large chips.

Design choices

ChoiceTrade-off
Number of chainsMore chains shorten test time but need more routing and compression logic
Chain lengthShorter chains shift faster
Compression ratioHigher ratios cut test time but can make some faults harder to detect
Mixing clock domains in a chainSimplifies stitching but needs extra cells to avoid timing problems
Shift speedFaster shifting reduces test time but raises power during test

What scan costs

  • Area. Scan flip-flops are slightly larger than ordinary ones, and the chains need wiring.
  • Timing. The selector at each flip-flop’s input adds a small delay to the normal path.
  • Routing. Scan connections and the scan enable signal consume wiring resources.
  • Power during test. In shift mode, far more of the chip switches at once than in normal operation, which can cause excess heat or voltage droop. Patterns and shift speeds are chosen to keep this in check.

Testing for speed defects

Basic scan testing finds faults where a signal is stuck at a fixed value. Some defects only make a circuit too slow. Detecting these requires at-speed testing, in which two clock pulses are applied in quick succession during capture, at the chip’s real operating frequency. The on-chip clock circuitry is usually used to generate those pulses.

Scan and security

A scan chain exposes the contents of every flip-flop. If a chip holds secret keys, an attacker with access to the scan pins could read them out. Chips that handle sensitive data protect against this by disabling scan access after manufacture, requiring authentication to enter test mode, or clearing secrets when test mode is entered.

How it connects to the rest of test

Scan provides access. Automatic test pattern generation decides what values to shift in. Memories are tested separately with built-in self-test. For the overall picture, see What Is Design for Testability (DFT)?.

Common questions

Does scan affect how the chip works in normal use?

Functionally, no. With scan enable off, the chip behaves exactly as designed. The added selector introduces a small delay, which is accounted for during design.

Is every flip-flop put on a scan chain?

Usually nearly all. This is called full scan. A few may be excluded for timing or other reasons, at some cost in test coverage.

Why are scan chains reordered after placement?

The initial order is logical and takes no account of where cells end up on the chip. Reordering connects physically adjacent flip-flops, which shortens wiring and eases routing.

Related guides