Hi,
I want to pass a real value to the function (or task) in verilog. That function will do few calculations in real data type and should return a real value to my module. How can I implement this ? Please explain with a small example.
Thanks dave_59, this is very useful. But I am having a small problem. I am trying to round off a real value ( For eg. 0.002625 to 0.003) as shown in code below, but here its giving wrong result. Could you please suggest any solution?
module top;
function real round_off(input real a);
real ax1000;
integer a_temp;
begin
ax1000 = a * 1000;
a_temp = ax1000;
round_off = a_temp / 1000;
end
endfunction
real X;
initial begin
X =0.002625;
$display("%g",round_off(X));
end
endmodule