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. Which Gate Wants Which Phase?
On this page

    VLSI DV Interview PuzzlesAll levels

    Which Gate Wants Which Phase?

    Two gating cells see the same clock. The AND gate has en go from 0 to 1 and the OR gate has dis go from 0 to 1 (clock disabled), both at t=12 while clk is low. List every rising edge each output produces.

    Puzzle

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

    Two gating cells see the same clock. The AND gate has en go from 0 to 1 and the OR gate has dis go from 0 to 1 (clock disabled), both at t=12 while clk is low. List every rising edge each output produces.

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    `timescale 1ns/1ns
    module tb;
      reg clk = 0, en = 0, dis = 0;
      always #5 clk = ~clk;                       // high 5..10, 15..20, 25..30; low 10..15, 20..25
      wire g_and = clk & en;                      // en=0 holds the output low
      wire g_or  = clk | dis;                     // dis=1 holds the output high
      always @(posedge g_and) $display("t=%0d AND-gate rising edge", $time);
      always @(posedge g_or)  $display("t=%0d OR-gate rising edge", $time);
      initial begin
        #12 en = 1; dis = 1;                      // both controls change at t=12, while clk is low
        #21 $finish;
      end
    endmodule

    Hint

    The OR gate output follows clk until dis is 1; then it is held high.

    Step-by-step solution

    Diagram
    1) The AND output is 0 while en=0, so no rising edge is produced at t=5. en rises at t=12 while clk is low, so nothing happens at the output; the rising edges at t=15 and t=25 pass through. The AND cell is being switched in its safe phase (clk low).
    2) The OR output equals clk while dis=0, so it rises at t=5.
    3) dis rises at t=12, clk is low, so the OR output (clk | dis) goes from 0 to 1 at t=12: a rising edge that is not a clock edge.
    4) After that the OR output stays high, so there are no more edges: the gate is disabled, but at the cost of one spurious edge.
    5) Rule: an AND-type gate may change its enable only while clk is low; an OR-type gate (holds the clock high when disabled) may change only while clk is high.

    Answer

    Answer: OR gate rising edges at t=5 and t=12 (the second is a spurious edge), AND gate rising edges at t=15 and t=25. Each gate's control may only change in its own safe phase: low clock for AND, high clock for OR.

    How this was checked

    Checked by running the code in Icarus Verilog 13; the printed output supports the answer above. Icarus: the OR gate produces a rising edge at t=12 when its control changes during the low phase; the AND gate is clean.

    Why candidates get it wrong

    Memorising 'enable changes when the clock is low' for every gate. That is only for the AND type; the OR type (parks the clock high) needs the opposite phase, and changing it while the clock is low creates a rising edge.

    Interviewer follow-up

    For the OR gate, which latch phase gives a safe disable? Model answer: a latch that is transparent while clk is high (the disable is frozen during the low phase), so dis can only change while the OR gate output is held high by clk.

    Related topics

    • Back to Clock Gating & Clock Mux Puzzles

    • Clock, Reset & CDC Puzzles section

    Previous

    244 / 293

    Next: Switching a Clock Mux With the Select

    Up next

    Up nextSwitching a Clock Mux With the Select

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • AND Gate Fed Straight From a Flop
    • The Glitch-Free Clock Switch
    • Does the Gated Flop See the Old Data?