Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
    • Low-Power RTL Hub
    • DFT and Scan Hub
    • Physical Awareness Hub
    • Waveform Debug Hub
    • STA and ECO Hub
    • RTL-to-Implementation Closure
    • DFT-Ready RTL
      • Scan-Ready Coding
      • Test Clocks, Resets, and Modes
      • Memory, JTAG, Compression, and Handoff
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
  • Glossary and Notation
Loading lesson

‹DFT-Ready RTL
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. DFT-Ready RTL
  5. Scan-Ready Coding

Part 9 · Senior · Senior

Scan-Ready Coding

Use recognizable flops, approved clock gating, controllable resets, and explicit test bypasses.

On this page

    Why this matters

    A functional clock divider may not give the repeated pulses scan needs, and a test_mode mux added everywhere damages timing and opens a security hole. Scan-ready coding makes insertion predictable.

    After this lesson you can: spot RTL features that block scan, replace them with approved patterns, and centralise test controls.

    RTL feature

    DFT risk

    Preferred pattern

    Fabric-generated clock

    Uncontrollable shift clock

    Clock enable or approved clock cell

    Combinational reset logic

    Uncontrolled reset during shift

    Reset controller with test override

    Latch/custom storage

    May not have scan equivalent

    Approved library pattern and waiver

    Black-box state

    Unobservable or uncontrollable

    Test model or wrapper

    X-producing analog/status input

    Compactor pollution

    Test clamp/mask with reviewed behavior

    The sensor peripheral replaces its fabric divider with an approved clock wrapper, gives test control explicit reset ownership, and clamps the analog status only in authorized test mode. These changes preserve functional behavior while making scan insertion predictable.

    Divided clock: bad and good

    The fabric divider below clocks a flop from logic. In shift the tester cannot drive that clock, and the divider's own state decides when it ticks.

    div_clk_bad.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    // Bad for scan: q is clocked by a divider flop, not by a controllable clock
    module div_clk_bad (
      input  logic clk, rst_n, d,
      output logic q
    );
      logic clk_div2;
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n) clk_div2 <= 1'b0;
        else        clk_div2 <= ~clk_div2;
      always_ff @(posedge clk_div2) q <= d;   // clock from fabric logic
    endmodule

    The fix keeps one clock and turns the divide into an enable. Every flop now sees the tester's shift pulses; only the functional update rate changes.

    div_en_good.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    // Scan-friendly: one clock, divide-by-two as a clock enable
    module div_en_good (
      input  logic clk, rst_n, d,
      output logic q
    );
      logic en_div2;
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n) en_div2 <= 1'b0;
        else        en_div2 <= ~en_div2;
      always_ff @(posedge clk)
        if (en_div2) q <= d;                  // updates every second edge
    endmodule

    Where a real divided clock is required, use the approved clock wrapper with a test bypass, as the sensor peripheral does.

    What scan insertion builds

    A mux-D scan cell: the tool puts a two-input mux in front of each recognisable flop. SE picks the previous cell's output (shift) or the functional D (capture).

    Read the cell left to right. The accent wires are what scan adds; everything else is the functional flop.

    • The flop must be recognisable and clocked by a controllable clock, or the tool cannot replace it.

    • SE is a global test control, so it comes from the AON test controller, not functional software.

    • SO feeds the next cell, which is why every cell in a chain must shift on the same legal clock.

    Instance / boundary

    Functional domain and relation

    Test/reset owner and hook

    u_sensor/u_sample_regs

    sample_clk from sensor PLL; asynchronous to bus_clk

    u_aon/u_test_ctrl owns sample clock wrapper/OCC and test reset; separate sample scan chain

    u_sensor/u_bus_regs

    bus_clk; no assumed phase relation to sample_clk

    Same AON owner, independent bus wrapper/OCC and reset; separate bus scan chain

    u_sensor/u_sample_sram

    sample_clk, 256x16 single-port macro

    u_sample_mbist owns wrapper test select, address/data/write control and done/fail status

    u_sensor/u_cfg_sram

    bus_clk, 64x32 single-port macro

    u_cfg_mbist owns distinct wrapper and status; not scanned as ordinary flops

    analog_status -> sample control

    External asynchronous/X-capable input

    Functional synchronizer retained; authorized scan/capture clamp=0 before compaction

    sensor_pins / bus_pins

    External interfaces

    AON pin mux parks outputs; u_tap boundary access per pin policy

    Each functional reset asserts asynchronously and releases synchronously to its domain. Test control takes ownership only with clocks stopped and reset asserted, then releases reset with the selected legal test clocks before loading vectors. Enumerate excluded AON/OCC state separately with DFT-owned reasons. Separate chains avoid assuming a lockup latch can make arbitrary asynchronous capture relationships safe.

    • Run DFT lint before integration.

    • Identify every non-scan register and why it is safe.

    • Expose test enables through stable top-level ownership.

    • Do not let functional software configuration be the only path to test mode.

    • Keep test behavior out of normal functional timing paths where possible.

    Common pitfall

    Adding a test_mode mux everywhere can damage functional timing and create security exposure. Centralize test controls and use library-supported structures.

    Check yourself Why are internally divided clocks difficult for scan?

    Shift requires controllable repeated pulses. A functional divider depends on internal state and may not deliver the required test-clock sequence unless bypassed or replaced.

    Remember

    • Shifting needs controllable repeated pulses; bypass a functional divider with an approved clock wrapper.

    • Give test control explicit reset ownership, and clamp analog status only in authorised test mode.

    • Run DFT lint early, and list every non-scan register with the reason it is safe.

    How this was checked

    The instance names and mode artifacts form an illustrative integration contract, not an inserted netlist or an executed DFT signoff.

    Keep going

    • Code lab: Scan chain stub

    • Interview: run a mock interview on this topic

    Related topics

    • Test clocks, resets, and modes

    • Full scan-ready RTL lesson

    Previous

    300 / 350

    Next: Test Clocks, Resets, and Modes

    Up next

    Up nextTest Clocks, Resets, and Modes

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Memory, JTAG, Compression, and Handoff