unit tests for SPRs when MMU enabled,
[soc.git] / src / soc / fu / mmu / test / test_issuer_mmu_data_path.py
1 from nmigen import Module, Signal
2 from soc.simple.test.test_issuer import TestRunner
3 from openpower.simulator.program import Program
4 from openpower.endian import bigendian
5 import unittest
6
7 from openpower.test.common import (
8 TestAccumulatorBase, skip_case, TestCase, ALUHelpers)
9
10 # this test case takes about half a minute to run on my Talos II
11 class MMUTestCase(TestAccumulatorBase):
12 # MMU on microwatt handles MTSPR, MFSPR, DCBZ and TLBIE.
13 # libre-soc has own SPR unit
14 # other instructions here -> must be load/store
15
16 def case_mmu_dar(self):
17 lst = [ "mfspr 1, 19", # DAR to reg 1
18 ]
19
20 initial_regs = [0] * 32
21 initial_regs[1] = 0x2
22
23 initial_sprs = {'DAR': 0x87654321,
24 }
25 self.add_case(Program(lst, bigendian),
26 initial_regs, initial_sprs)
27
28 def cse_mmu_ldst(self):
29 lst = [
30 "dcbz 1,2",
31 "tlbie 0,0,0,0,0", # RB,RS,RIC,PRS,R
32 "mtspr 18, 1", # reg 1 to DSISR
33 "mtspr 19, 2", # reg 2 to DAR
34 "mfspr 5, 18", # DSISR to reg 5
35 "mfspr 6, 19", # DAR to reg 6
36 "mtspr 48, 3", # set MMU PID
37 "mtspr 720, 4", # set MMU PRTBL
38 "lhz 3, 0(1)", # load some data
39 "addi 7, 0, 1"
40 ]
41
42 initial_regs = [0] * 32
43 initial_regs[1] = 0x2
44 initial_regs[2] = 0x2020
45 initial_regs[3] = 5
46 initial_regs[4] = 0xDEADBEEF
47
48 initial_sprs = {'DSISR': 0x12345678, 'DAR': 0x87654321,
49 'PIDR': 0xabcd, 'PRTBL': 0x0def}
50 self.add_case(Program(lst, bigendian),
51 initial_regs, initial_sprs)
52
53
54 if __name__ == "__main__":
55 unittest.main(exit=False)
56 suite = unittest.TestSuite()
57 suite.addTest(TestRunner(MMUTestCase().test_data,
58 microwatt_mmu=True,
59 svp64=False))
60 runner = unittest.TextTestRunner()
61 runner.run(suite)