system verilog - The best way to convert a real valued number to an integer value larger than 32 bits? -
are there system functions support more 32 bits in system verilog? want convert real-valued quantity integral value contains more 32 bits. $rtoi() system function precisely want values can represented in 32 bits or less. there built-in this, or need write own?
for concrete example, able following:
logic [41:0] test_value; initial begin test_value = $rtoi($pow(2.0, 39.5)); end
where, instead of $rtoi(), use unknown sought after system function. given correct function, expect result in test_value being initialized bit sequence 42'b1011010100000100111100110011001111111001
or possibly 42'b1011010100000100111100110011001111111010
if rounding supported.
i can write own function, avoid reinventing wheel unless there no wheel.
a implicit cast real integral gives want rounding
test_value = 2.0**39.5;
or can use explicit cast
typedef logic [41:0] uint42_t; test_value = uint42_t'(2.0**39.5);
Comments
Post a Comment