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

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
    • Reset Puzzles
    • Clock Gating & Clock Mux Puzzles
      • AND Gate Fed Straight From a Flop
      • A Latch Makes the Gate Safe
      • Which Gate Wants Which Phase?
      • Switching a Clock Mux With the Select
      • The Glitch-Free Clock Switch
      • Does the Gated Flop See the Old Data?
    • CDC Basics Puzzles
    • Verifying CDC & Reset Puzzles
    • Clock, Reset & CDC Puzzles: Tricky Q&A
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Clock Gating & Clock Mux Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Clock, Reset & CDC Puzzles
  4. Clock Gating & Clock Mux Puzzles
  5. AND Gate Fed Straight From a Flop
On this page

    VLSI DV Interview PuzzlesAll levels

    AND Gate Fed Straight From a Flop

    An enable flop (clock-to-q 1 ns) drives an AND gate with the clock directly: gclk = clk & en. The enable command is 1 from t=12 to t=32. List the high pulses of gclk with their widths. Which of them are illegal for a flop clocked by gclk?

    Puzzle

    Difficulty: Medium · Puzzle 1 of 6 · Topic: Clock Gating & Clock Mux Puzzles

    An enable flop (clock-to-q 1 ns) drives an AND gate with the clock directly: gclk = clk & en. The enable command is 1 from t=12 to t=32. List the high pulses of gclk with their widths. Which of them are illegal for a flop clocked by gclk?

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    `timescale 1ns/1ns
    module tb;
      reg clk = 0, en_cmd = 0, en = 0;
      always #5 clk = ~clk;                       // posedges at 5, 15, 25, 35
      always @(posedge clk) en <= #1 en_cmd;      // enable flop with 1 ns clock-to-q, feeding the AND gate directly
      wire gclk = clk & en;
      integer t_r = -1;
      always @(gclk)
        if (gclk) t_r = $time;
        else if (t_r >= 0) $display("gclk high %0d..%0d width=%0d", t_r, $time, $time - t_r);
      initial begin
        #12 en_cmd = 1;
        #20 en_cmd = 0;                           // t=32
        #8  $finish;
      end
    endmodule

    Hint

    The enable changes 1 ns after a rising clock edge, while the clock is still high.

    Step-by-step solution

    Diagram
    1) The enable flop samples the command at each clk edge and updates 1 ns later.
    2) At the edge at t=15 the command is 1: en rises at t=16 while clk is high, so gclk rises at t=16 and falls with clk at t=20: a 4 ns pulse instead of 5.
    3) At t=25 en is already 1, so the pulse is the full 25..30, 5 ns.
    4) The command falls at t=32. At the edge at t=35 en is still 1 (it falls 1 ns later), so gclk rises at 35; en falls at 36 and cuts gclk low: a 1 ns pulse.
    5) The 4 ns pulse (truncated, late rising edge) and the 1 ns pulse (a runt) are glitches: the gate output changed while clk was high. The 1 ns pulse is the worst: it may or may not clock the flop reliably.

    Answer

    Answer: gclk high 16..20 (width 4), 25..30 (width 5), 35..36 (width 1). The first and last are illegal: the enable changed while clk was high, truncating the first pulse and creating a 1 ns runt on the last.

    How this was checked

    Checked by running the code in Icarus Verilog 13; the printed output supports the answer above. Icarus: with a 1 ns clock-to-q on the enable, the gate output is truncated at the start and has a 1 ns runt at the end.

    Why candidates get it wrong

    Believing a gate fed from a posedge flop is safe because the flop is synchronous. The enable can only change safely while the clock is low (for an AND gate); a posedge-launched enable changes just after the rising edge, so the gate output is cut or created mid-pulse. In zero-delay RTL (no clock-to-q) the glitch is invisible, so it passes simulation.

    Interviewer follow-up

    What would the pulse list look like in zero-delay RTL with en <= en_cmd (no #1)? Model answer: gclk would show clean full-width pulses (rising at the same time as clk, one delta later), so RTL simulation passes while the real circuit glitches.

    Related topics

    • Back to Clock Gating & Clock Mux Puzzles

    • Clock, Reset & CDC Puzzles section

    Previous

    242 / 293

    Next: A Latch Makes the Gate Safe

    Up next

    Up nextA Latch Makes the Gate Safe

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Which Gate Wants Which Phase?
    • Switching a Clock Mux With the Select
    • The Glitch-Free Clock Switch