Determine the final values of a and b after the active simulation time st…
Determine the final values of a and b after the active simulation time step finishes: reg [3:0] a, b; initial begin a = 4'd4; b = 4'd7; a <= b; b <= a; end
- a = 4'd7, b = 4'd7
- a = 4'd4, b = 4'd7
- a = 4'd7, b = 4'd4
- a = 4'd4, b = 4'd4
Correct answer
C. a = 4'd7, b = 4'd4
Explanation
Non-blocking assignments ( <= ) evaluate their right-hand sides during the active region using the current values of the variables before scheduling updates. At the moment of scheduling, a is 4'd4 and b is 4'd7 . In the NBA (Non-Blocking Assignment update) region, a receives 4'd7 and b receives 4'd4 , effectively swapping their contents without needing a temporary register.