Skip to content

Commit 1b1692b

Browse files
authored
FIXES ISSUE #473 : lowest/highest_set_bit functions should return a Bits type? (#906)
This PR fixes #473. The ```lowest_set_bit``` and ```highest_set_bit``` functions were returning XReg (i.e., Bits<XLEN>) though they only compute a position index. Updated to return Bits<8> instead, which is sufficient and semantically correct. All smoke tests and IDL validations pass successfully. @ThinkOpenly please review this and request if any further chnaged are required !! Signed-off-by: Om Santosh Suneri <[email protected]>
1 parent 6bcc730 commit 1b1692b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spec/std/isa/isa/util.idl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ function has_virt_mem? {
4848
}
4949

5050
function highest_set_bit {
51-
returns XReg
51+
returns Bits<8>
5252
arguments XReg value
5353
description {
5454
Returns the position of the highest (nearest MSB) bit that is '1',
5555
or -1 if value is zero.
5656
}
5757
body {
58-
for (U32 i=xlen()-1; i >= 0; i--) {
58+
for (Bits<8> i=xlen()-1; i >= 0; i--) {
5959
if (value[i] == 1) {
6060
return i;
6161
}
@@ -67,14 +67,14 @@ function highest_set_bit {
6767
}
6868

6969
function lowest_set_bit {
70-
returns XReg
70+
returns Bits<8>
7171
arguments XReg value
7272
description {
7373
Returns the position of the lowest (nearest LSB) bit that is '1',
7474
or XLEN if value is zero.
7575
}
7676
body {
77-
for (U32 i=0; i < xlen(); i++) {
77+
for (Bits<8> i=0; i < xlen(); i++) {
7878
if (value[i] == 1) {
7979
return i;
8080
}

0 commit comments

Comments
 (0)