1 """DCache PortInterface Test
2 starting as a copy to test_ldst_pi.py
5 from nmigen
import (C
, Module
, Signal
, Elaboratable
, Mux
, Cat
, Repl
, Signal
)
6 from nmigen
.cli
import main
7 from nmigen
.cli
import rtlil
8 from nmutil
.mask
import Mask
, masked
9 from nmutil
.util
import Display
10 from random
import randint
, seed
11 from nmigen
.sim
import Simulator
, Delay
, Settle
12 from nmutil
.util
import wrap
14 from soc
.config
.test
.test_pi2ls
import pi_ld
, pi_st
, pi_ldst
15 from soc
.config
.test
.test_loadstore
import TestMemPspec
16 from soc
.config
.loadstore
import ConfigMemoryPortInterface
18 from soc
.fu
.ldst
.loadstore
import LoadStore1
19 from soc
.experiment
.mmu
import MMU
20 from soc
.experiment
.test
import pagetables
22 from nmigen
.compat
.sim
import run_simulation
29 """simulator process for getting memory load requests
36 while True: # wait for dc_valid
44 addr
= (yield wb
.adr
) << 3
46 print (" WB LOOKUP NO entry @ %x, returning zero" % (addr
))
51 store
= (yield wb
.dat_w
)
53 data
= mem
.get(addr
, 0)
54 # note we assume 8-bit sel, here
63 print (" DCACHE set %x mask %x data %x" % (addr
, sel
, res
))
65 data
= mem
.get(addr
, 0)
66 yield wb
.dat_r
.eq(data
)
67 print (" DCACHE get %x data %x" % (addr
, data
))
79 pspec
= TestMemPspec(ldst_ifacetype
='mmu_cache_wb',
82 #disable_cache=True, # hmmm...
88 cmpi
= ConfigMemoryPortInterface(pspec
)
89 m
.submodules
.ldst
= ldst
= cmpi
.pi
90 m
.submodules
.mmu
= mmu
= MMU()
93 l_in
, l_out
= mmu
.l_in
, mmu
.l_out
94 d_in
, d_out
= dcache
.d_in
, dcache
.d_out
95 wb_out
, wb_in
= dcache
.wb_out
, dcache
.wb_in
97 # link mmu and dcache together
98 m
.d
.comb
+= dcache
.m_in
.eq(mmu
.d_out
) # MMUToDCacheType
99 m
.d
.comb
+= mmu
.d_in
.eq(dcache
.m_out
) # DCacheToMMUType
101 # link ldst and MMU together
102 comb
+= l_in
.eq(ldst
.m_out
)
103 comb
+= ldst
.m_in
.eq(l_out
)
107 ### test case for dcbz
109 def _test_dcbz_addr_100e0(dut
, mem
):
110 mmu
= dut
.submodules
.mmu
111 pi
= dut
.submodules
.ldst
.pi
115 yield mmu
.rin
.prtbl
.eq(0x1000000) # set process table
119 data
= 0xf553b658ba7e1f51
121 yield from pi_st(pi
, addr
, data
, 8, msr_pr
=0)
124 ld_data
= yield from pi_ld(pi
, addr
, 8, msr_pr
=0)
125 assert ld_data
== 0xf553b658ba7e1f51
126 ld_data
= yield from pi_ld(pi
, addr
, 8, msr_pr
=0)
127 assert ld_data
== 0xf553b658ba7e1f51
129 print("do_dcbz ===============")
130 yield from pi_st(pi
, addr
, data
, 8, msr_pr
=0, is_dcbz
=1)
131 print("done_dcbz ===============")
134 ld_data
= yield from pi_ld(pi
, addr
, 8, msr_pr
=0)
135 print("ld_data after dcbz")
142 def test_dcbz_addr_100e0():
144 m
, cmpi
= setup_mmu()
146 mem
= pagetables
.test1
152 sim
.add_sync_process(wrap(_test_dcbz_addr_100e0(m
, mem
)))
153 sim
.add_sync_process(wrap(wb_get(cmpi
.wb_bus(), mem
)))
154 with sim
.write_vcd('test_dcbz_addr_zero.vcd'):
157 if __name__
== '__main__':
158 test_dcbz_addr_100e0()