Hi,
in C/C++, I can declare a floating point variable (single or double precision) and later access its hexadecimal representation. For instance, I can declare a double:
double a = 75.94;
and later refer to it and obtain its hexademical representation in memory using a pointer and reading the correct amount of bytes (in this example, the equivalent hexadecimal representation in memory of the above double will be 0x4052fc28f5c28f5c).
Is there a way to achieve the same result in SystemVerilog?
Thank you!
In reply to stf.cpll:
Since SystemVerilog is mainly used to describe hardware, it’s not necessary to access the internal representation of a data type in the memory of the simulation platform.
But Verilog does provide a $realtobits and $bittoreal conversion function to give you access to the representation in memory. Note that this representation does not always translate to how a real value would be represented in hardware.
In reply to dave_59:
Hi Dave,
thank you very much! That’s precisely what I was in need of!
Yes, I think that in some case there could be some 1-LSB differences, but fortunately I operate on a small subset of values. So I can spot all differences.
Cheers!