From 6f640248c2bebfd5fd522cae2727bdbb0b9bf9a3 Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Sun, 5 Apr 2020 15:41:23 -0400 Subject: [PATCH] Autogenerate all.py --- src/soc/decoder/isa/all.py | 19 ------------------- src/soc/decoder/pseudo/pywriter.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) delete mode 100644 src/soc/decoder/isa/all.py diff --git a/src/soc/decoder/isa/all.py b/src/soc/decoder/isa/all.py deleted file mode 100644 index b9be75f4..00000000 --- a/src/soc/decoder/isa/all.py +++ /dev/null @@ -1,19 +0,0 @@ -from caller import ISACaller -from fixedarith import fixedarith -from fixedload import fixedload -from fixedstore import fixedstore -from soc.decoder.isa.caller import ISACaller - - -class ISA(ISACaller): - def __init__(self, dec, regs): - super().__init__(dec, regs) - self.fixedarith = fixedarith() - self.fixedload = fixedload() - self.fixedstore = fixedstore() - - self.instrs = { - **self.fixedarith.fixedarith_instrs, - **self.fixedload.fixedload_instrs, - **self.fixedstore.fixedstore_instrs, - } diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 7c6e70ad..a1629aaa 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -28,8 +28,10 @@ class %s: class PyISAWriter(ISA): def __init__(self): ISA.__init__(self) + self.pages_written = [] def write_pysource(self, pagename): + self.pages_written.append(pagename) instrs = isa.page[pagename] isadir = get_isasrc_dir() fname = os.path.join(isadir, "%s.py" % pagename) @@ -71,6 +73,29 @@ class PyISAWriter(ISA): f.write(" %s_instrs = {}\n" % pagename) f.write(iinf) + def write_isa_class(self): + isadir = get_isasrc_dir() + fname = os.path.join(isadir, "all.py") + + with open(fname, "w") as f: + f.write('from soc.decoder.isa.caller import ISACaller\n') + for page in self.pages_written: + f.write('from soc.decoder.isa.%s import %s\n' % (page, page)) + f.write('\n') + + classes = ', '.join(['ISACaller'] + self.pages_written) + f.write('class ISA(%s):\n' % classes) + f.write(' def __init__(self, dec, regs):\n') + f.write(' super().__init__(dec, regs)\n') + f.write(' self.instrs = {\n') + for page in self.pages_written: + f.write(' **self.%s_instrs,\n' % page) + f.write(' }\n') + + + + + if __name__ == '__main__': isa = PyISAWriter() isa.write_pysource('sprset') @@ -86,3 +111,4 @@ if __name__ == '__main__': isa.write_pysource('fixedload') isa.write_pysource('comparefixed') isa.write_pysource('fixedarith') + isa.write_isa_class() -- 2.30.2