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
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
      • Interview: Combinational and Arithmetic
      • Interview: Sequential and Pipelines
      • Interview: FSM and Control
      • Interview: Timing and STA
      • Interview: CDC and Reset
      • Interview: Memories and Buses
      • Interview: Low-Power Design
        • Dynamic power first
        • Clock gating done safely
        • Crossing a powered-off domain
        • The RTL and UPF split
      • Interview: Debug and ECO
      • Interview: Coding and Whiteboard
  • Glossary and Notation
Loading lesson

‹Interview: Low-Power Design
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. Senior RTL Interview Questions & Model Answers
  5. Interview: Low-Power Design
  6. Clock gating done safely

Part 9 · Senior · Senior

Clock gating done safely

Safe clock gating with a latch-based ICG model, scan override and testbench.

On this page

    Why this matters

    ANDing the clock with an enable makes a runt pulse whenever the enable changes while the clock is high, and the flop captures at the wrong moment. Interviewers ask for the safe pattern to see if you know the latch.

    After this lesson you can: draw a latch-based clock gate, explain why it removes runt pulses, and name the test override and timing checks it needs.

    The question

    The interviewer asks for a safe clock-gating pattern, or what is wrong with ANDing the clock with an enable. It is testing for the latch-based cell and the habits around it.

    A direct clk & en can glitch if en changes while clk is high. A characterized ICG captures the gating decision with a low-transparent latch and holds it throughout the high phase. Rising-edge registration is optional control design; it alone still changes Q during the high phase.

    A latch-based clock gating cell: en OR te passes through a latch that is open while clk is low, and the latched value gates clk in an AND gate.

    Read it left to right: the decision is made in the OR gate, frozen by the latch, then applied by the AND gate.

    • The bubble on EN makes the latch open only while clk is low, which is exactly when the AND gate's other input is 0, so changes cannot reach gated_clk.

    • While clk is high the latch holds en_lat, so the AND sees a steady enable for the whole pulse.

    • te joins in the OR, so scan can force the gate open whatever en says.

    Model answer

    The picture has four slots per clock period: two while clk is high and two while it is low. A pulse cut short shows up as one high slot instead of two. The same en drives both gates, and it changes twice while clk is high.

    • Bare AND gate: in g_naive, en falls one slot into the first high phase, so the gated clock is a runt pulse. Later en rises one slot into the second high phase, so a late short pulse appears. A flop clocked by either pulse can capture at the wrong moment.

    • Latch-based gate: in g_icg, the latch holds en_lat steady while clk is high. The first pulse stays full width, the late enable does nothing, and en only takes effect after clk falls.

    Meet the ICG enable and test-control gating setup/hold requirements at latch closure. Low-phase capture prevents ideal-model high-phase disturbances, but does not remove physical timing obligations. An inactive/falling-edge register can be another scoped method for a positive-edge clock if the target flow supports it and its half-cycle timing is met. On FPGA, prefer supported clock-enable pins or dedicated clock-control resources. See canonical safe gating.

    Every gate gets a test override that keeps scan clocks alive. Prefer one enable per functional cluster over one per flop, and review the gating against realistic activity traces.

    Common pitfall

    Never write ad-hoc clk & en gating in RTL. Map intent-driven enables to library ICG cells and let the backend insert them.

    Follow-ups

    • Why the latch rather than a rising-edge flop alone? A rising-edge flop updates while clk is high. The low-transparent latch holds throughout that phase, subject to characterized closure timing. A falling-edge alternative must satisfy its own clock and enable timing; no ideal model establishes physical margin.

    • What does the test input do during scan shift? It forces the gate open so shift clocks reach every flop. Without it, ATPG patterns cannot shift through gated domains.

    • One enable per flop or per cluster? Per cluster. Per-flop gating explodes the enable logic and its routing, which costs more than the flops saved.

    Common wrong answers

    • ANDing clock and enable in RTL. Correct intent, unsafe circuit. Any enable transition during the high phase becomes a runt clock pulse.

    • Ignoring enable/test timing because a latch exists. Both controls must meet the selected cell's gating checks; optional registration does not waive them.

    • Skipping the scan override. The design gates fine in function and fails in test. Every gate control needs the override path.

    Interview

    Draw low-phase capture, name enable and test gating checks, and use the target's characterized clock-control resource.

    Check yourself The enable rises just after a rising clock edge while the clock is high. What does the gated clock do, and why?

    Nothing until the next edge. The latch is closed while the clock is high, so the new enable waits for the low phase and no runt pulse appears.

    Testbench

    A behavioural ICG with scan override, a gated counter, and a bench for hold, advance, override and a mid-high enable change. Pulse width and gating margin come from implemented timing checks, not from this zero-delay model.

    icg.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    `timescale 1ns/1ps
    module icg (
      input  logic clk,
      input  logic en,          // intent-driven; obey the target ICG gating timing
      input  logic te,          // scan override: forces the gate open in test
      output logic gated_clk
    );
      logic en_lat;
      always @(clk or en or te) begin
        if (clk == 1'b0) en_lat = en | te;   // transparent while low, holds while high
      end
      assign gated_clk = clk & en_lat;
    endmodule
    
    module gated_counter (
      input  logic       clk,
      input  logic       rst_n,
      input  logic       en,
      input  logic       te,
      output logic [7:0] count
    );
      logic gated_clk;
      icg u_icg (.clk(clk), .en(en), .te(te), .gated_clk(gated_clk));
      always @(posedge gated_clk or negedge rst_n) begin
        if (!rst_n) count <= 8'h00;
        else count <= count + 8'h01;
      end
    endmodule
    

    Remember

    • A low-transparent latch holds the enable while the clock is high, so the gated clock never has a runt pulse.

    • The ICG still has setup and hold requirements at latch closure, for both the enable and the test control.

    • Every gate needs a scan override, and one enable should serve a functional cluster, not a single flop.

    Rule of thumb: never write clk & en in RTL; use the library ICG and let the backend insert it.

    How this was checked

    ICG bench Run with Icarus Verilog 13.0 (2026-10-16): prints PASS. It covers hold, advance, override and a mid-high enable change in an ideal zero-delay model, so it does not establish pulse width or physical gating margin.

    Keep going

    • Practice: A safe clock-gating cell with a latch-based enable

    • Interview: run a mock interview on this topic

    Previous

    338 / 350

    Next: Crossing a powered-off domain

    Up next

    Up nextCrossing a powered-off domain

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • The RTL and UPF split
    clkeng_naiveen_latg_icg
    A bare AND gate against a latch-based gate on the same enable