Now, I'm trying to use clocking statement in systemverilog as following.
interface itf();
...
clocking cb @(posedge clk);
default input #3ns output #5ns;
output read,enable,addr;
input negedge data;
endclocking
...
endinterface
As I think, above code that are using output and input have delay. read,enable,addr have 5ns delay, and data is delayed 3ns. but It does not work well. would you please give any advice? If you can, Would you show me example code with that codes?
I want to see that works which input #3ns and output #5ns Thanks.
update1
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
As you can see the code, I want to test about the "default input #3ns output #5ns;" and "default input #3ns //output #5ns;"
But default input #3ns //output #5ns; does not work.
Also How can we proving the tb.read value?
update2.
Should I have to modity like as following?
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
update 3
I got it the idea about clocking statement. But I want to know what kind of event use the input of clocking . What kind of examples are used in the input of clocking?