Skip to content

Commit

Permalink
Include rs1 values in Go instruction opcodes. (#254)
Browse files Browse the repository at this point in the history
Some of the instructions in the V extension encode part of the opcode
in the rs1 field. These values are not currently included in the Go
instruction opcodes - fix this by adding an rs1 field and populating
it with the relevant values.
  • Loading branch information
4a6f656c authored Jun 27, 2024
1 parent 5ce8977 commit 5c03ec5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ def make_go(instr_dict):
type inst struct {
opcode uint32
funct3 uint32
rs1 uint32
rs2 uint32
csr int64
funct7 uint32
Expand All @@ -960,11 +961,12 @@ def make_go(instr_dict):
enc_match = int(instr_dict[i]['match'],0)
opcode = (enc_match >> 0) & ((1<<7)-1)
funct3 = (enc_match >> 12) & ((1<<3)-1)
rs1 = (enc_match >> 15) & ((1<<5)-1)
rs2 = (enc_match >> 20) & ((1<<5)-1)
csr = (enc_match >> 20) & ((1<<12)-1)
funct7 = (enc_match >> 25) & ((1<<7)-1)
instr_str += f''' case A{i.upper().replace("_","")}:
return &inst{{ {hex(opcode)}, {hex(funct3)}, {hex(rs2)}, {signed(csr,12)}, {hex(funct7)} }}
return &inst{{ {hex(opcode)}, {hex(funct3)}, {hex(rs1)}, {hex(rs2)}, {signed(csr,12)}, {hex(funct7)} }}
'''

with open('inst.go','w') as file:
Expand Down

0 comments on commit 5c03ec5

Please sign in to comment.