verilog学习——系统任务和函数/system tasks and functions
(一)Verilog显示任务/task
显示系统任务(display system tasks)用于显示信息和调试信息,以跟踪日志文件中的模拟流程,有助于更快的调试。可以通过不同的显示任务组和格式打印值。
1.显示/写入任务(tasks)
语法:
$display(<list_of_arguments>);
$write(<list_of_arguments>);
display和display 和display和write都按照参数列表中的出现顺序显示参数。
$write不会将换行符添加到其字符串的末尾。
2.verilog storbes
strobe在当前增量时间步长的末尾打印变量的最终值,并与strobe 在当前增量时间步长的末尾打印变量的最终值,并与strobe在当前增量时间步长的末尾打印变量的最终值,并与display具有类似的格式,
module tb;
initial begin
reg [7:0] a;
reg [7:0] b;
a = 8'h2D;
b = 8'h2D;
#10; // Wait till simulation reaches 10ns
b <= a + 1; // Assign a+1 value to b
$display ("[$display] time=%0t a=0x%0h b=0x%0h", $time, a, b);
$strobe ("[$strobe] time=%0t a=0x%0h b=0x%0h", $time, a, b);
#1;
$display ("[$display] time=%0t a=0x%0h b=0x%0h", $time, a, b);
$strobe ("[$strobe] time=%0t a=0x%0h b=0x%0h", $time, a, b);
end
endmodule
[$display] time=10 a=0x2d b=0x2d
[$strobe] time=10 a=0x2d b=0x2e
[$display] time=11 a=0x2d b=0x2e
[$strobe] time=11 a=0x2d b