VLSI DV Interview Puzzles · All levels
Does #0 Beat NBA?
Predict both prints at time 0 and explain why they differ even though there is no real time advance.
Puzzle
Difficulty: Easy · Puzzle 2 of 6 · Topic: Event Scheduling Puzzles
Predict both prints at time 0 and explain why they differ even though there is no real time advance.
Code
systemverilog
module tb;
int x;
initial begin
x = 0;
x <= 1;
#0 x = 2;
$display("[%0t INACTIVE] x=%0d", $time, x);
$strobe("[%0t POSTPONED] x=%0d", $time, x);
end
endmoduleHint
#0 lands in inactive; NBA updates happen after inactive.
Step-by-step solution
diagram
1) Active region schedules x<=1 for NBA.
2) #0 resumes in inactive and assigns x=2.
3) $display in inactive prints x=2 at t=0.
4) NBA region then updates x to 1.
5) $strobe runs in postponed and prints x=1 at t=0.Answer
Answer: Inactive print is [0] x=2, postponed print is [0] x=1. #0 executes before NBA in the same time slot.
Why candidates get it wrong
Many engineers think #0 moves after NBA because it 'feels later'. It does not.
Interviewer follow-up
If you replace #0 with #1, what changes in ordering and printed time?