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

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
    • Event Scheduling Puzzles
    • Race Condition Puzzles
      • Competing Active Writers on x
      • Blocking Writer vs NBA Writer Same Signal
      • False Mismatch from Active Sampling
      • #0 Monitor Is Still Before NBA
      • Lost Update in Forked Counter
      • Two always_ff Writers, One Register
    • Clocking Block Puzzles
    • Semaphore & Mailbox Puzzles
    • Concurrency & Timing Puzzles: Tricky Q&A
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Race Condition Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Concurrency & Timing Puzzles
  4. Race Condition Puzzles
  5. #0 Monitor Is Still Before NBA

VLSI DV Interview Puzzles · All levels

#0 Monitor Is Still Before NBA

Does adding #0 before compare fix the previous race? Predict mismatch behavior.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: Race Condition Puzzles

    Does adding #0 before compare fix the previous race? Predict mismatch behavior.

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    module tb;
      bit clk = 0;
      bit d = 1;
      bit q = 0;
      always #5 clk = ~clk;
    
      always @(posedge clk) q <= d;
    
      always @(posedge clk) begin
        #0;
        if (q !== d)
          $display("[%0t #0 CHECK] mismatch q=%0b d=%0b", $time, q, d);
      end
    
      initial begin
        repeat (2) @(posedge clk);
        $finish;
      end
    endmodule

    Hint

    #0 shifts active to inactive, but NBA is still later.

    Step-by-step solution

    Diagram
    1) q<=d is scheduled in active at each edge.
    2) Monitor resumes in inactive due to #0 and checks q before NBA commit.
    3) At t=5 it still sees q=0, d=1 and prints mismatch.
    4) #0 changed region but not enough to see NBA-updated state.

    Answer

    Answer: No fix. Mismatch still appears at t=5 because #0 checks in inactive, which is before NBA.

    Why candidates get it wrong

    Using #0 as a generic race cure is unreliable and often wrong.

    Interviewer follow-up

    What region-safe alternatives can a UVM monitor use for cycle-accurate sampling?

    Related topics

    • Back to Race Condition Puzzles

    • Concurrency & Timing Puzzles section

    Previous

    64 / 210

    Next: Lost Update in Forked Counter

    Up next

    Up nextLost Update in Forked Counter

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Competing Active Writers on x
    • Blocking Writer vs NBA Writer Same Signal
    • Two always_ff Writers, One Register