fhdl/structure: use sets for memories and instance collections

This commit is contained in:
Sebastien Bourdeauducq 2012-11-23 17:20:08 +01:00
parent 7c6ebcf753
commit 3971600917
3 changed files with 8 additions and 8 deletions

View file

@ -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):

View file

@ -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:

View file

@ -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)