read all files from openpower/isa directory successfully
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 2 Apr 2020 14:57:19 +0000 (15:57 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 2 Apr 2020 14:57:19 +0000 (15:57 +0100)
libreriscv
src/soc/decoder/pseudo/pagereader.py

index b93437fe4b0db7e3d9d066445c9528dc236dc4ed..03177977f70255421290a59caa3db84658e7f3e5 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b93437fe4b0db7e3d9d066445c9528dc236dc4ed
+Subproject commit 03177977f70255421290a59caa3db84658e7f3e5
index 14d6f823b4e1c6029a7527dc7fdcf8b384bfc6b3..39836b0150ed54b23cda4cd65fa62da83ad23bab 100644 (file)
@@ -5,19 +5,21 @@ import os
 
 op = namedtuple("Ops", ("desc", "form", "opcode", "regs", "pcode", "sregs"))
 
+def get_isa_dir():
+    fdir = os.path.abspath(os.path.dirname(__file__))
+    fdir = os.path.split(fdir)[0]
+    fdir = os.path.split(fdir)[0]
+    fdir = os.path.split(fdir)[0]
+    fdir = os.path.split(fdir)[0]
+    return os.path.join(fdir, "libreriscv", "openpower", "isa")
+
 class ISA:
 
     def __init__(self):
         self.instr = OrderedDict()
 
     def read_file(self, fname):
-        fdir = os.path.abspath(os.path.dirname(__file__))
-        fdir = os.path.split(fdir)[0]
-        fdir = os.path.split(fdir)[0]
-        fdir = os.path.split(fdir)[0]
-        fdir = os.path.split(fdir)[0]
-        print (fdir)
-        fname = os.path.join(fdir, "libreriscv", "openpower", "isa", fname)
+        fname = os.path.join(get_isa_dir(), fname)
         with open(fname) as f:
             lines = f.readlines()
         
@@ -74,7 +76,7 @@ class ISA:
 
             # get special regs
             li = []
-            while True:
+            while lines:
                 l = lines.pop(0).rstrip()
                 if len(l) == 0: break
                 assert l.startswith('    '), ("4spcs not found in line %s" % l)
@@ -106,5 +108,9 @@ class ISA:
 
 if __name__ == '__main__':
     isa = ISA()
-    isa.read_file("fixedlogical.mdwn")
+    for pth in os.listdir(os.path.join(get_isa_dir())):
+        print (get_isa_dir(), pth)
+        assert pth.endswith(".mdwn"), "only %s in isa dir" % pth
+        isa.read_file(pth)
+
     isa.pprint_ops()