From d72474c30510616c1909a62d0088db7038a56f32 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 5 Aug 2018 17:52:37 +0100 Subject: [PATCH] convert m_ext_ifacedef to class --- src/bsv/peripheral_gen/base.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/bsv/peripheral_gen/base.py b/src/bsv/peripheral_gen/base.py index 2bebaac..56ccd95 100644 --- a/src/bsv/peripheral_gen/base.py +++ b/src/bsv/peripheral_gen/base.py @@ -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): -- 2.30.2