from soc.fu.compunits.compunits import LDSTFunctionUnit
from soc.fu.compunits.test.test_compunit import TestRunner
+from soc.fu.test.common import ALUHelpers
class LDSTTestRunner(TestRunner):
"""naming (res) must conform to LDSTFunctionUnit output regspec
"""
- print ("check cu outputs", res)
- # RT
- out_reg_valid = yield dec2.e.write_reg.ok
- if out_reg_valid:
- write_reg_idx = yield dec2.e.write_reg.data
- expected = sim.gpr(write_reg_idx).value
- cu_out = res['o']
- print(f"expected {expected:x}, actual: {cu_out:x}")
- self.assertEqual(expected, cu_out, code)
-
- # RA
- out_reg_valid = yield dec2.e.write_ea.ok
- if out_reg_valid:
- write_reg_idx = yield dec2.e.write_ea.data
- expected = sim.gpr(write_reg_idx).value
- cu_out = res['o1']
- print(f"expected {expected:x}, actual: {cu_out:x}")
- self.assertEqual(expected, cu_out, code)
+ print ("check cu outputs", code, res)
rc = yield dec2.e.rc.data
op = yield dec2.e.insn_type
self.assertEqual(cridx_ok, 1, code)
self.assertEqual(cridx, 0, code)
- # CR (CR0-7)
- if cridx_ok:
- cr_expected = sim.crl[cridx].get_range().value
- cr_actual = res['cr_a']
- print ("CR", cridx, cr_expected, cr_actual)
- self.assertEqual(cr_expected, cr_actual, "CR%d %s" % (cridx, code))
+ sim_o = {}
+
+ yield from ALUHelpers.get_sim_int_o(sim_o, sim, dec2)
+ yield from ALUHelpers.get_sim_int_o1(sim_o, sim, dec2)
+ yield from ALUHelpers.get_wr_sim_cr_a(sim_o, sim, dec2)
+
+ ALUHelpers.check_cr_a(self, res, sim_o, "CR%d %s" % (cridx, code))
+ ALUHelpers.check_int_o(self, res, sim_o, code)
+ ALUHelpers.check_int_o1(self, res, sim_o, code)
# XER.so
return
else:
yield alu.p.data_i.full_cr.eq(0)
+ def get_int_o1(res, alu, dec2):
+ out_reg_valid = yield dec2.e.write_ea.ok
+ if out_reg_valid:
+ res['o1'] = yield alu.n.data_o.o1.data
+
def get_int_o(res, alu, dec2):
out_reg_valid = yield dec2.e.write_reg.ok
if out_reg_valid:
- res['o'] = yield alu.n.data_o.o.data
+ res['o'] = yield alu.n.data_o.o.data
def get_cr_a(res, alu, dec2):
cridx_ok = yield dec2.e.write_cr.ok
write_reg_idx = yield dec2.e.write_reg.data
res['o'] = sim.gpr(write_reg_idx).value
+ def get_sim_int_o1(res, sim, dec2):
+ out_reg_valid = yield dec2.e.write_ea.ok
+ if out_reg_valid:
+ write_reg_idx = yield dec2.e.write_ea.data
+ res['o1'] = sim.gpr(write_reg_idx).value
+
def get_wr_sim_cr_a(res, sim, dec2):
cridx_ok = yield dec2.e.write_cr.ok
if cridx_ok:
if oe and oe_ok:
res['xer_so'] = 1 if sim.spr['XER'][XER_bits['SO']] else 0
+ def check_int_o1(dut, res, sim_o, msg):
+ if 'o1' in res:
+ expected = sim_o['o1']
+ alu_out = res['o1']
+ print(f"expected {expected:x}, actual: {alu_out:x}")
+ dut.assertEqual(expected, alu_out, msg)
+
def check_int_o(dut, res, sim_o, msg):
if 'o' in res:
expected = sim_o['o']