|
`timescale是VerilogHDL 中的一种时间尺度预编译指令,它用来定义模块的仿真时的时间单位和时间精度。格式如下:
`timescale 仿真时间单位/时间精度
注意:用于说明仿真时间单位和时间精度的数字只能是1、10、100,不能为其它的数字。而且,时间精度要比时间单位小。最多两个一样大。比如:下面定义都是对的:
`timescale 1ns/1ps
`timescale 100ns/100ns
下面的定义是错的:
`timescale 1ps/1ns
时间精度就是模块仿真时间和延时的精确程序,比如:定义时间精度为10ns,那么时中所有的延时至多能精确到10ns,而8ns或者18ns是不可能做到的。下面举个简单的例子说明一下:
`timescale 100ns / 10ns
module muti_delay( din, dout1 );
input din;
output dout1;
wire din;
reg dout1;
always @(din)
#3.14 dout1 = din;
endmodule
我们可以看到,本意是要延时100*3.14=314ns后将din 的值赋给dout1,但是它在310ns 的时候就赋值了,为什么呢?这就是时间精度的问题了。时间精度定义为10ns,因此不能精确到4ns,经过四舍五入后,“#3.14”变成了“#3.1”。当然就是在310ns的时候赋值了!
|
|