只要参变量值发生变化,就在过程块结束时,打印列表。
一般使用时一个监控任务监视多个参数。
任何时刻只能有一个监控任务处于激活状态,下面的例子调用了两次任务,但最终控制台输出的只跟第二次有关,说明只能有一个任务激活。
module monitor_pra;
reg clkin;
reg [2:0] count;
reg [3:0] count2;
initial
begin
clkin = 1;
count = 0;
count2 = 0;
$monitor("monitor1 at %t,count = %d,count2 = %d.",$time,count,count2);
$monitor("monitor2 at %t,count = %d,count2 = %d.",$time,count,count2);
end
always #2 clkin = ~clkin;
always @(posedge clkin)
begin
count = count +1;
if(count >=5)
begin
$monitoroff; //关闭激活任务
end
else
$monitoron; //打开最近关闭的监控任务
end
always @(posedge clkin)
begin
count2 = count2 + 3;
end
endmodule
控制台输出结果:
# monitor2 at 0,count = 1,count2 = 3.
# monitor2 at 4,count = 2,count2 = 6.
# monitor2 at 8,count = 3,count2 = 9.
# monitor2 at 12,count = 4,count2 = 12.
# monitor2 at 28,count = 0,count2 = 8.
# monitor2 at 32,count = 1,count2 = 11.
# monitor2 at 36,count = 2,count2 = 14.
# monitor2 at 40,count = 3,count2 = 1.
# monitor2 at 44,count = 4,count2 = 4.
从结果中可以看到在count =4之后就没有再输出监控信息,直到count再次为0。说明$monitoroff起作用了。
文章评论(0条评论)
登录后参与讨论