如果设计中多个模块带有自身的`timescale,编译时模拟器总是定义在所有模块的最小时延精度上,并且所有模块中的时延都自动地换算为到最小试验精度上。
附录: Counter源代码:
`timescale 1ns/100ps
module Counter (
input CLK,
input RST_N,
output [3:0] CNT
);
reg [3:0] cnt;
assign CNT = cnt;
always@(posedge CLK, negedge RST_N) begin
if (!RST_N)
cnt <= #5 4'h0;
else
cnt <= #0 cnt + 1'b1;
end
endmodule
Counter_tb源代码:
`timescale 1ns/100ps
module Counter_tb ;
wire [3:0] CNT ;
reg RST_N ;
reg CLK ;
Counter
DUT (
.CNT (CNT ) ,
.RST_N (RST_N ) ,
.CLK (CLK ) );
//http://wenku.baidu.com/view/cd93f34ecf84b9d528ea7a95.html
initial begin
#0 CLK = 1'b0;
RST_N = 1'b0;
#5 RST_N = 1'b1;
end
// 50MHz
always #10 CLK = ~CLK;
endmodule
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-38414-6.html
你好
别随便说同志不合法