if you set timescale to 1ps/1ps, but still got #1=1ns in your simulation, you’d better print out timescale before you start to wait #50000 by using cmd below:
$printtimescale(path)
Generally, if have other files re-define the timescale, your wait time will be different without notifying you.
So if there are several persons working on the same environment and you only handle part of the env(especially RTL also have the right to change timescale), better define your own wait task inside tb_top where you can call in sub-file:
timeunit 1ns
timeprecision 1ps
task dly_ns(input real delay);
#delay;
endtask:dly_ns
task dly_us(input real delay);
#(delay*1000);
endtask:dly_us
Now you can call dly_ns(num) or dly_us(num) as you want.
Thanks for your help, I add these ns_task , ps_task and us_task in the tb_top , and call these task in my testcase , I get the ps ns and us delay cocrrectly.
But there is still a question I want to ask , I put “timescale 1ps/1ps” in the top of the testcase just for test ,and call the $printtimescale(path), the sim_log shows me that the timescale is still “timescale 1ns/1p”,could you tell me why ?
timescale has a property to pick whatever the latest definition is. Even if you have specified 1ps/1ps there might be submodule or tb blocks whose timescale might be different and it would be overwritten.
It is suggested to check ifdef TIMESCALE … before your task/method and update it back with the required timescale.