From 22d91f84c566a0b61b9bfeb27bf82efd49684bab Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 3 Apr 2020 22:34:51 +0100 Subject: [PATCH] plan to use class named ISACaller base class --- src/soc/decoder/pseudo/pywriter.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 9cb8a220..610ca14f 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -28,18 +28,20 @@ class PyISAWriter(ISA): isadir = get_isasrc_dir() fname = os.path.join(isadir, "%s.py" % pagename) with open(fname, "w") as f: - f.write("class %s:\n" % pagename) + iinf = '' + f.write("from soc.decoder.isa import ISACaller\n\n") + f.write("class %s(ISACaller):\n" % pagename) for page in instrs: d = self.instr[page] print (fname, d.opcode) pcode = '\n'.join(d.pcode) + '\n' print (pcode) - pycode, regsused = convert_to_python(pcode) + pycode, rused = convert_to_python(pcode) # create list of arguments to call - regs = regsused['read_regs'] + regsused['uninit_regs'] + regs = rused['read_regs'] + rused['uninit_regs'] args = create_args(regs, 'self') # create list of arguments to return - retargs = create_args(regsused['write_regs']) + retargs = create_args(rused['write_regs']) f.write(" def %s(%s):\n" % (page.replace(".", "_"), args)) pycode = pycode.split("\n") pycode = '\n'.join(map(lambda x: " %s" % x, pycode)) @@ -49,6 +51,13 @@ class PyISAWriter(ISA): f.write(" return (%s,)\n\n" % retargs) else: f.write("\n") + # cumulate the instruction info + iinfo = "('%s', %s, %s, %s)" % \ + (pagename, rused['read_regs'], + rused['uninit_regs'], rused['write_regs']) + iinf += " instrs['%s'] = %s\n" % (pagename, iinfo) + f.write(" instrs = {}\n") + f.write(iinf) if __name__ == '__main__': isa = PyISAWriter() -- 2.30.2