format black
parent
e1fbe4f11d
commit
5515c7795c
@ -1,2 +1,2 @@
|
|||||||
from .decoder import decode, RISCV_REGS
|
from .decoder import decode, RISCV_REGS
|
||||||
from .formatter import format_ins
|
from .formatter import format_ins
|
||||||
|
@ -1,6 +1,34 @@
|
|||||||
RISCV_REGS = [
|
RISCV_REGS = [
|
||||||
'zero', 'ra', 'sp', 'gp', 'tp', 't0', 't1', 't2',
|
"zero",
|
||||||
's0', 's1', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7',
|
"ra",
|
||||||
's2', 's3', 's4', 's5', 's6', 's7', 's8', 's9', 's10', 's11',
|
"sp",
|
||||||
't3', 't4', 't5', 't6'
|
"gp",
|
||||||
|
"tp",
|
||||||
|
"t0",
|
||||||
|
"t1",
|
||||||
|
"t2",
|
||||||
|
"s0",
|
||||||
|
"s1",
|
||||||
|
"a0",
|
||||||
|
"a1",
|
||||||
|
"a2",
|
||||||
|
"a3",
|
||||||
|
"a4",
|
||||||
|
"a5",
|
||||||
|
"a6",
|
||||||
|
"a7",
|
||||||
|
"s2",
|
||||||
|
"s3",
|
||||||
|
"s4",
|
||||||
|
"s5",
|
||||||
|
"s6",
|
||||||
|
"s7",
|
||||||
|
"s8",
|
||||||
|
"s9",
|
||||||
|
"s10",
|
||||||
|
"s11",
|
||||||
|
"t3",
|
||||||
|
"t4",
|
||||||
|
"t5",
|
||||||
|
"t6",
|
||||||
]
|
]
|
||||||
|
@ -1,81 +1,81 @@
|
|||||||
from typing import Dict, Tuple
|
from typing import Dict, Tuple
|
||||||
|
|
||||||
MCAUSE_TRANSLATION: Dict[Tuple[int, int], str]= {
|
MCAUSE_TRANSLATION: Dict[Tuple[int, int], str] = {
|
||||||
(1, 0): 'User software interrupt',
|
(1, 0): "User software interrupt",
|
||||||
(1, 1): 'Supervisor software interrupt',
|
(1, 1): "Supervisor software interrupt",
|
||||||
(1, 3): 'Machine software interrupt',
|
(1, 3): "Machine software interrupt",
|
||||||
(1, 4): 'User timer interrupt',
|
(1, 4): "User timer interrupt",
|
||||||
(1, 5): 'Supervisor timer interrupt',
|
(1, 5): "Supervisor timer interrupt",
|
||||||
(1, 7): 'Machine timer interrupt',
|
(1, 7): "Machine timer interrupt",
|
||||||
(1, 8): 'User external interrupt',
|
(1, 8): "User external interrupt",
|
||||||
(1, 9): 'Supervisor external interrupt',
|
(1, 9): "Supervisor external interrupt",
|
||||||
(1, 11): 'Machine external interrupt',
|
(1, 11): "Machine external interrupt",
|
||||||
(0, 0): 'Instruction address misaligned',
|
(0, 0): "Instruction address misaligned",
|
||||||
(0, 1): 'Instruction access fault',
|
(0, 1): "Instruction access fault",
|
||||||
(0, 2): 'Illegal instruction',
|
(0, 2): "Illegal instruction",
|
||||||
(0, 3): 'Breakpoint',
|
(0, 3): "Breakpoint",
|
||||||
(0, 4): 'Load address misaligned',
|
(0, 4): "Load address misaligned",
|
||||||
(0, 5): 'Load access fault',
|
(0, 5): "Load access fault",
|
||||||
(0, 6): 'Store/AMO address misaligned',
|
(0, 6): "Store/AMO address misaligned",
|
||||||
(0, 7): 'Store/AMO access fault',
|
(0, 7): "Store/AMO access fault",
|
||||||
(0, 8): 'environment call from user mode',
|
(0, 8): "environment call from user mode",
|
||||||
(0, 9): 'environment call from supervisor mode',
|
(0, 9): "environment call from supervisor mode",
|
||||||
(0, 11): 'environment call from machine mode',
|
(0, 11): "environment call from machine mode",
|
||||||
(0, 12): 'Instruction page fault',
|
(0, 12): "Instruction page fault",
|
||||||
(0, 13): 'Load page fault',
|
(0, 13): "Load page fault",
|
||||||
(0, 15): 'Store/AMO page fault',
|
(0, 15): "Store/AMO page fault",
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Assigns tuple (interrupt bit, exception code) to their respective readable names
|
Assigns tuple (interrupt bit, exception code) to their respective readable names
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MSTATUS_OFFSETS: Dict[str, int] = {
|
MSTATUS_OFFSETS: Dict[str, int] = {
|
||||||
'uie': 0,
|
"uie": 0,
|
||||||
'sie': 1,
|
"sie": 1,
|
||||||
'mie': 3,
|
"mie": 3,
|
||||||
'upie': 4,
|
"upie": 4,
|
||||||
'spie': 5,
|
"spie": 5,
|
||||||
'mpie': 7,
|
"mpie": 7,
|
||||||
'spp': 8,
|
"spp": 8,
|
||||||
'mpp': 11,
|
"mpp": 11,
|
||||||
'fs': 13,
|
"fs": 13,
|
||||||
'xs': 15,
|
"xs": 15,
|
||||||
'mpriv': 17,
|
"mpriv": 17,
|
||||||
'sum': 18,
|
"sum": 18,
|
||||||
'mxr': 19,
|
"mxr": 19,
|
||||||
'tvm': 20,
|
"tvm": 20,
|
||||||
'tw': 21,
|
"tw": 21,
|
||||||
'tsr': 22,
|
"tsr": 22,
|
||||||
'sd': 31
|
"sd": 31,
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Offsets for all mstatus bits
|
Offsets for all mstatus bits
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MSTATUS_LEN_2 = ('mpp', 'fs', 'xs')
|
MSTATUS_LEN_2 = ("mpp", "fs", "xs")
|
||||||
"""
|
"""
|
||||||
All mstatus parts that have length 2. All other mstatus parts have length 1
|
All mstatus parts that have length 2. All other mstatus parts have length 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CSR_NAME_TO_ADDR: Dict[str, int] = {
|
CSR_NAME_TO_ADDR: Dict[str, int] = {
|
||||||
'mstatus': 0x300,
|
"mstatus": 0x300,
|
||||||
'misa': 0x301,
|
"misa": 0x301,
|
||||||
'mie': 0x304,
|
"mie": 0x304,
|
||||||
'mtvec': 0x305,
|
"mtvec": 0x305,
|
||||||
'mepc': 0x341,
|
"mepc": 0x341,
|
||||||
'mcause': 0x342,
|
"mcause": 0x342,
|
||||||
'mtval': 0x343,
|
"mtval": 0x343,
|
||||||
'mip': 0x344,
|
"mip": 0x344,
|
||||||
'mvendorid': 0xF11,
|
"mvendorid": 0xF11,
|
||||||
'marchid': 0xF12,
|
"marchid": 0xF12,
|
||||||
'mimpid': 0xF13,
|
"mimpid": 0xF13,
|
||||||
'mhartid': 0xF14,
|
"mhartid": 0xF14,
|
||||||
'time': 0xc01,
|
"time": 0xC01,
|
||||||
'timeh': 0xc81,
|
"timeh": 0xC81,
|
||||||
'halt': 0x789,
|
"halt": 0x789,
|
||||||
'mtimecmp': 0x780,
|
"mtimecmp": 0x780,
|
||||||
'mtimecmph': 0x781,
|
"mtimecmph": 0x781,
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Translation for named registers
|
Translation for named registers
|
||||||
"""
|
"""
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from .test_tokenizer import *
|
from .test_tokenizer import *
|
||||||
from .test_helpers import *
|
from .test_helpers import *
|
||||||
from .test_integers import *
|
from .test_integers import *
|
||||||
|
Loading…
Reference in New Issue