2 test cases for LDSTSplitter and L0CacheBuffer2
5 from soc
.experiment
.l0_cache
import L0CacheBuffer2
6 from nmigen
import Module
, Signal
, Mux
, Elaboratable
, Cat
, Const
7 from nmigen
.cli
import rtlil
8 from soc
.scoreboard
.addr_split
import LDSTSplitter
9 from soc
.scoreboard
.addr_match
import LenExpand
11 from soc
.config
.test
.test_pi2ls
import pi_ld
, pi_st
, pi_ldst
13 from soc
.experiment
.pimem
import PortInterfaceBase
15 from nmigen
.compat
.sim
import run_simulation
, Settle
17 class TestCachedMemoryPortInterface(PortInterfaceBase
):
18 """TestCacheMemoryPortInterface
20 This is a test class for simple verification of LDSTSplitter
21 conforming to PortInterface
24 def __init__(self
, regwid
=64, addrwid
=4):
25 super().__init
__(regwid
, addrwid
)
26 self
.ldst
= LDSTSplitter(32, 48, 4)
28 # TODO implement these
30 def set_wr_addr(self
, m
, addr
, mask
):
31 lsbaddr
, msbaddr
= self
.splitaddr(addr
)
32 #m.d.comb += self.ldst... ### .eq(msbaddr)
34 def set_rd_addr(self
, m
, addr
, mask
):
35 lsbaddr
, msbaddr
= self
.splitaddr(addr
)
36 #m.d.comb += self..eq(msbaddr)
38 def set_wr_data(self
, m
, data
, wen
):
39 #m.d.comb += self.mem.wrport.data.eq(data) # write st to mem
40 #m.d.comb += self.mem.wrport.en.eq(wen) # enable writes
41 return Const(1, 1) #document return value
43 def get_rd_data(self
, m
):
44 return self
.ldst
.ld_data_o
.data
, Const(1, 1)
46 def elaborate(self
, platform
):
47 m
= super().elaborate(platform
)
49 # add TestMemory as submodule
50 m
.submodules
.ldst
= self
.ldst
55 yield from super().ports()
58 def test_cache_single_run(dut
):
62 yield from pi_st(dut
.pi
, addr
, data
, 1)
64 def test_cache_single():
65 dut
= TestCachedMemoryPortInterface()
66 #LDSTSplitter(8, 48, 4) #data leng in bytes, address bits, select bits
68 run_simulation(dut
, test_cache_single_run(dut
),
69 vcd_name
='test_cache_single.vcd')
72 if __name__
== '__main__':