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
According to IEEE Std 1800-2017 SystemVerilog 3.1a Language Reference Manual, Accellera’s Extensions to Verilog®, Section 3.14 Casting, the syntax before the ' can be:
a decimal-based literal number >0 (the size as a literal)
the signing (signed or unsigned)
a type identifier, optionally package-scoped (with ::)
Unless I missed something (a newer version of the standard?), the casts used to build IsaCode in core/csr_regfile.sv are not covered by the official specification of the language.
If we do not comply with the standard, we have no guarantee that the tools perform as we expect.
So we should probably find a way to comply with the standard.
Do we really need these casts?
All the values around the casts can fit in a signed 32 bit number, which is IIRC the default size for integers.
The one which is the closest to overflow is MXL, which does not have the cast.
So we could probably remove all these casts?
Later in the same file, we use MIP values, which are little integer constants (at most 4096).
So these casts should probably be removed there too.
To avoid implicit cast warnings, we could probably make the constants unsized (e.g. int unsigned).
After all, if we always re-size them, there is no real reason to have them sized.
If we really need these casts, the standard suggests to use a local typedef <the type> the_type_alias; (types with generic parameters do not exist in SystemVerilog so we cannot put them in a package) and then cast with the_type_alias'(expression).
The text was updated successfully, but these errors were encountered:
cathales
added
the
Type:Bug
For bugs in the RTL, Documentation, Verification environment or Tool and Build system
label
Mar 12, 2025
Is there an existing CVA6 bug for this?
Bug Description
According to IEEE Std 1800-2017 SystemVerilog 3.1a Language Reference Manual, Accellera’s Extensions to Verilog®, Section 3.14 Casting, the syntax before the
'
can be:::
)Unless I missed something (a newer version of the standard?), the casts used to build
IsaCode
incore/csr_regfile.sv
are not covered by the official specification of the language.If we do not comply with the standard, we have no guarantee that the tools perform as we expect.
So we should probably find a way to comply with the standard.
Here is an example from
csr_regfile
:cva6/core/csr_regfile.sv
Lines 282 to 295 in c3fe25a
Do we really need these casts?
All the values around the casts can fit in a signed 32 bit number, which is IIRC the default size for integers.
The one which is the closest to overflow is MXL, which does not have the cast.
So we could probably remove all these casts?
Later in the same file, we use MIP values, which are little integer constants (at most 4096).
So these casts should probably be removed there too.
To avoid implicit cast warnings, we could probably make the constants unsized (e.g.
int unsigned
).After all, if we always re-size them, there is no real reason to have them sized.
If we really need these casts, the standard suggests to use a local
typedef <the type> the_type_alias;
(types with generic parameters do not exist in SystemVerilog so we cannot put them in a package) and then cast withthe_type_alias'(expression)
.The text was updated successfully, but these errors were encountered: