在时钟块中,加入default input output可以自定义采样和驱动时间。
其中input是指时钟块在时钟沿后多久去采样输入,output是指多久去驱动
如果没有default,也是会有默认值的,input为1step,output为0。
clocking cb @(posedge clk);
default input #1step output #1ps;
output c;
endclocking
以代码为例,input #1step是指在时钟沿后1step去采样,output #1ps是指在1ps后驱动。
但事情并没有这么简单!
首先看如下代码示例:
interface tf(input clk);
logic [3:0] a,b,c;
clocking cb @(posedge clk);
default input #1step output #1ps;
input a;
output c;
endclocking
endinterface
module test;
bit clk = 0;
tf t(clk);
rd rd_test;
initial begin
forever begin
#5ns;
clk = ~clk;
end
end
initial begin
t.a = 0;
t.b = 0;
t.c = 0;
repeat(5)@(posedge clk);
t.a <= 1;

最低0.47元/天 解锁文章
7228

被折叠的 条评论
为什么被折叠?



