summaryrefslogtreecommitdiff
path: root/parse-opcodes
diff options
context:
space:
mode:
Diffstat (limited to 'parse-opcodes')
-rwxr-xr-xparse-opcodes10
1 files changed, 8 insertions, 2 deletions
diff --git a/parse-opcodes b/parse-opcodes
index a6e0c87..0f7d449 100755
--- a/parse-opcodes
+++ b/parse-opcodes
@@ -767,6 +767,12 @@ def make_chisel():
print ' }'
print '}'
+def signed(value, width):
+ if 0 <= value < (1<<(width-1)):
+ return value
+ else:
+ return value - (1<<width)
+
def print_go_insn(name):
print '\tcase A%s:' % name.upper().replace('.', '')
m = match[name]
@@ -774,7 +780,7 @@ def print_go_insn(name):
funct3 = yank(m, 12, 3)
csr = yank(m, 20, 12)
funct7 = yank(m, 25, 7)
- print '\t\treturn &inst{0x%x, 0x%x, 0x%x, 0x%x}' % (opcode, funct3, csr, funct7)
+ print '\t\treturn &inst{0x%x, 0x%x, %d, 0x%x}' % (opcode, funct3, signed(csr, 12), funct7)
def make_go():
print '// Automatically generated by parse-opcodes'
@@ -786,7 +792,7 @@ def make_go():
print 'type inst struct {'
print '\topcode uint32'
print '\tfunct3 uint32'
- print '\tcsr uint32'
+ print '\tcsr int64'
print '\tfunct7 uint32'
print '}'
print