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. Does the Gated Flop See the Old Data?
On this page

    VLSI DV Interview PuzzlesAll levels

    Does the Gated Flop See the Old Data?

    A register a runs on clk. A register b runs on g2, a gated copy of clk that arrives two continuous-assignment deltas later, and copies a. Both start at 0. What is printed at t=26, and is there a race? Assume a, b are updated with the usual non-blocking assignments.

    Puzzle

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

    A register a runs on clk. A register b runs on g2, a gated copy of clk that arrives two continuous-assignment deltas later, and copies a. Both start at 0. What is printed at t=26, and is there a race? Assume a, b are updated with the usual non-blocking assignments.

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    `timescale 1ns/1ns
    module tb;
      reg clk = 0, en = 1;
      always #5 clk = ~clk;                       // posedges at 5, 15, 25
      wire g1 = clk & en;                         // gated clock, one delta after clk
      wire g2 = ~(~g1);                           // and one more delta
      reg [3:0] a = 0, b = 0;
      always @(posedge clk) a <= a + 1;           // ungated domain
      always @(posedge g2)  b <= a;               // gated domain samples the ungated register
      initial begin
        #26 $display("t=%0d a=%0d b=%0d", $time, a, b);
        $finish;
      end
    endmodule

    Hint

    Where in the time step do non-blocking updates happen compared with continuous assignments?

    Step-by-step solution

    Diagram
    1) At each rising clk edge the always block for a schedules a <= a + 1 in the NBA region.
    2) The continuous assignments g1 and g2 are evaluated in the active region of the same time step, so g2 rises, and the always @(posedge g2) block runs and reads a, before the NBA region updates a.
    3) So b receives the value a had before the edge. Edge 5: b=0, a=1. Edge 15: b=1, a=2. Edge 25: b=2, a=3.
    4) At t=26 a=3 and b=2: exactly the behaviour of two flops on the same edge. There is no race.
    5) It would be a race if the gated clock were produced through a non-blocking assignment or a delay, because the clock edge would then happen after a's update.

    Answer

    Answer: It prints a=3 b=2. The gated flop reads the value from before the edge because the delta delays of continuous assignments all happen in the active region, before any non-blocking update; there is no race in this style of gating.

    How this was checked

    Checked by running the code in Icarus Verilog 13 and Verilator 5; the printed output supports the answer above. Icarus: the gated register captures the pre-edge value of a. Verilator gives the same result for this continuous-assignment style.

    Why candidates get it wrong

    Concluding that any delta of clock skew breaks RTL. Continuous or blocking gating keeps the gated flop on the same side of the NBA update, so RTL simulation is fine; the breakage comes from deriving the clock with a non-blocking assignment or a delay, or from launching data with blocking assignments.

    Interviewer follow-up

    What happens if the gated clock is made with always @(clk) gclk <= clk & en? Model answer: the gated edge now arrives in the NBA region, in the same batch as a's update, so b may capture the new value of a; the result is a race that depends on the tool, which is why clocks must not be derived with non-blocking assignments.

    Related topics

    • Back to Clock Gating & Clock Mux Puzzles

    • Clock, Reset & CDC Puzzles section

    Previous

    247 / 293

    Next: CDC Basics Puzzles

    Up next

    Up nextCDC Basics Puzzles

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • AND Gate Fed Straight From a Flop
    • A Latch Makes the Gate Safe
    • Which Gate Wants Which Phase?