- 系统函数
- 显示
- 仿真控制
- 时间($time)
- 文件操作
- 预编译语句
- 其他仿真语句
1.概述
对Verilog中用于验证的常用函数进行总结,方便以后使用。
2.系统函数
系统任务和系统函数的名字都是用字符"$"开头。
2.1 显示
- $display
用于字符串打印,类似于C/C++中的printf
$display("带格式字符串",参数1,参数2,...);
module sdisp1
integer i;
reg [3:0] x;
initial begin
i=21;
x=4'h3;
$display("1\t%d\n2\t%h\\",i,x);
end
endmodule
- $write
与$display一样,$write也是输出显示到标准输出;\ $display会在文本后加一个换行,而$write是不加的。
$wirte("带格式字符串",参数1,参数2,...);
2.2 $strobe 和$monitor
$strobe和$monitor也可以完成显示任务,它们在有些情况下可以弥补$display的不足,语法如下:
$strobe("带格式字符串",参数1,参数2,...);
$monitor("带格式字符串",参数1,参数2,...);
Demo code:
`timescale 1ns/1ps
module sdisp3;
reg [1:0]a;
reg b;
initial $monitor("\$monitor: a=%b",a);
initial begin
b=0;
a=0;
$strobe("\$strobe: a=%b",a);
a