I want to do a fraction arithmetic and then display the results. I know that $display displays in integer. But what is the solution to display the exact amount as eg I want to display 10/3 = 3.3 but I get displayed 3.0000. This is my code. I do not want to use real data type here.
`timescale 1ns/1ps
module fp_check
(a,b,c,d);
input logic signed [7:0] a;
input real b;
output real c;
output logic [7:0] d;
assign c = a*2;
assign d = b+1;
endmodule
module fp_test;
logic signed [7:0] a;
real b;
real c;
logic signed [7:0] d;
initial
begin
a = 3.3333;
b = 11.7;
$display("a =%f, b=%f,c=%f,d=%f", a,b,c,d);
end
fp_check s (.a(a), .b(b), .c(c), .d(d));
endmodule
The output I get is a =3.000000, b=11.700000,c=0.000000,d=0.000000
What I expect is a =3.333333, b=11.700000,c=6.666666,d=12.700000