difference between blocking and non blocking statements with intra-assignment delay

六月ゝ 毕业季﹏ 提交于 2019-12-06 02:08:55

out = #5 in; blocks the next operation for 5 time units. It will prevent the monitoring of the next @(in) until the the 5 time units have passed. If you add a $display statement just before and after the assignment you will see 5 time units has passed.

always @(in) begin
    $display("enter @ %0t",$realtime);
    out = #5 in;
    $display("exit @ %0t",$realtime);
end
/*******************
 * Example output:
 * enter @ time 10
 * exit @ time 15
 *******************/

out <= #5 in; schedules the assignment of occur 5 time units in the future and allows the next operation to begin without waiting for assignment to complete.

always @(in) begin
    $display("enter @ %0t",$realtime);
    out <= #5 in;
    $display("exit @ %0t",$realtime);
end
/*******************
 * Example output:
 * enter @ time 10
 * exit @ time 10
 *******************/

Working example at the EDA Playground: http://www.edaplayground.com/s/6/114

They produce different output when in toggles before the #5 delay is up. The non-blocking assignment will always delay in by #5 regardless of how fast in toggles.

Examples on EDA Playground. Note the difference in sim output.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!