diff options
author | Andrew Waterman <waterman@eecs.berkeley.edu> | 2014-01-21 14:42:52 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@eecs.berkeley.edu> | 2014-01-21 14:43:10 -0800 |
commit | 1b4f2b1e85d6623e64d4348ef1a912a3033d14ea (patch) | |
tree | 0e7f95f87b78bcf71bc2cec82268519f0d342193 /parse-opcodes | |
parent | 714662af27924f1c3dbf81d700e67dfafa0367a0 (diff) |
Auto-generate exception cause numbers
Diffstat (limited to 'parse-opcodes')
-rwxr-xr-x | parse-opcodes | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/parse-opcodes b/parse-opcodes index 6c12a16..6b55d5d 100755 --- a/parse-opcodes +++ b/parse-opcodes @@ -40,6 +40,21 @@ arglut['cimm6'] = (15,10) arglut['cimm10'] = (14,5) arglut['cimm5'] = (9,5) +causes = [ + (0x00, 'misaligned fetch'), + (0x01, 'fault fetch'), + (0x02, 'illegal instruction'), + (0x03, 'privileged instruction'), + (0x04, 'FP disabled'), + (0x06, 'syscall'), + (0x07, 'breakpoint'), + (0x08, 'misaligned load'), + (0x09, 'misaligned store'), + (0x0A, 'fault load'), + (0x0B, 'fault store'), + (0x0C, 'accelerator disabled'), +] + csrs = [ (0x001, 'fflags'), (0x002, 'frm'), @@ -88,6 +103,8 @@ def make_c(match,mask): print '#define MASK_%s %s' % (name2, hex(mask[name])) for num, name in csrs: print '#define CSR_%s %s' % (name.upper(), hex(num)) + for num, name in causes: + print '#define CAUSE_%s %s' % (name.upper().replace(' ', '_'), hex(num)) print '#endif' print '#ifdef DECLARE_INSN' @@ -601,6 +618,16 @@ def make_chisel(): for name in namelist: print_chisel_insn(name) print '}' + print 'object Causes {' + for num, name in causes: + print ' val %s = %s' % (name.lower().replace(' ', '_'), hex(num)) + print ' val all = {' + print ' val res = collection.mutable.ArrayBuffer[Int]()' + for num, name in causes: + print ' res += %s' % (name.lower().replace(' ', '_')) + print ' res.toArray' + print ' }' + print '}' print 'object CSRs {' for num, name in csrs: print ' val %s = %s' % (name, hex(num)) |