Skip to content

Commit 0b6ccec

Browse files
committed
feat(decode): implement fence, fence.i as nop
1 parent 2119d65 commit 0b6ccec

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sim/src/decode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extern CPU_state cpu;
1111
#define Mr mem_read
1212
#define Mw mem_write
1313
#define HALT(thispc, code) halt_trap(thispc, code)
14+
#define NOP do {} while(0)
1415

1516
enum {
1617
TYPE_I, TYPE_U, TYPE_S,
@@ -115,6 +116,8 @@ void decode_exec(Decode *s){
115116
INSTPAT("0000000 ????? ????? 101 ????? 01110 11", srlw , R, R(rd) = SEXT((uint32_t)src1 >> (src2 & 0x1f), 32));
116117
INSTPAT("0100000 ????? ????? 101 ????? 01110 11", sraw , R, R(rd) = SEXT((int32_t)src1 >> (src2 & 0x1f), 32));
117118
// FENCE, FENCE.I
119+
INSTPAT("0000??? ????? 00000 000 00000 00011 11", fence , I, NOP);
120+
INSTPAT("0000000 00000 00000 000 00000 00011 11", fencei , I, NOP);
118121
// ECALL
119122
INSTPAT("0000000 00001 00000 000 00000 11100 11", ebreak , N, HALT(s->pc, R(10))); // R(10) is $a0
120123
// CSRRW, CSRRS, CSRRC, CSRRWI, CSRRSI, CSRRCI

0 commit comments

Comments
 (0)