Home › Practice › RTL Design › Scan chain: shift and capture
Scan chain: shift and capture
EasyDFTRTLsequential
A 4-bit scan chain links four flip-flops into a shift path so chip testers can load and read internal state through two pins. The starter code compiles, but two bugs break shifting and scan readout.
Concept first. Inside a real chip, thousands of flip-flops sit behind logic with no direct path to the pins. Adding a 2-to-1 mux in front of every flip-flop lets test mode turn them into one long shift register. When scan enable (se) is 1, each flip-flop takes the previous flip-flop's output and the chain shifts a test pattern in from si and out through so. When se is 0, each flip-flop captures its normal data input d_in.
What the circuit must do.
- Inputs
clk,rst,se,si,d_in[3:0]. Outputsq[3:0],so. rstis synchronous, active-high: on a risingclkedge withrst=1,qbecomes4'b0000.- When
se=1(shift mode), on each rising edgesientersq[3]and every bit shifts right by one:q[3]moves toq[2],q[2]toq[1], andq[1]toq[0]. - When
se=0(capture mode), on each rising edgeqloadsd_in. sois driven continuously by the last flip-flop in the chain,q[0].
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.