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
    • Event Scheduling Puzzles
    • Race Condition Puzzles
    • Clocking Block Puzzles
      • Why Every Sample Is One Cycle Old
      • Interpreting |=> ##1 in Clocking Domain
      • disable fork Kills Unrelated Background Threads
      • input #0 vs input #1step Snapshot
      • Nonzero Input Skew Looks Back in Time
      • Mixing Direct Drive and cb Drive
    • Semaphore & Mailbox Puzzles
    • Concurrency & Timing Puzzles: Tricky Q&A
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Clocking Block Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Concurrency & Timing Puzzles
  4. Clocking Block Puzzles
  5. Nonzero Input Skew Looks Back in Time
On this page

    VLSI DV Interview PuzzlesAll levels

    Nonzero Input Skew Looks Back in Time

    The clocking block uses input #2 and a signal changes shortly before each clock edge. Predict the three lines and explain why cb.d and the raw d differ.

    Puzzle

    Difficulty: Medium · Puzzle 5 of 6 · Topic: Clocking Block Puzzles

    The clocking block uses input #2 and a signal changes shortly before each clock edge. Predict the three lines and explain why cb.d and the raw d differ.

    Code

    ifc.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
    29
    30
    `timescale 1ns/1ns
    interface ifc(input bit clk);
      logic d = 0;
      clocking cb @(posedge clk);
        default input #2;
        input d;
      endclocking
    endinterface
    
    program automatic check(ifc vif);
      initial begin
        repeat (3) begin
          @(vif.cb);
          $display("[%0t] cb.d=%0b raw d=%0b", $time, vif.cb.d, vif.d);
        end
        $finish;
      end
    endprogram
    
    module tb;
      bit clk = 0;
      always #5 clk = ~clk;
      ifc vif(clk);
      check c(vif);
    
      initial begin
        #4  vif.d = 1;                 // 1 ns before the t=5 edge
        #10 vif.d = 0;                 // 1 ns before the t=15 edge
      end
    endmodule

    Hint

    input #2 samples the value the signal had 2 time units before the clocking event, not the value at the edge.

    Step-by-step solution

    Diagram
    1) The clock rises at t=5, 15, 25. d goes 0 to 1 at t=4 and 1 to 0 at t=14.
    2) With input #2 the clocking block returns the value d held at t-2 (the sample is taken 2 ns before the edge, in the Preponed-style region of that earlier instant). At t=5 that is t=3: d=0, so cb.d=0.
    3) The reader is a program (Reactive region), so raw d is read after everything at t=5 has settled: d=1. First line: [5] cb.d=0 raw d=1.
    4) At t=15 the clocking sample is the value at t=13, which is 1 (d only falls at t=14); the raw value is 0. Second line: [15] cb.d=1 raw d=0.
    5) At t=25 the sample at t=23 is 0 and the raw value is 0: [25] cb.d=0 raw d=0.
    6) Because the change happens inside the skew window the clocking block ignores it for that edge; only the next edge sees it. Verified in Verilator 5.048 (prints the three lines above). Icarus does not support clocking blocks.

    Answer

    Answer: [5] cb.d=0 raw d=1, [15] cb.d=1 raw d=0, [25] cb.d=0 raw d=0. The clocking block returns d as it was 2 ns before each edge, so a change made 1 ns before the edge is invisible to it until the next edge.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. input #2 returns d as it was 2 ns before each edge, so a change 1 ns before the edge is hidden for that edge.

    Why candidates get it wrong

    Reading input #2 as 'sample at the edge with a 2 ns delay' is backwards: an input skew looks back in time, so it samples earlier than the edge. A signal that is still changing inside the skew window is, by design, not seen on that edge (that is the setup-time model).

    Interviewer follow-up

    Which skew would you pick so a change made 1 ns before the edge is seen on that edge? Model answer: any skew smaller than the 1 ns setup margin: input #1, input #1step or input #0 all give [5] cb.d=1, [15] cb.d=0, [25] cb.d=0 (verified in Verilator), while input #2 hides both changes for one edge. Choose the skew to match the real setup time of the interface, or fix the stimulus timing so setup time is respected.

    Say it out loud

    With input skew of two, the clocking block returns the value d had two nanoseconds before the edge, so it looks back in time. At five that is time three, so cb.d is 0 while the raw d is already 1; at fifteen cb.d is 1 and raw d is 0; at twenty-five both are 0. A change made one nanosecond before the edge falls inside the skew window and is only seen at the next edge. The trap is reading the skew as a delay after the edge; it is the setup-time model, and Icarus does not support clocking blocks.

    Related topics

    • Clocking Blocks

    • Driving & Sampling via Clocking Blocks

    • Clocks & the Sampling Model

    • Back to Clocking Block Puzzles

    • Concurrency & Timing Puzzles section

    Previous

    77 / 293

    Next: Mixing Direct Drive and cb Drive

    Up next

    Up nextMixing Direct Drive and cb Drive

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Why Every Sample Is One Cycle Old
    • Interpreting |=> ##1 in Clocking Domain
    • disable fork Kills Unrelated Background Threads