def elaborate(self, platform):
m = super().elaborate(platform)
comb = m.d.comb
- # small 32-entry Memory
- memory = Memory(width=self.addr_wid, depth=32)
+ # small 16-entry Memory
+ memory = Memory(width=self.data_wid, depth=16)
m.submodules.sram = sram = SRAM(memory=memory, granularity=8,
features={'cti', 'bte', 'err'})
dbus = self.dbus
# directly connect the wishbone bus of LoadStoreUnitInterface to SRAM
# note: SRAM is a target (slave), dbus is initiator (master)
- fanouts = ['adr', 'dat_w', 'sel', 'cyc', 'stb', 'we', 'cti', 'bte']
+ fanouts = ['dat_w', 'sel', 'cyc', 'stb', 'we', 'cti', 'bte']
fanins = ['dat_r', 'ack', 'err']
for fanout in fanouts:
+ print ("fanout", fanout, getattr(sram.bus, fanout).shape(),
+ getattr(dbus, fanout).shape())
+ comb += getattr(sram.bus, fanout).eq(getattr(dbus, fanout))
comb += getattr(sram.bus, fanout).eq(getattr(dbus, fanout))
for fanin in fanins:
comb += getattr(dbus, fanin).eq(getattr(sram.bus, fanin))
+ # SRAM is row-addressed, so ignore LSBs
+ comb += sram.bus.adr.eq(dbus.adr[self.adr_lsbs:])
return m
yield dut.x_mask_i.eq(-1)
yield dut.x_valid_i.eq(1)
yield dut.x_stall_i.eq(1)
+ yield dut.m_valid_i.eq(1)
yield
yield
yield dut.x_st_i.eq(1)
yield dut.x_st_data_i.eq(val << (offset * 8))
yield dut.x_mask_i.eq(1 << offset)
+ print ("write_byte", addr, hex(1<<offset), hex(val<<(offset*8)))
yield dut.x_valid_i.eq(1)
+ yield dut.m_valid_i.eq(1)
yield
yield dut.x_st_i.eq(0)
yield
assert (yield dut.x_valid_i)
val = (yield dut.m_ld_data_o)
+ print ("read_byte", addr, offset, hex(val))
return (val >> (offset * 8)) & 0xff
m = Module()
Pspec = namedtuple('Pspec', ['ldst_ifacetype',
'addr_wid', 'mask_wid', 'reg_wid'])
- pspec = Pspec(ldst_ifacetype=ifacetype, addr_wid=64, mask_wid=4, reg_wid=64)
+ pspec = Pspec(ldst_ifacetype=ifacetype, addr_wid=64, mask_wid=4, reg_wid=32)
dut = ConfigLoadStoreUnit(pspec).lsi
m.submodules.dut = dut
for addr, val in enumerate(values):
yield from write_to_addr(dut, addr << 2, val)
x = yield from read_from_addr(dut, addr << 2)
- print ("addr, val", addr, val, x)
+ print ("addr, val", addr, hex(val), hex(x))
assert x == val
values = [random.randint(0, 255) for x in range(16*4)]
for addr, val in enumerate(values):
yield from write_byte(dut, addr, val)
- for addr, val in enumerate(values):
+ x = yield from read_from_addr(dut, addr << 2)
+ print ("addr, val", addr, hex(val), hex(x))
x = yield from read_byte(dut, addr)
+ print ("addr, val", addr, hex(val), hex(x))
assert x == val
sim.add_sync_process(process)
sim.run()
if __name__ == '__main__':
- tst_lsmemtype('testmem')
tst_lsmemtype('test_bare_wb')
+ tst_lsmemtype('testmem')