Open
Description
Describe the bug
I think the IDL functions lowest_set_bit
and highest_set_bit
are defined slightly incorrectly.
In reviewing #471, the following assignment was being slightly corrected:
X[rd] = (xlen() - 1) - $signed(lowest_set_bit(X[rs1]));
X[rd]
andX[rs1]
are of typeBits[XLEN]
(I believe, as BUILTIN).xlen()
is defined:(I'll note that Extension B: fix ctz instruction IDL code #471 is removing the use offunction xlen { returns Bits<8>
xlen()
, but it's useful for additional context here.)- I confess not knowing where
$signed
is defined (?) lowest_set_bit(...)
is defined:function highest_set_bit { returns XReg arguments XReg value [...] function lowest_set_bit { returns XReg arguments XReg value
It makes sense to me that the *set_bit
functions accept an XReg
parameter.
It does not make sense to me that they return an XReg
value. Ignoring $signed
, the calculation is using register values to compute an integer value (less than or equal to XLEN).
Should these functions instead return Bits<8> (or essentially Bits<log2(XLEN)>, but we presume that 8 is sufficient)?