在testbench中我们经常需要加不同的delay来搭建direct pattern,可以通过plusargs来传递参数。如何实现呢?
`timescale 1ns/1fs
module top ;
task automatic delay_fs(longint val);
longint idx = 0;
while(idx < val)begin
#1fs;
idx++
end
endtask
initial begin
longint time_mark;
if($value$plusargs("START_TIME=%0f",time_mark))begin//用%f,为了兼容questa,当time_mark比较大时,vcs和questa行为不一致
delay_fs(time_mark);
@(posedge dut.clk);
force dut.src = 1;
...
end
end
endmodule