From: Sebastien Bourdeauducq Date: Fri, 23 Nov 2012 16:20:08 +0000 (+0100) Subject: fhdl/structure: use sets for memories and instance collections X-Git-Tag: 24jan2021_ls180~2099^2~763 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3971600917a9179777715b1b0b160d24cf4ed48e;p=litex.git fhdl/structure: use sets for memories and instance collections --- diff --git a/migen/fhdl/structure.py b/migen/fhdl/structure.py index 2249b466..4db0580b 100644 --- a/migen/fhdl/structure.py +++ b/migen/fhdl/structure.py @@ -324,8 +324,8 @@ class Fragment: def __init__(self, comb=None, sync=None, instances=None, memories=None, sim=None): if comb is None: comb = [] if sync is None: sync = dict() - if instances is None: instances = [] - if memories is None: memories = [] + if instances is None: instances = set() + if memories is None: memories = set() if sim is None: sim = [] if isinstance(sync, list): @@ -333,8 +333,8 @@ class Fragment: self.comb = comb self.sync = sync - self.instances = instances - self.memories = memories + self.instances = set(instances) + self.memories = set(memories) self.sim = sim @@ -345,8 +345,8 @@ class Fragment: for k, v in other.sync.items(): newsync[k].extend(v) return Fragment(self.comb + other.comb, newsync, - self.instances + other.instances, - self.memories + other.memories, + self.instances | other.instances, + self.memories | other.memories, self.sim + other.sim) def rename_clock_domain(self, old, new): diff --git a/migen/fhdl/tools.py b/migen/fhdl/tools.py index 0b126921..0382892d 100644 --- a/migen/fhdl/tools.py +++ b/migen/fhdl/tools.py @@ -84,7 +84,7 @@ def group_by_targets(sl): def list_inst_ios(i, ins, outs, inouts): if isinstance(i, Fragment): return list_inst_ios(i.instances, ins, outs, inouts) - elif isinstance(i, list): + elif isinstance(i, set): if i: return set.union(*(list_inst_ios(e, ins, outs, inouts) for e in i)) else: diff --git a/migen/uio/ioo.py b/migen/uio/ioo.py index 907d85e9..c5b9263e 100644 --- a/migen/uio/ioo.py +++ b/migen/uio/ioo.py @@ -14,7 +14,7 @@ class UnifiedIOObject(Actor): self._memories = set(v for v in self.buses.values() if isinstance(v, Memory)) def get_fragment(self): - return Fragment(memories=list(self._memories)) + return Fragment(memories=self._memories) (_WAIT_COMPLETE, _WAIT_POLL) = range(2)