Blocking vs. Non-Blocking Assignment
A Blocking Statement must executed before the execution of statements that follow it in a sequential block.It can be used in Procedural assignments like initial,always and continious statements like assign statements.It is recommended to use within combinattional always block.it is represented by "=" operator sign
Example :
module block();
integer a,b,c,d;
// Blocking Assignments
initial
begin
a = 5; b = 3;
#15 c = 8;
#20 d = 15;
end
endmodule
In Above Example ,
At time '0' a and b have the value 5 and 3 respectively
At time '15' c have the value 8 and
At time '35' d have the value 15
A Non Blocking Statement first evaluate the value and then assigns it in the next event change,just the ways sequential circuits work.They always the sample the value of rising/falling edge of clock.It can be used in the procedural blocks like initial and always. assign statement is not permitted .It is recommended to use within sequential always block .It is represented by "<=" operator sign
Example :
module non_block();
integer a,b,c,d;
// Non-Blocking Assignments
initial
begin
a <= 5;
#10 b <= 3;
#15 c <= 8;
#20 d <= 15;
end
endmodule
In Above Example ,
At time '0' a have the value 5 .
At time '10' b have the value 3.
At time '15' c have the value 8 and
At time '20' d have the value 15
A Blocking Statement must executed before the execution of statements that follow it in a sequential block.It can be used in Procedural assignments like initial,always and continious statements like assign statements.It is recommended to use within combinattional always block.it is represented by "=" operator sign
Example :
module block();
integer a,b,c,d;
// Blocking Assignments
initial
begin
a = 5; b = 3;
#15 c = 8;
#20 d = 15;
end
endmodule
In Above Example ,
At time '0' a and b have the value 5 and 3 respectively
At time '15' c have the value 8 and
At time '35' d have the value 15
A Non Blocking Statement first evaluate the value and then assigns it in the next event change,just the ways sequential circuits work.They always the sample the value of rising/falling edge of clock.It can be used in the procedural blocks like initial and always. assign statement is not permitted .It is recommended to use within sequential always block .It is represented by "<=" operator sign
Example :
module non_block();
integer a,b,c,d;
// Non-Blocking Assignments
initial
begin
a <= 5;
#10 b <= 3;
#15 c <= 8;
#20 d <= 15;
end
endmodule
In Above Example ,
At time '0' a have the value 5 .
At time '10' b have the value 3.
At time '15' c have the value 8 and
At time '20' d have the value 15