forked from riscv-software-src/riscv-isac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.py
38 lines (29 loc) · 1.14 KB
/
interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import importlib
import pluggy
from riscv_isac.plugins.specification import *
import riscv_isac.plugins as plugins
def interface (trace, arch, mode):
'''
Arguments:
Trace - Log_file_path
Arch - Architecture
Mode - Execution trace format
'''
parser_pm = pluggy.PluginManager("parser")
decoder_pm = pluggy.PluginManager("decoder")
parser_pm.add_hookspecs(ParserSpec)
decoder_pm.add_hookspecs(DecoderSpec)
parserfile = importlib.import_module("riscv_isac.plugins."+mode)
parserclass = getattr(parserfile, "mode_"+mode)
parser_pm.register(parserclass())
parser = parser_pm.hook
parser.setup(trace=trace,arch=arch)
instructionObjectfile = importlib.import_module("riscv_isac.plugins.internalDecoder")
decoderclass = getattr(instructionObjectfile, "disassembler")
decoder_pm.register(decoderclass())
decoder = decoder_pm.hook
decoder.setup(arch=arch)
iterator = iter(parser.__iter__()[0])
for instr, mnemonic, addr, commitvalue in iterator:
if instr is not None:
instrObj = decoder.decode(instr=instr, addr=addr)