Autogenerate all.py
authorMichael Nolan <mtnolan2640@gmail.com>
Sun, 5 Apr 2020 19:41:23 +0000 (15:41 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Sun, 5 Apr 2020 19:41:23 +0000 (15:41 -0400)
src/soc/decoder/isa/all.py [deleted file]
src/soc/decoder/pseudo/pywriter.py

diff --git a/src/soc/decoder/isa/all.py b/src/soc/decoder/isa/all.py
deleted file mode 100644 (file)
index b9be75f..0000000
+++ /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,
-        }
index 7c6e70ad01b60ce978ff9828a60c068fbc34790e..a1629aaab0c10e72958eb534b0b4ef8e98ff241d 100644 (file)
@@ -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()