convert m_ext_ifacedef to class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 Aug 2018 16:52:37 +0000 (17:52 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 Aug 2018 16:52:37 +0000 (17:52 +0100)
src/bsv/peripheral_gen/base.py

index 2bebaacc0397d28a4c6976c18a40ee85736b159c..56ccd95f3484ad5227401a8f6c1267df863dd050 100644 (file)
@@ -921,11 +921,7 @@ class PeripheralInterfaces(object):
     def mk_ext_ifacedef(self):
         ret = []
         for (name, count) in self.ifacecount:
-            for i in range(count):
-                if self.is_on_fastbus(name, i):
-                    continue
-                txt = self.data[name].mk_ext_ifacedef(name, i)
-                ret.append(txt)
+            ret += list(MkExtIface(self, name, count))
         return '\n'.join(li(list(filter(None, ret)), 8))
 
     def mk_plic(self):
@@ -965,6 +961,7 @@ class PeripheralInterfaces(object):
             return iname not in self.fastbus
         return iname in self.fastbus
 
+
 class IfaceIter(object):
 
     def __init__(self, name, count, *args):
@@ -991,6 +988,19 @@ class IfaceIter(object):
         return self.__next__()
 
 
+class MkExtIface(IfaceIter):
+
+    def __init__(self, ifaces, name, count, *args):
+        self.ifaces = ifaces
+        IfaceIter.__init__(self, name, count, *args)
+
+    def check(self, name, i):
+        return not self.ifaces.is_on_fastbus(name, i)
+
+    def item(self, name, i):
+        return self.ifaces.data[name].mk_ext_ifacedef(name, i)
+
+
 class MkPinCon(IfaceIter):
 
     def __init__(self, ifaces, name, count, *args):
@@ -1003,6 +1013,7 @@ class MkPinCon(IfaceIter):
     def item(self, name, i, typ):
         return self.ifaces.data[name]._mk_pincon(name, i, typ)
 
+
 class MkClkCon(IfaceIter):
 
     def __init__(self, ifaces, name, count, *args):