πŸ”§ DFT Blog

Part 5 of 11

Scan Chains

The backbone of structural testing

By Praveen Kumar Vagala

1,378 views

What is Scan?

Scan connects all flip-flops into a long shift register, allowing direct access to internal state.

Normal Mode (Functional Operation)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DFF1 │────►│ DFF2 │────►│ DFF3 β”‚ β”‚ D Q β”‚ β”‚ D Q β”‚ β”‚ D Q β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↑ ↑ ↑ Logic Logic Logic Each FF receives data from combinational logic.

Scan Mode (Test Operation)

SI (Scan In) β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ SFF1 │────►│ SFF2 │────►│ SFF3 │───► SO β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ All FFs form a shift register - can load/unload any pattern!

Scan Flip-Flop Structure

A scan FF is a regular FF with a MUX added at the input:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” D (func) ─────►│ β”‚ β”‚ MUX │───► D ──► FF ───► Q SI (scan) ─────►│ β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚ SE (scan enable) SE=0: Normal operation (D β†’ FF β†’ Q) SE=1: Scan operation (SI β†’ FF β†’ Q)

Verilog Implementation

module scan_dff (
    input      clk,
    input      rst_n,
    input      d,           // Functional data
    input      si,          // Scan input
    input      se,          // Scan enable
    output reg q
);
    wire mux_out;
    
    // Scan MUX: SE selects between functional and scan data
    assign mux_out = se ? si : d;
    
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            q <= 1'b0;
        else
            q <= mux_out;
    end
endmodule

Scan Test Operation

Step 1: Shift In (Load Pattern)

SE = 1 (Scan mode) Apply N clock cycles to shift in test pattern SI ──► [0] ──► [1] ──► [0] ──► [1] ──► [1] ──► SO After 5 clocks, pattern "01011" is loaded into 5 FFs.

Step 2: Capture (Apply Test)

SE = 0 (Functional mode) Apply ONE clock cycle [0]──►Logic──►[?] [1]──►Logic──►[?] ... Combinational logic evaluates, results captured in FFs.

Step 3: Shift Out (Unload Response)

SE = 1 (Scan mode) Apply N clock cycles to shift out captured response (While shifting in next pattern - pipelined!) SI ──► [new] ──► [new] ──► [captured] ──► [captured] ──► SO

Complete Timing

│←── Shift In ──→│Cap│←── Shift Out ──→│ CLK ───┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴── SE ━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━ ┗━━━┛ SI ───Pattern N────────────────Pattern N+1─── SO ───────────────────────────Response N─────

Scan Chain Architecture

Real chips have multiple scan chains running in parallel:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ SI[0]──►│ Chain 0: [FF]─[FF]─[FF]─[FF]─[FF] │──►SO[0] β”‚ β”‚ SI[1]──►│ Chain 1: [FF]─[FF]─[FF]─[FF]─[FF] │──►SO[1] β”‚ β”‚ SI[2]──►│ Chain 2: [FF]─[FF]─[FF]─[FF]─[FF] │──►SO[2] β”‚ β”‚ SI[3]──►│ Chain 3: [FF]─[FF]─[FF]─[FF]─[FF] │──►SO[3] β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ More chains = shorter chains = faster shift!

Trade-offs

More ChainsFewer Chains
Faster shift timeSlower shift time
More pins neededFewer pins needed
More routing complexityLess routing

Scan DRC Rules

Design Rule Checks that MUST pass:

1. All FFs Must Be Scannable

Every flip-flop should be in a scan chain (unless specifically excluded).

2. Clocks Must Be Controllable

βœ“ GOOD: Clock from controllable source CLK_PIN ──► FF βœ— BAD: Clock from internal logic (uncontrollable) Logic ──► FF (clock can't be controlled in scan mode)

3. Async Resets Must Be Inactive

During scan shift:
  RST_N = 1 (inactive)
  
If RST_N = 0, all FFs reset - destroys scan data!

4. No Tri-State in Scan Path

βœ— BAD: Tri-state buffer in scan chain SI ──► [TRISTATE] ──► FF High-Z would break the chain!

5. No Combinational Loops

βœ— BAD: Feedback without FF β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β–Ό β”‚ Logic β”€β”€β–Ίβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”˜ Can't determine stable value!

Summary

ConceptKey Point
Scan FFRegular FF + MUX for scan input
SE=0Functional mode (normal operation)
SE=1Scan mode (shift register)
Shift InLoad test pattern into all FFs
CaptureOne functional clock, capture response
Shift OutUnload response from all FFs