Consider the following Verilog snippet inside an always @(posedge clk) block:a <= 1'b1; a <= ~a;
Assuming the register a holds the value 1'b0 just before the clock edge, what will be the value of a immediately after the clock edge, and why?
Non-blocking assignments evaluate all right-hand expressions simultaneously using the variable values at the beginning of the evaluation phase. Since a was 0, ~a evaluates to 1. When multiple non-blocking assignments to the same variable exist, the last one in the code order is the one that gets scheduled and applied.