VLSI DV Interview Puzzles · All levels
Last NBA in a Process Wins
Predict active print and end-of-slot value of q on the first edge. Explain why only one NBA survives.
Puzzle
Difficulty: Easy · Puzzle 5 of 6 · Topic: Event Scheduling Puzzles
Predict active print and end-of-slot value of q on the first edge. Explain why only one NBA survives.
Code
systemverilog
module tb;
bit clk = 0;
int q = 0;
always #5 clk = ~clk;
always @(posedge clk) begin
q <= 1;
q <= 2;
q <= 3;
$display("[%0t ACTIVE] q=%0d", $time, q);
end
initial begin
@(posedge clk);
$strobe("[%0t POSTPONED] q=%0d", $time, q);
$finish;
end
endmoduleHint
Within one process and one time slot, later NBA to same variable overrides earlier NBA updates.
Step-by-step solution
diagram
1) Active print sees old q=0 at t=5.
2) Three NBAs are queued for q in same process.
3) Last assignment q<=3 overrides earlier q<=1 and q<=2 for that slot.
4) Postponed print shows q=3 at t=5.Answer
Answer: Active shows q=0 at t=5; final value is q=3 at t=5. Last NBA to same variable in the process wins.
Why candidates get it wrong
People mix this with cross-process NBA ordering, which is not guaranteed.
Interviewer follow-up
What if each q<= assignment were in separate always blocks on the same edge?