class FullMemoryWE(ModuleTransformer):
def __init__(self):
- self.replacments = dict()
+ self.replacements = dict()
def transform_fragment(self, i, f):
newspecials = set()
+ replaced_ports = set()
for orig in f.specials:
if not isinstance(orig, Memory):
newspecials.add(orig)
continue
+
global_granularity = gcd_multiple([p.we_granularity if p.we_granularity else orig.width for p in orig.ports])
if global_granularity == orig.width:
newspecials.add(orig) # nothing to do
clock_domain=port.clock.cd)
newmem.ports.append(newport)
newspecials.add(newport)
- self.replacments[orig] = newmems
+ for port in orig.ports:
+ replaced_ports.add(port)
+ self.replacements[orig] = newmems
+
+ newspecials -= replaced_ports
f.specials = newspecials
storage.append(mem_storage)
for port in mem.ports:
- if port.we_granularity:
- raise NotImplementedError
try:
sync = f.sync[port.clock.cd]
except KeyError:
from litex.gen.fhdl.tools import (list_targets, list_signals,
insert_resets, lower_specials)
from litex.gen.fhdl.simplify import MemoryToArray
-from litex.gen.fhdl.specials import _MemoryLocation
+from litex.gen.fhdl.specials import _MemoryLocation, _MemoryPort
from litex.gen.sim.vcd import VCDWriter, DummyVCDWriter
fs, lowered = lower_specials(overrides={}, specials=self.fragment.specials)
self.fragment += fs
self.fragment.specials -= lowered
+ # FIXME: Remaining replaced ports workaround
+ remaining_memory_ports = set()
+ for s in self.fragment.specials:
+ if isinstance(s, _MemoryPort):
+ remaining_memory_ports.add(s)
+ self.fragment.specials -= remaining_memory_ports
+ # FIXME: Remaining replaced ports workaround
if self.fragment.specials:
raise ValueError("Could not lower all specials", self.fragment.specials)