Skip to content

Commit

Permalink
fhdl/simplify: remove stale MemoryPorts. Closes #49
Browse files Browse the repository at this point in the history
sbourdeauducq committed Nov 5, 2016
1 parent 565927a commit b94d1f5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions migen/fhdl/simplify.py
Original file line number Diff line number Diff line change
@@ -48,6 +48,8 @@ def transform_fragment(self, i, f):
self.replacements[orig] = newmems

f.specials = newspecials
for oldmem in self.replacements.keys():
f.specials -= set(oldmem.ports)


class MemoryToArray(ModuleTransformer):
@@ -125,6 +127,7 @@ class SplitMemory(ModuleTransformer):

def transform_fragment(self, i, f):
old_specials, f.specials = f.specials, set()
old_ports = set()

for old in old_specials:
if not isinstance(old, Memory):
@@ -135,9 +138,12 @@ def transform_fragment(self, i, f):
f.specials.add(old)
except ValueError:
new, glue = self._split_mem(old)
old_ports |= set(old.ports)
f.specials.update(new)
f.comb += glue

f.specials -= old_ports

def _split_mem(self, mem):
depths = [1 << i for i in range(log2_int(mem.depth, need_pow2=False))
if mem.depth & (1 << i)]

0 comments on commit b94d1f5

Please sign in to comment.