Blocking and Non-Blocking Assignments
always @(posedge CLK) begin temp = B; B = A; A = temp; end
always @(posedge CLK) begin A <= B; B <= A; end
Blocking assignments (Q = A)
- variable is assigned immediately before continuing to next statement
- new variable value is used by subsequent statements
Non-blocking assignments (Q <= A)
- variable is assigned only after all statements already scheduledare executed
- value to be assigned is computed here but saved for later
- usual use: register assignment
- registers simultaneously take their new valuesafter the clock tick