Hi All ,
I am trying the following code :
`timescale 10 ns / 1 ps
module top ;
parameter d = 1.54345 ; // As RHS is real no. , d is parameter of real type
initial begin
$display("parameter d = %0f",d);
$display("parameter d = %0t",d);
end
endmodule
The output I observe :
parameter d = 1.543450
parameter d = 15434
Since 0.1ps == 0.0001ns , real numbers are rounded to 4 decimal places .
Using %f / %0f we observe real nos. , hence we observe the entire real no. 1.54345
Using %t / %0t time precision of 1ps would be used ( as there is No explicit $timeformat defined ) ,
Section 22.7 of LRM says : Parameter d retains its value no matter what timescale is in effect
However my expectation was that first the real no. would be rounded off to 4 decimal places i.e 1.5435 .
Then it would be scaled to time unit of 10ns i.e 15.435ns which is 15435ps .
Hence I expected 2nd display statement to be : parameter d = 15435 ( which is different than the output )
My 2nd question is regarding the rounding-off of real numbers .
What gets rounded-off and when does it occur ?
Like the parameter d isn’t rounded-off to 4 decimal places ( as observed in output via %f )
However had we used delay as : #d ;
**Will the delay first be rounded-off to 4 decimal places first i.e 1.5435 before calculating simulation time corresponding to the delay ?
**
i.e #d would then correspond to 15.435ns of delay ( scaled to time unit of 10ns )