VLSI DV Interview Puzzles · All levels

Chained #0 Delays vs Single NBA

Find final x at end of the time slot. Explain why two #0 assignments still lose to one NBA assignment.

Puzzle

Difficulty: Medium · Puzzle 3 of 6 · Topic: Event Scheduling Puzzles

Find final x at end of the time slot. Explain why two #0 assignments still lose to one NBA assignment.

Code

systemverilog
module tb;
  int x = 0;
  initial begin
    fork
      begin
        x = 1;
        #0 x = 2;
        #0 x = 4;
      end
      begin
        x <= 3;
      end
    join
    $strobe("[%0t] final x=%0d", $time, x);
  end
endmodule

Hint

Iterative inactive regions still complete before NBA commit.

Step-by-step solution

diagram
1) Active region executes x=1 and schedules x<=3 for NBA.
2) First #0 assigns x=2 in inactive.
3) Second #0 assigns x=4 in another inactive iteration.
4) After inactive queue drains, NBA commits x=3.
5) Postponed $strobe prints final x=3.

Answer

Answer: Final printed value is x=3 at t=0. Repeated #0 updates do not outrun the pending NBA update in that slot.

Why candidates get it wrong

Candidates often assume more #0 hops can override NBA; scheduler order is fixed.

Interviewer follow-up

How would behavior change if the NBA were replaced with blocking x = 3?

Related topics