Blocking (immediate) and Non-Blocking (deferred) Assignments in Verilog
Blocking assignments
- Blocking assignments (=) are done sequentially in the order the statements are written.
- A second assignment is not started until the preceding one is
complete. i.e, it blocks all the further execution before it itself gets
executed
module
Blocking(
input
a,
input
b,
output
reg
c,
output
reg
d
);
initial
begin
#
50
c = a|b;
d = c;
c = #
50
a&b;
#
20
d = c;
end
endmodule
Non-Blocking assignments
- Nonblocking assignments (<=), which follow each other in the code, are started in parallel.
- The right hand side of nonblocking assignments is evaluated starting
from the completion of the last blocking assignment or if none, the
start of the procedure.
- The transfer to the left hand side is made according to the delays.
An intra- assignment delay in a non-blocking statement will not delay
the start of any subsequent statement blocking or non-blocking. However
normal delays are cumulative and will delay the output.
- Non-blocking schedules the value to be assigned to the variables but
the assignment does not take place immediately. First the rest of the
block is executed and the assignment is last operation that happens for
that instant of time.
module
Non_Blocking(
input
a,
input
b,
output
reg
c,
output
reg
d
);
initial
begin
c <=
0
;
#
50
c <= a|b;
d <= c;
c <= #
50
a&b;
end
endmodule
No comments:
Post a Comment