#delay对于Verilog非阻塞语句如何工作? [英] How does #delay work for Verilog non-blocking statements?

查看:48
本文介绍了#delay对于Verilog非阻塞语句如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第二个 $ display 语句中的 A B 将打印什么?

What will be printed for A and B in the second $display statement?

module blocking;

reg[0:7] A, B;

initial begin
   A = 3;
   #1 A = A + 1; 
   B = A + 1;
   $display("Blocking: A= %d B= %d", A, B ); // A = 4, B = 5
   A = 3;
   #1 A <= A + 1;
   B <= A + 1;
   #1 $display("Non-blocking: A= %d B= %d", A, B ); // A = ?, B = ?
end
endmodule

Verilog中的事件调度如何处理延迟和非阻塞语句?

How does event scheduling in Verilog work with respect to delays and non-blocking statements?

推荐答案

因为在第二个 $ display 语句之前有#1 ,它将在下一个语句中执行 A B 结算之后的周期.

Because you have #1 before the second $display statement, it will be executed in the next cycle after A and B are settled.

假设我们处于第1个周期.

Say we are at cycle #1.

A = 3; // at #1
#1 // (does not matter) --> #2
A <= A + 1; // #2 will do A + 1 and wait till the end of the cycle 
B <= A + 1; // #2 same as above
// at the end of the cycle #2 (nba scheduling bucket) before switching to #3 
//    A and B will be assigned '4'
#1 // --> #3
// new values of A and B are available here (4)
$display("Non-blocking: A= %d B= %d", A, B );

这篇关于#delay对于Verilog非阻塞语句如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆