98fdd45341fad0d12bd5fbc52b968f58cdc7bb89
1 """simple core test, runs instructions from a TestMemory
5 * https://bugs.libre-soc.org/show_bug.cgi?id=363
8 # NOTE: to use cxxsim, export NMIGEN_SIM_MODE=cxxsim from the shell
9 # Also, check out the cxxsim nmigen branch, and latest yosys from git
14 # here is the logic which takes test cases and "executes" them.
15 # in this instance (TestRunner) its job is to instantiate both
16 # a Libre-SOC nmigen-based HDL instance and an ISACaller python
17 # simulator. it's also responsible for performing the single
18 # step and comparison.
19 from soc
.simple
.test
.test_runner
import TestRunner
22 from openpower
.test
.mmu
.mmu_cases
import MMUTestCase
23 from openpower
.test
.mmu
.mmu_rom_cases
import MMUTestCaseROM
, default_mem
24 from openpower
.test
.ldst
.ldst_cases
import LDSTTestCase
25 from openpower
.test
.ldst
.ldst_exc_cases
import LDSTExceptionTestCase
26 #from openpower.simulator.test_sim import (GeneralTestCases, AttnTestCase)
28 from openpower
.simulator
.program
import Program
29 from openpower
.endian
import bigendian
30 from openpower
.test
.common
import TestAccumulatorBase
32 class MMUTestCase(TestAccumulatorBase
):
34 def case_1_dcbz(self
):
37 initial_regs
= [0] * 32
38 initial_regs
[1] = 0x0004
39 initial_regs
[2] = 0x0008
40 initial_regs
[3] = 0x0007
42 self
.add_case(Program(lst
, bigendian
), initial_regs
,
43 initial_mem
=initial_mem
)
45 def case_2_tlbie(self
):
46 lst
= ["tlbie 1,1,1,1,1"] # tlbie RB,RS,RIC,PRS,R
47 initial_regs
= [0] * 32
49 self
.add_case(Program(lst
, bigendian
), initial_regs
,
50 initial_mem
=initial_mem
)
52 def case_3_mtspr(self
):
53 lst
= ["mtspr 720,1"] # mtspr PRTBL,r1
54 initial_regs
= [0] * 32
55 initial_regs
[1] = 0x1234
57 self
.add_case(Program(lst
, bigendian
), initial_regs
,
58 initial_mem
=initial_mem
)
60 def case_4_mfspr(self
):
61 lst
= ["mfspr 1,18", # mtspr r1,DSISR
62 "mfspr 2,19"] # mtspr r2,DAR
63 initial_regs
= [0] * 32
64 initial_regs
[1] = 0x1234
65 initial_regs
[2] = 0x3456
67 self
.add_case(Program(lst
, bigendian
), initial_regs
,
68 initial_mem
=initial_mem
)
70 if __name__
== "__main__":
72 if len(sys
.argv
) == 2:
73 if sys
.argv
[1] == 'nosvp64':
77 print ("SVP64 test mode enabled", svp64
)
79 unittest
.main(exit
=False)
80 suite
= unittest
.TestSuite()
82 # MMU/DCache integration tests
83 suite
.addTest(TestRunner(MMUTestCase().test_data
, svp64
=svp64
,
86 runner
= unittest
.TextTestRunner()