Skip to content

Commit 9046b6d

Browse files
committed
wip
1 parent ee072a9 commit 9046b6d

File tree

6 files changed

+4609
-23
lines changed

6 files changed

+4609
-23
lines changed

src/decode.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdlib.h>
88

99
#include "decode.h"
10+
#include "encoding.h"
1011
#include "riscv_private.h"
1112

1213
/* decode rd field
@@ -1959,7 +1960,7 @@ static inline bool op_mvx(rv_insn_t *ir, const uint32_t insn) {}
19591960
static inline bool op_v(rv_insn_t *ir, const uint32_t insn)
19601961
{
19611962
uint32_t funct3_mask = 0x7000;
1962-
switch (insn & funct3_mask) {
1963+
switch ((insn & funct3_mask) >> 7) {
19631964
case 0:
19641965
return op_ivv(ir, insn);
19651966
case 1:
@@ -1977,6 +1978,24 @@ static inline bool op_v(rv_insn_t *ir, const uint32_t insn)
19771978
default:
19781979
return false;
19791980
}
1981+
1982+
if ((insn & MASK_VSETVLI) == MATCH_VSETVLI) {
1983+
// vsetvli
1984+
ir->rd = (insn >> 7) & 0x1f;
1985+
ir->rs1 = (insn >> 15) & 0x1f;
1986+
ir->zimm = (insn >> 20) & 0x7ff;
1987+
} else if ((insn & MASK_VSETIVLI) == MATCH_VSETIVLI) {
1988+
// vsetivli
1989+
ir->rd = (insn >> 7) & 0x1f;
1990+
ir->uimm = (insn >> 15) & 0x1f;
1991+
ir->zimm = (insn >> 20) & 0x3ff; // zimm[9:0]
1992+
1993+
} else if ((insn & MASK_VSETVL) == MATCH_VSETVL) {
1994+
// vsetvl
1995+
ir->rd = (insn >> 7) & 0x1f;
1996+
ir->rs1 = (insn >> 15) & 0x1f;
1997+
ir->rs2 = (insn >> 20) & 0x1f;
1998+
}
19801999
}
19812000

19822001
/* handler for all unimplemented opcodes */

src/decode.h

+2
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ typedef struct rv_insn {
344344

345345
#if RV32_HAS(EXT_RVV)
346346
uint8_t vm;
347+
uint8_t zimm;
348+
uint8_t uimm;
347349
#endif
348350
/* fuse operation */
349351
int32_t imm2;

0 commit comments

Comments
 (0)