1 # test case for LOAD / STORE Computation Unit.
4 from nmigen
.compat
.sim
import run_simulation
5 from nmigen
.cli
import verilog
, rtlil
6 from nmigen
import Module
, Signal
, Mux
, Cat
, Elaboratable
, Array
, Repl
7 from nmigen
.hdl
.rec
import Record
, Layout
10 from nmutil.latch import SRLatch, latchregister
11 from nmutil.byterev import byte_reverse
12 from nmutil.extend import exts
14 from soc.fu.regspec import RegSpecAPI
16 from openpower.decoder.power_enums import MicrOp, Function, LDSTMode
17 from soc.fu.ldst.ldst_input_record import CompLDSTOpSubset
18 from openpower.decoder.power_decoder2 import Data
19 from openpower.consts import MSR
22 from soc
.experiment
.compalu_multi
import go_record
, CompUnitRecord
23 from soc
.experiment
.l0_cache
import PortInterface
24 from soc
.experiment
.pimem
import LDSTException
25 from soc
.experiment
.compldst_multi
import LDSTCompUnit
26 from soc
.config
.test
.test_loadstore
import TestMemPspec
28 ########################################
34 ########################################
37 class TestLDSTCompUnitMMU(LDSTCompUnit
):
39 def __init__(self
, rwid
, pspec
):
40 from soc
.experiment
.l0_cache
import TstL0CacheBuffer
41 self
.l0
= l0
= TstL0CacheBuffer(pspec
)
43 LDSTCompUnit
.__init
__(self
, pi
, rwid
, 4)
45 def elaborate(self
, platform
):
46 m
= LDSTCompUnit
.elaborate(self
, platform
)
47 m
.submodules
.l0
= self
.l0
48 # link addr-go direct to rel
49 m
.d
.comb
+= self
.ad
.go_i
.eq(self
.ad
.rel_o
)
53 def test_scoreboard_mmu():
56 pspec
= TestMemPspec(ldst_ifacetype
='mmu_cache_wb',
57 imem_ifacetype
='bare_wb',
63 dut
= TestLDSTCompUnitMMU(16,pspec
)
64 vl
= rtlil
.convert(dut
, ports
=dut
.ports())
65 with
open("test_ldst_comp_mmu1.il", "w") as f
:
68 run_simulation(dut
, ldst_sim(dut
), vcd_name
='test_ldst_comp.vcd')
70 ########################################
71 class TestLDSTCompUnitRegSpecMMU(LDSTCompUnit
):
73 def __init__(self
, pspec
):
74 from soc
.experiment
.l0_cache
import TstL0CacheBuffer
75 from soc
.fu
.ldst
.pipe_data
import LDSTPipeSpec
76 regspec
= LDSTPipeSpec
.regspec
77 self
.l0
= l0
= TstL0CacheBuffer(pspec
)
79 LDSTCompUnit
.__init
__(self
, pi
, regspec
, 4)
81 def elaborate(self
, platform
):
82 m
= LDSTCompUnit
.elaborate(self
, platform
)
83 m
.submodules
.l0
= self
.l0
84 # link addr-go direct to rel
85 m
.d
.comb
+= self
.ad
.go_i
.eq(self
.ad
.rel_o
)
89 def test_scoreboard_regspec_mmu():
92 pspec
= TestMemPspec(ldst_ifacetype
='mmu_cache_wb',
93 imem_ifacetype
='bare_wb',
99 dut
= TestLDSTCompUnitRegSpecMMU(pspec
)
100 vl
= rtlil
.convert(dut
, ports
=dut
.ports())
101 with
open("test_ldst_comp_mmu2.il", "w") as f
:
104 run_simulation(dut
, ldst_sim(dut
), vcd_name
='test_ldst_regspec.vcd')
107 if __name__
== '__main__':
108 test_scoreboard_regspec_mmu()
109 #only one test for now -- test_scoreboard_mmu()