from openpower.simulator.program import Program
from openpower.decoder.selectable_int import SelectableInt
from openpower.decoder.isa.test_runner import run_tst
+from openpower.test.state import TestState
class DecoderTestCase(FHDLTestCase):
e.intregs[3] = 0x8800
with Program(lst, bigendian=False) as program:
# and here lies the rabbit hole...at least for me
- sim = self.run_tst_program(program, initial_regs)
- yield from self.check_regs(sim, e)
+ sim = self.run_tst_program(program, initial_regs, expected=e)
"""
def test_case_srw_1(self):
lst = ["sraw 3, 1, 2"]
self.assertEqual(sim.gpr(3), SelectableInt(0xffffffff80122900, 64))
"""
- def run_tst_program(self, prog, initial_regs=[0] * 32, initial_mem=None):
- simulator = run_tst(prog, initial_regs, mem=initial_mem)
+ def run_tst_program(self, prog, initial_regs=[0] * 32, initial_mem=None,
+ expected=None):
+ simulator = run_tst(prog, initial_regs, mem=initial_mem,
+ state=(self, 0))
+
simulator.gpr.dump()
+ # this is by no means perfect... needs work but it's functional
+ if expected is not None:
+ # have to put these in manually
+ expected.to_test = expected
+ expected.dut = self
+ expected.state_type = "expected"
+ expected.code = 0
+ # do actual comparison
+ simulator.state.compare(expected)
return simulator
-
- def check_regs(self, sim, e):
- simstate = yield from TestState("sim",sim,self)
- yield from simstate.compare(e)
-
"""
def check_regs(self, sim, e):
# int regs
from openpower.simulator.program import Program
from openpower.decoder.isa.caller import ISACaller, inject
from openpower.decoder.isa.all import ISA
+from openpower.test.state import TestState
from nmutil.formaltest import FHDLTestCase
sim.run()
+def check_regs(dut, sim, expected, test, code):
+ # create the two states and compare
+ testdic = {'sim': sim, 'expected': expected}
+ yield from teststate_check_regs(dut, testdic, test, code)
+
+
def run_tst(generator, initial_regs, initial_sprs=None, svstate=0, mmu=False,
initial_cr=0, mem=None,
initial_fprs=None,
- pdecode2=None):
+ pdecode2=None,
+ state=None): # (dut, code)
if initial_sprs is None:
initial_sprs = {}
m = Module()
comb += pdecode2.dec.raw_opcode_in.eq(instruction)
sim = Simulator(m)
+ process_state = state
+
def process():
print ("GPRs")
pc = simulator.pc.CIA.value
index = pc//4
+ # use this to test against expected (static) results at end of run
+ if process_state is not None:
+ (dut, code) = process_state
+ simulator.state = yield from TestState("sim", simulator, dut, code)
+
sim.add_process(process)
with sim.write_vcd("simulator.vcd", "simulator.gtkw",
traces=[]):
sim.run()
+
return simulator