If I try to use calculations with infinity results (in float32 representation) there are some unexpected results, as if the calculations were in double precision. Simple casts to shortreal doesn't work, only conversion to bits and back again.
module tb_inf;
shortreal tmp1, tmp2, tmp3;
initial begin
tmp1 = 2e30;
tmp2 = 1e30;
tmp3 = shortreal'(tmp1*tmp2);
$display("inf test1 %e ", shortreal'(tmp3));
$display("inf test2 %e ", $bitstoshortreal($shortrealtobits(tmp3)));
end
endmodule
In Vivado and modelsim I get:
inf test1 2e60
inf test2 inf
Is the second way of conversion is best for correct calculations with float?