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. Competing Active Writers on x

VLSI DV Interview Puzzles · All levels

Competing Active Writers on x

Predict post-NBA values of x and y on each edge. Is behavior deterministic across simulators?

On this page

    Puzzle

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

    Predict post-NBA values of x and y on each edge. Is behavior deterministic across simulators?

    Code

    tb.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
    module tb;
      bit clk = 0;
      int x = 0;
      int y = 0;
    
      always #5 clk = ~clk;
    
      always @(posedge clk) begin
        x = x + 1;
        y <= x;
      end
    
      always @(posedge clk) begin
        x = x + 10;
      end
    
      initial begin
        repeat (2) begin
          @(posedge clk);
          $strobe("[%0t] x=%0d y=%0d", $time, x, y);
        end
        $finish;
      end
    endmodule

    Hint

    Both blocks write x in active with no ordering guarantee.

    Step-by-step solution

    Diagram
    1) x ends each edge as old_x + 11 regardless of order.
    2) y<=x samples x in whichever intermediate active state Process A sees.
    3) If A runs first on first edge, y becomes 1; if B runs first, y becomes 11.
    4) Same ambiguity repeats each edge, so y is race-dependent.

    Answer

    Answer: x is deterministic per edge (+11), but y is nondeterministic because it samples race-dependent active-state x before NBA update.

    Why candidates get it wrong

    Using NBA on y does not sanitize the active-region race on x.

    Interviewer follow-up

    How would you refactor to a single writer while preserving intended math?

    Related topics

    • Back to Race Condition Puzzles

    • Concurrency & Timing Puzzles section

    Previous

    61 / 210

    Next: Blocking Writer vs NBA Writer Same Signal

    Up next

    Up nextBlocking Writer vs NBA Writer Same Signal

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • False Mismatch from Active Sampling
    • #0 Monitor Is Still Before NBA
    • Lost Update in Forked Counter