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. Two always_ff Writers, One Register

VLSI DV Interview Puzzles · All levels

Two always_ff Writers, One Register

When load and clear are both 1 on the same edge, what can data become? Is the result language-deterministic?

On this page

    Puzzle

    Difficulty: Hard · Puzzle 6 of 6 · Topic: Race Condition Puzzles

    When load and clear are both 1 on the same edge, what can data become? Is the result language-deterministic?

    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
    module tb;
      bit clk = 0;
      bit load = 1;
      bit clear = 1;
      byte in = 8'hA5;
      byte data = 8'h00;
      always #5 clk = ~clk;
    
      always_ff @(posedge clk) begin
        if (load) data <= in;
      end
    
      always_ff @(posedge clk) begin
        if (clear) data <= 8'h00;
      end
    
      initial begin
        @(posedge clk);
        $strobe("[%0t] data=%0h", $time, data);
        $finish;
      end
    endmodule

    Hint

    Two different processes enqueue NBAs to same variable in same slot.

    Step-by-step solution

    Diagram
    1) Both always_ff blocks schedule NBA updates for data at t=5.
    2) Relative ordering of those cross-process NBAs is not guaranteed by intent and is tool/order dependent.
    3) data may end as 8'hA5 or 8'h00 depending on process order.
    4) Architecturally correct fix is single-writer sequential logic.

    Answer

    Answer: Result is nondeterministic: data can be 8'hA5 or 8'h00 at t=5. Multiple sequential writers create a race.

    Why candidates get it wrong

    Using always_ff does not legalize multiple writers to the same flopped signal.

    Interviewer follow-up

    Refactor this into one always_ff with explicit priority (clear over load or vice versa).

    Related topics

    • Back to Race Condition Puzzles

    • Concurrency & Timing Puzzles section

    Previous

    66 / 210

    Next: Clocking Block Puzzles

    Up next

    Up nextClocking Block Puzzles

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Competing Active Writers on x
    • Blocking Writer vs NBA Writer Same Signal
    • False Mismatch from Active Sampling