In reply to dave_59:
Hi Dave,
I reviewed this code, made a few changes, and observed the following.
`timescale 10ns / 10ps
module top ;
initial begin
static real rtdelay = 800.559 ; // What gets stored in rtdelay ?
static time tdelay = 800.509 ; // Rounded to 801
$display(" ",$realtime ," At T:%t" , rtdelay );
$display(" At T:%t %t\n" , $realtime , rtdelay );
#rtdelay;
$display(" ",$realtime ," At T:%t" , rtdelay );
$display(" At T:%t %t\n" , $realtime , rtdelay );
#tdelay;
$display(" ",$realtime ," At T:%t" , tdelay );
$display(" At T:%t %t\n" , $realtime , tdelay );
$timeformat( -10 , 5 , "ps");
$display(" ",$realtime ," At T:%t" , tdelay );
$display(" At T:%t %t" , $realtime , tdelay );
end
endmodule
The output is :
# vsim -voptargs=+acc=npr
# run -all
# 0 At T: 800559
# At T: 0 800559
#
# 800.559 At T: 800559
# At T: 800559 800559
#
# 1601.559 At T: 801000
# At T: 1601559 801000
#
# 1601.559 At T: 80100.00000ps
# At T: 160155.90000ps 80100.00000ps
# exit
- Here, as you can see I have displayed the $realtime in two ways. First-one is using $realtime and the second one uses $realtime along with %t/%0t. We got different results.
Is it because the unit or format of $time or $realtime depends on the time unit and %t/%0t depends on time precision?
Another point is - $timeformat this system function targets only time-precision.
If you go through the last two displays, you will see that in the first one 1601.559, we got after doing the operation on 1601559. 1601559 is in ps and unit-time was in ns. That’s why
$realtime = 1601559 * (current_time_unit / target_time_unit)=1601559 * .001 = 1601.559.
If we consider this theory as the main reason / correct explanation, then in the second display we should have got 160.1559 instead of 1601.559.