显示任务($display)在执行到该语句时立即执行
选通任务($strobe)要推迟到当前时阶结束时进行。
可以通过以下的程序的方针结果进一步认识二者的不同。
module task_fun;
reg [7:0] result;
reg [7:0] a,b;
reg [7:0] c,d;
reg clk;
initial
begin
clk = 0;
a = 0;
b = 0;
c = 0;
d = 0;
result = 0;
end
always #4 clk = ~clk;
always @(negedge clk)
begin
a <=$random%128;
$display("display a = %h,b = %h",a,b);
b <=$random%128;
$strobe("strobe a = %h,b = %h",a,b);
end
always @(negedge clk)
begin
c =$random%128;
$display("display c = %h,d = %h",c,d);
d =$random%128;
$strobe("strobe c = %h,d = %h",c,d);
end
always @(posedge clk)
begin
result <= a + b;
$strobe("result is %h",result);
end
endmodule
# at 0 display a = 00,b = 00 # at 0 strobe a = 24,b = 81
# at 0 display c = 89,d = 00 # at 0 strobe c = 89,d = e3
# at 4 result is a5
# at 8 display a = 24,b = 81 # at 8 strobe a = 0d,b = 0d
# at 8 display c = e5,d = e3 # at 8 strobe c = e5,d = 92
# at 4 result is 1a
a,b是非阻塞赋值,c,d是阻塞赋值。
在时间0时刻,a.b在$display显示未赋值的,strobe任务在always块结束时调用显示a,b的随机值。
在0时刻,c由于是阻塞赋值,在dsiplay调用时就被赋值,所用显示c=89,而d未被赋值。等到always结束时,c,d都被赋值,在strobe调用显示了c,d当前值。
总结:从两个任务的特性来看,用于监控非阻塞语句用$strobe任务,监控阻塞语句用$display任务。
文章评论(0条评论)
登录后参与讨论