Skip to content

Commit 2119d65

Browse files
committed
feat(decode): implement RV64I arithmetic operation instructions
1 parent eb35987 commit 2119d65

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sim/src/decode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ void decode_exec(Decode *s){
109109
INSTPAT("0000000 ????? ????? 110 ????? 01100 11", or , R, R(rd) = src1 | src2);
110110
INSTPAT("0000000 ????? ????? 111 ????? 01100 11", and , R, R(rd) = src1 & src2);
111111
// ADDW, SUBW, SLLW, SRLW, SRAW
112+
INSTPAT("0000000 ????? ????? 000 ????? 01110 11", addw , R, R(rd) = SEXT((uint32_t)src1 + (uint32_t)src2, 32));
113+
INSTPAT("0100000 ????? ????? 000 ????? 01110 11", subw , R, R(rd) = SEXT((uint32_t)src1 - (uint32_t)src2, 32));
114+
INSTPAT("0000000 ????? ????? 001 ????? 01110 11", sllw , R, R(rd) = SEXT((uint32_t)src1 << (src2 & 0x1f), 32));
115+
INSTPAT("0000000 ????? ????? 101 ????? 01110 11", srlw , R, R(rd) = SEXT((uint32_t)src1 >> (src2 & 0x1f), 32));
116+
INSTPAT("0100000 ????? ????? 101 ????? 01110 11", sraw , R, R(rd) = SEXT((int32_t)src1 >> (src2 & 0x1f), 32));
112117
// FENCE, FENCE.I
113118
// ECALL
114119
INSTPAT("0000000 00001 00000 000 00000 11100 11", ebreak , N, HALT(s->pc, R(10))); // R(10) is $a0

0 commit comments

Comments
 (0)