Hardware interview practice
Eight-bit scan-chain RTL
An eight-flop register supports functional parallel capture and serial scan shifting. Implement the scan behavior with a defined shift direction, reset, and observable serial output.
Starting point
Question code
input logic clk, rst_n, scan_en, scan_in;
input logic [7:0] func_d;
output logic [7:0] q;
output logic scan_out;Reviewed example
Work through one case
Input
Before scan edge: q=8'hA5, scan_en=1, scan_in=0Expected output
Before edge scan_out=1; after edge q=8'h4AOld q[7] is observed at scan_out, while the remaining bits shift toward bit 7 and zero enters bit 0.
What to cover
Requirements
- With scan_en=1, load q[0] from scan_in and q[i] from prior q[i-1] for i=1 through 7.
- Define scan_out as current q[7], making the pre-edge shifted-out bit observable.
- With scan_en=0, capture func_d into all eight bits in parallel.
- Use synchronous active-low reset; rst_n=0 on a rising edge clears q regardless of scan_en.
