From: Luke Kenneth Casson Leighton Date: Sun, 5 Aug 2018 14:58:58 +0000 (+0100) Subject: convert MkClkCon to iterator X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55e31ed5a5ebe2f25abe55a01dbbb46734bae033;p=pinmux.git convert MkClkCon to iterator --- diff --git a/src/bsv/peripheral_gen/base.py b/src/bsv/peripheral_gen/base.py index 1ac32c3..2bebaac 100644 --- a/src/bsv/peripheral_gen/base.py +++ b/src/bsv/peripheral_gen/base.py @@ -955,11 +955,7 @@ class PeripheralInterfaces(object): def _mk_clk_con(self, ctype): 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_clk_con(name, i, ctype) - ret.append(txt) + ret += list(MkClkCon(self, name, count, ctype)) return '\n'.join(li(list(filter(None, ret)), 8)) def is_on_fastbus(self, name, i): @@ -982,7 +978,7 @@ class IfaceIter(object): def __next__(self): while True: - if self.i > self.maxcount: + if self.i >= self.maxcount: raise StopIteration if self.check(self.name, self.i): res = self.item(self.name, self.i, *self.args) @@ -1007,6 +1003,18 @@ 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): + 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, ctype): + return self.ifaces.data[name]._mk_clk_con(name, i, ctype) + class PFactory(object): def getcls(self, name):