Reputation: 23
I was trying to print the $realtime for the following timescale setting:
`timescale 1ns/10ps
initial begin
#10;
$display(" %0t",$realtime);
$display($realtime);
end
The result that gets prints is:
1000
10
I am just curious as to what is different in using format specifier in printing realtime? Correct me if I am wrong. I believe it is printing 1000 (10 *10ps = 1000 ns) because of the time precision. But what is the reason for the difference?
Upvotes: 2
Views: 15158
Reputation: 13987
The $timeformat
system task is used to set the format of the output when the %t
format specifier is used. It should only be called once (if it is called more than once, the last call will override the previous ones). It has 4 parameters: they are:
$timeformat(<units>, <precision>, <suffix>, minimum field width>);
units : log base 10 of the unit (eg -9 is ns)
precision : the number of decimal places
suffix : a string (eg "ns")
minimum field width : the minimum field width
$display(" %0t",$realtime);
is printing the time according to the time format set up by the $timeformat
system task. As you haven't called the $timeformat
system task, the default values are used. They are:
units : the simulation precision (10ps in your case)
precision : 0
suffix : null string
minimum field width : 20
$display($realtime);
displays the value returned from the $realtime
system function as a decimal integer - 10
in your case.
Upvotes: 5