def elaborate(self, platform):
m = Module()
+
m.submodules.mem = mem = TestMemory(
self.regwid, self.addrwid, granularity=8)
+ do_load = Signal() # set when doing a load while valid and not stalled
+ do_store = Signal() # set when doing a store while valid and not stalled
+
+ m.d.comb += [
+ do_load.eq(self.x_load & (self.x_valid & ~self.x_stall)),
+ do_store.eq(self.x_store & (self.x_valid & ~self.x_stall)),
+ ]
m.d.comb += [
mem.rdport.addr.eq(self.x_addr[2:]),
self.m_load_data.eq(mem.rdport.data),
mem.wrport.addr.eq(self.x_addr[2:]),
- mem.wrport.en.eq(Mux(self.x_store, self.x_mask, 0)),
+ mem.wrport.en.eq(Mux(do_store, self.x_mask, 0)),
mem.wrport.data.eq(self.x_store_data)
]
- m.d.sync += self.x_valid.eq(self.x_load)
-
return m
yield dut.x_store_data.eq(value)
yield dut.x_store.eq(1)
yield dut.x_mask.eq(-1)
-
+ yield dut.x_valid.eq(1)
+ yield dut.x_stall.eq(1)
+ yield
+ yield
+
+ yield dut.x_stall.eq(0)
yield
yield dut.x_store.eq(0)
while (yield dut.x_stall):
def read_from_addr(dut, addr):
yield dut.x_addr.eq(addr)
yield dut.x_load.eq(1)
+ yield dut.x_valid.eq(1)
+ yield dut.x_stall.eq(1)
+ yield
+ yield dut.x_stall.eq(0)
yield
yield dut.x_load.eq(0)
yield Settle()
yield dut.x_store.eq(1)
yield dut.x_store_data.eq(val << (offset * 8))
yield dut.x_mask.eq(1 << offset)
+ yield dut.x_valid.eq(1)
yield
yield dut.x_store.eq(0)
offset = addr & 0x3
yield dut.x_addr.eq(addr)
yield dut.x_load.eq(1)
+ yield dut.x_valid.eq(1)
yield
yield dut.x_load.eq(0)
yield Settle()