Skip to question and answer

Hardware interview practice

SystemVerilog Blocking vs. Nonblocking Assignments

EasySystemVerilogMultiple choice

What values are printed by display and strobe, in that order?

Question code
logic a;
initial begin
  a = 0;
  a <= 1;
  $display("D=%0b", a);
  $strobe("S=%0b", a);
end

Answer choices

  1. A. D=0, S=0
  2. B. D=x, S=1
  3. C. D=1, S=1
  4. D. D=0, S=1

Concise answer

The answer and the key reason

Choose D: $display prints D=0 and $strobe prints S=1. The blocking assignment changes a immediately, while the nonblocking assignment schedules its update for the NBA region. $display runs before that scheduled update; $strobe reports later, after the new value has taken effect.

Deeper explanation

Work through the implementation and tradeoffs

At the start of the initial block, the blocking assignment places 0 into a in the current active-region execution. The following <= statement evaluates its right-hand side but defers writing 1. Therefore the immediate $display call still observes the old current value and emits D=0.

Nonblocking updates are committed later in the same simulation time slot, after active-region work. $strobe waits until the postponed region, when those updates are visible and the time slot has settled, so it emits S=1. No simulation time advances; the difference comes entirely from event-region ordering, which is central to race-free modeling in synchronous RTL.

What to remember

  • $display sees active-region state
  • NBA updates occur later
  • $strobe sees settled state

Practice the complete prompt

Explain it first, then compare the reviewed solution.

Open this exact question in the practice bank to attempt it, check your reasoning, and access the full member solution.Practice this question

Keep practicing

SystemVerilogSystemVerilog logic, bit, and wire 4-State TypesSystemVerilogSystemVerilog Logical Equality vs. Case EqualityData StructuresSystemVerilog Packed vs. Unpacked Arrays