Consider the following two concurrent always blocks: reg q1, q2; always @…
Consider the following two concurrent always blocks: reg q1, q2; always @(posedge clk) begin q1 = d; end always @(posedge clk) begin q2 = q1; end What is the expected physical behavior/simulation outcome for q2 upon a rising clock edge?
- A dedicated 2-stage shift register is synthesized, and q2 reliably takes the old value of q1 .
- A simulation race condition exists where q2 may capture either the old value of q1 or the newly updated q1 value depending on simulator scheduling.
- Synthesis completely fails to map this design because blocking assignments are illegal inside posedge blocks.
- q2 will always enter a high-impedance state ( 1'bz ).
Correct answer
B. A simulation race condition exists where q2 may capture either the old value of q1 or the newly updated q1 value depending on simulator scheduling.
Explanation
Because blocking assignments ( = ) execute immediately in the Active region of the stratified event queue, the evaluation order between the two active always blocks is non-deterministic according to the IEEE Verilog standard. If block 1 runs first, q2 samples the new d value (acting as a single register for both). If block 2 runs first, q2 samples the old q1 value (acting as a shift register). Non-blocking assignments ( <= ) must be used for sequential logic to avoid this simulation-synthesis mismatch.