-from nmigen import Elaboratable, Memory, Module
+from nmigen import Elaboratable, Memory, Module, Signal
from nmigen.utils import log2_int
from nmigen_soc.wishbone.bus import Interface
n_bussel = self.bus.sel.shape()[0]
assert n_wrport == n_bussel, "bus enable count %d " \
"must match memory wen count %d" % (n_wrport, n_bussel)
- for i in range(n_wrport):
- m.d.comb += wrport.en[i].eq(self.bus.cyc & self.bus.stb &
- self.bus.we & self.bus.sel[i])
+ wen = Signal()
+ m.d.comb += wen.eq(self.bus.cyc & self.bus.stb & self.bus.we)
+ with m.If(wen):
+ m.d.comb += wrport.en.eq(self.bus.sel)
# generate ack
m.d.sync += self.bus.ack.eq(0)