You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Moore] Add shortreal type, bit <-> real conversions (#8985)
This PR disambiguates the RealType into 32-Bit real types ("shortreal") and 64-Bit real types ("real").
It adds support for materializing moore.shortreal from shortreal-specific statements like
localparam shortreal sr = 4.532;
as well.
Apart from this new type disctinction, this PR also adds support for the builtins $shortrealtobits, $bitstoshortreal, $realtobits and $bitstoreal.
When working through the builtins mentioned above, I noticed that the shortreal type was missing.
I decided to add it as !moore.shortreal since the distinction between $shortrealtobits and $realtobits would not really make sense in the previous type system.
To keep backwards compatibility (and also because most real values in Verilog are actually real, not shortreal), I chose to default the new width parameter of RealType to 64 and add a TypeBuilder that accepts "widthless" construction and defaults to 64 Bit.
While Section 20.5 "Conversion functions" is unspecific about the domain of the "bits" end of the conversion functions, I infer these two lines to mean two-valued bit rather than logic vectors only:
$realtobits converts values from a real type to a 64-bit vector representation of the real number.
$bitstoreal converts a bit pattern created by $realtobits to a value of the real type.
0 commit comments