From: Luke Kenneth Casson Leighton Date: Fri, 23 Apr 2021 16:07:59 +0000 (+0100) Subject: move ALUHelpers to openpower-isa X-Git-Tag: 0.0.1~22 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3d3b8aefe95668400b23a21d67993e74768ed51a;p=openpower-isa.git move ALUHelpers to openpower-isa --- diff --git a/src/openpower/test/common.py b/src/openpower/test/common.py index 435cbc9a..3bdb7d49 100644 --- a/src/openpower/test/common.py +++ b/src/openpower/test/common.py @@ -7,6 +7,13 @@ import inspect import functools import types +from openpower.decoder.power_enums import XER_bits, CryIn, spr_dict +from openpower.util import fast_reg_to_spr, slow_reg_to_spr # HACK! +from openpower.consts import XERRegsEnum +from openpower.test.common import (mask_extend, SkipCase, _id, skip_case, + skip_case_if, TestAccumulatorBase, + TestCase) + # TODO: make this a util routine (somewhere) def mask_extend(x, nbits, repeat): @@ -136,3 +143,420 @@ class TestCase: self.svstate = svstate +class ALUHelpers: + + def get_sim_fast_reg(res, sim, dec2, reg, name): + spr_sel = fast_reg_to_spr(reg) + spr_data = sim.spr[spr_sel].value + res[name] = spr_data + + def get_sim_cia(res, sim, dec2): + res['cia'] = sim.pc.CIA.value + + # use this *after* the simulation has run a step (it returns CIA) + def get_sim_nia(res, sim, dec2): + res['nia'] = sim.pc.CIA.value + + def get_sim_msr(res, sim, dec2): + res['msr'] = sim.msr.value + + def get_sim_slow_spr1(res, sim, dec2): + spr1_en = yield dec2.e.read_spr1.ok + if spr1_en: + spr1_sel = yield dec2.e.read_spr1.data + spr1_sel = slow_reg_to_spr(spr1_sel) + spr1_data = sim.spr[spr1_sel].value + res['spr1'] = spr1_data + + def get_sim_fast_spr1(res, sim, dec2): + fast1_en = yield dec2.e.read_fast1.ok + if fast1_en: + fast1_sel = yield dec2.e.read_fast1.data + spr1_sel = fast_reg_to_spr(fast1_sel) + spr1_data = sim.spr[spr1_sel].value + res['fast1'] = spr1_data + + def get_sim_fast_spr2(res, sim, dec2): + fast2_en = yield dec2.e.read_fast2.ok + if fast2_en: + fast2_sel = yield dec2.e.read_fast2.data + spr2_sel = fast_reg_to_spr(fast2_sel) + spr2_data = sim.spr[spr2_sel].value + res['fast2'] = spr2_data + + def get_sim_cr_a(res, sim, dec2): + cridx_ok = yield dec2.e.read_cr1.ok + if cridx_ok: + cridx = yield dec2.e.read_cr1.data + res['cr_a'] = sim.crl[cridx].get_range().value + + def get_sim_cr_b(res, sim, dec2): + cridx_ok = yield dec2.e.read_cr2.ok + if cridx_ok: + cridx = yield dec2.e.read_cr2.data + res['cr_b'] = sim.crl[cridx].get_range().value + + def get_sim_cr_c(res, sim, dec2): + cridx_ok = yield dec2.e.read_cr3.ok + if cridx_ok: + cridx = yield dec2.e.read_cr3.data + res['cr_c'] = sim.crl[cridx].get_range().value + + def get_sim_int_ra(res, sim, dec2): + # TODO: immediate RA zero + reg1_ok = yield dec2.e.read_reg1.ok + if reg1_ok: + data1 = yield dec2.e.read_reg1.data + res['ra'] = sim.gpr(data1).value + + def get_sim_int_rb(res, sim, dec2): + reg2_ok = yield dec2.e.read_reg2.ok + if reg2_ok: + data = yield dec2.e.read_reg2.data + res['rb'] = sim.gpr(data).value + + def get_sim_int_rc(res, sim, dec2): + reg3_ok = yield dec2.e.read_reg3.ok + if reg3_ok: + data = yield dec2.e.read_reg3.data + res['rc'] = sim.gpr(data).value + + def get_rd_sim_xer_ca(res, sim, dec2): + cry_in = yield dec2.e.do.input_carry + xer_in = yield dec2.e.xer_in + if (xer_in & (1<