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

How to use clocking statement in systemverilog?

现在,我正尝试在 systemverilog 中使用时钟语句,如下所示。

interface itf();
...

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

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

...
endinterface

正如我所想,上面使用输出和输入的代码有延迟。 read,enable,addr有5ns的延迟,data有3ns的延迟。 但效果不佳。你能给点建议吗? 如果可以的话,你能给我看一下带有这些代码的示例代码吗?

我想看看输入#3ns 输出#5ns 的效果 谢谢

更新1

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

如您所见,我想测试一下 "default input #3ns output #5ns;" 和 "default input #3ns //output #5ns;"

但默认输入#3ns //输出#5ns;不起作用。

还有我们如何证明 tb.read 值?

更新2.

我是否必须像下面这样修改?

 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 

更新 3

我想到了时钟语句。 但我想知道什么样的事件使用时钟输入。 clocking的输入使用了什么样的例子?

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