Part 5 of 11
Scan Chains
The backbone of structural testing
By Praveen Kumar Vagala
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 Chains | Fewer Chains |
| Faster shift time | Slower shift time |
| More pins needed | Fewer pins needed |
| More routing complexity | Less 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
| Concept | Key Point |
| Scan FF | Regular FF + MUX for scan input |
| SE=0 | Functional mode (normal operation) |
| SE=1 | Scan mode (shift register) |
| Shift In | Load test pattern into all FFs |
| Capture | One functional clock, capture response |
| Shift Out | Unload response from all FFs |