//`timescale 1ns/100fs
module tim();
timeunit 1ns;
timeprecision 100fs;
reg i;
initial
begin
i=0;
#7;
i=1;
$display("STATEMENT 1 :: time is %0t",$time);
#7;
$finish;
end
initial $printtimescale();
endmodule
In the above code output of $display is “time is 70000”. if i want to print the time with timeunit , is there any way i can do the same without printing ns/ps from the display statement.
$timeformat affects how the %t is printed in $display. So you specify $timeformat only once as shown above in an initial block, then any $display having %t will function as you described. By default %t will print time w.r.t. the smallest precision in the simulation cluster with no time units. However you can change the default as above. If you added the above $timeformat code in your example above, your $display will print time as “7.00 ns” instead of “70000”. Does this answer your question?
In reply to ayehia:
Maybe this was already understood, but just to clarify, %t can be used by any of the print formatting tasks, not just $display. UVM users should not be using $display.