Skip to content

Commit f5d2201

Browse files
authored
Extension B: fix ctz instruction IDL code (#471)
* Extension B: fix ctz instruction IDL code Signed-off-by: Albert Yosher <[email protected]> * B extension: fixing ctz and ctzw instructions Signed-off-by: Albert Yosher <[email protected]> * B extensions: additional fix for ctz instruction to support case when xlen() != XLEN Signed-off-by: Albert Yosher <[email protected]> --------- Signed-off-by: Albert Yosher <[email protected]>
1 parent 0d876c4 commit f5d2201

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/inst/B/ctz.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ operation(): |
3030
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
3131
}
3232
33-
X[rd] = (xlen() - 1) - $signed(lowest_set_bit(X[rs1]));
33+
if (xlen() == 32) {
34+
X[rd] = lowest_set_bit(X[rs1][31:0]);
35+
} else {
36+
X[rd] = lowest_set_bit(X[rs1]);
37+
}
3438
3539
sail(): |
3640
{

arch/inst/B/ctzw.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ operation(): |
3131
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
3232
}
3333
34-
X[rd] = (xlen() - 1) - $signed(lowest_set_bit(X[rs1][31:0]));
34+
X[rd] = lowest_set_bit(X[rs1][31:0]);
3535
3636
sail(): |
3737
{

0 commit comments

Comments
 (0)