System verilog 如何在systemverilog中使用时钟语句?

System verilog 如何在systemverilog中使用时钟语句?,system-verilog,System Verilog,现在,我尝试在systemverilog中使用clocking语句,如下所示 interface itf(); ... clocking cb @(posedge clk); default input #3ns output #5ns; output read,enable,addr; input negedge data; endclocking ... endinterface 我认为,上面使用输出和输入的代码有延迟。 读取、启用、添加延迟5ns,数据延迟3ns。 但效果

现在,我尝试在systemverilog中使用clocking语句,如下所示

interface itf();
...

clocking cb @(posedge clk); 
default input #3ns output #5ns; 

output read,enable,addr; 
input negedge data; 
endclocking 

...
endinterface
我认为,上面使用输出和输入的代码有延迟。 读取、启用、添加延迟5ns,数据延迟3ns。 但效果并不理想。你能给点建议吗? 如果可以的话,你能给我看一下带有这些代码的示例代码吗

我想看看哪个输入3ns和哪个输出5ns起作用 谢谢

更新1
moduletop();
逻辑时钟;
初始开始
clk=0;
永远#5CLK=~clk;
结束
创新及科技基金u_创新及科技基金(.clk(clk));
dut u_dut(u_itf);
tb________________)tb(u_itf);;
端模
模块tb(itf tb);
初始开始

tb.read如果搜索,可以找到许多时钟块示例。给你。我在代码中看到的一些问题是,您正在使用非阻塞分配和来自测试台的时钟块驱动语句对读取信号进行同步分配。为接口定义了使用时钟块的一般规则,时钟块信号是您应该与之交互的唯一信号。其中包括用于同步的事件控件。您不应该使用
#10
@(posedge tb.clk)
-只需使用
@(tb.cb)

请解释您所说的“但它不能正常工作”是什么意思。@dave_59:我不确定我是否完全理解systemverilog中的时钟语句,但我知道如果我们在接口中使用时钟语句,那么默认延迟确实会影响定时。特别是,如果我们使用输入3ns,那么输入信号延迟3ns。但我的模拟没有受到影响。顺便说一句,如果我使用输出5ns,那么输出信号都会受到5ns延迟的影响。所以我需要关于完全能够使用时钟语句的示例代码。另一件事是重复标识符,这使得代码很难理解。虽然使用名为tb的模块和名为tb的接口端口(以及模块dut和modport dut)是合法的,但这使讨论变得很困难。谢谢,我想按照您的命令修改我的代码。但我还是不太明白。因此,为了理解我,请您帮助如何实现您的修改建议?我已经更新了关于repeat的示例代码。实际上,最初的代码来自这里,我已经扩展和修改了,以了解时钟语句的字符。
module top();
logic clk;
initial begin
clk =0;
forever #5 clk= ~clk;
end
itf u_itf(.clk(clk));
dut u_dut(u_itf);
tb_u_tb(u_itf);
endmodule

module tb (itf tb);
initial begin
tb.read <= 0;
repeat(3) #10 tb.read <= ~tb.read;
$finish;
end

always @(posedge tb.clk) begin
tb.cb.read <=tb.cb;
if (tb.cb.enable)
tb.data  <= tb.data+1;
end

initial begin 
tb.data =0;
end

endmodule

module dut(itf dut_itf);
always  @(posedge dut_itf.clk) begin
if (dut_itf.read)
dut_itf.enable <= 1;
end

initial begin 
dut_itf.enable <= 0;
end
endmodule

interface itf(input clk);
logic read,enable;
logic [7:0]  addr, data;
modport dut(input read, addr, output data, enable);
modport tb(clocking cb);

clocking cb@(posedge clk);
default input #3ns //output #5ns; //Here is my test point.
output data, addr, read;
input enable;
endclocking


endinterface
 module tb (itf tb);
 initial begin 
 tb.cb.read <= 0; 
 repeat(3) tb.cb.read <= ~tb.cb.read;
 $finish;
 end 
 always @( tb.cb) begin
 tb.cb.read <=tb.cb; 
 if (tb.cb.enable)
 tb.cb.data <= tb.cb.data+1; 
 end 
 initial begin 
 tb.cb.data =0; 
 end endmodule