From: Luke Kenneth Casson Leighton Date: Thu, 6 Oct 2022 14:59:54 +0000 (+0100) Subject: add insert sort svp64 test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=26fc8d3ef286aee327e078a46cbcfa181b0d7124;p=openpower-isa.git add insert sort svp64 test --- diff --git a/src/openpower/decoder/isa/test_caller_svp64_inssort.py b/src/openpower/decoder/isa/test_caller_svp64_inssort.py new file mode 100644 index 00000000..8e7cce4f --- /dev/null +++ b/src/openpower/decoder/isa/test_caller_svp64_inssort.py @@ -0,0 +1,152 @@ +from nmigen import Module, Signal +from nmigen.sim import Simulator, Delay, Settle +from nmutil.formaltest import FHDLTestCase +import unittest +from openpower.decoder.isa.caller import ISACaller +from openpower.decoder.power_decoder import (create_pdecode) +from openpower.decoder.power_decoder2 import (PowerDecode2) +from openpower.simulator.program import Program +from openpower.decoder.isa.caller import ISACaller, SVP64State +from openpower.decoder.selectable_int import SelectableInt +from openpower.decoder.orderedset import OrderedSet +from openpower.decoder.isa.all import ISA +from openpower.decoder.isa.test_caller import Register, run_tst +from openpower.sv.trans.svp64 import SVP64Asm +from openpower.consts import SVP64CROffs +from copy import deepcopy +from openpower.decoder.helpers import fp64toselectable +from openpower.decoder.isa.remap_preduce_yield import preduce_y +from functools import reduce +import operator + + +def signcopy(x, y): + y = abs(y) + if x < 0: + return -y + return y + + +class DecoderTestCase(FHDLTestCase): + + def _check_regs(self, sim, expected): + for i in range(32): + self.assertEqual(sim.gpr(i), SelectableInt(expected[i], 64)) + + def test_sv_cmp(self): + lst = SVP64Asm(["sv.cmp *0, 1, *16, 0", + ]) + lst = list(lst) + + # SVSTATE vl=10 + svstate = SVP64State() + svstate.vl = 3 # VL + svstate.maxvl = 3 # MAXVL + print ("SVSTATE", bin(svstate.asint())) + + gprs = [0] * 64 + vec = [1, 2, 3] + crs_expected = [8, 2, 4] # LT EQ GT + + res = [] + # store GPRs + for i, x in enumerate(vec): + gprs[i+16] = x + + gprs[0] = 2 # middle value of vec + + with Program(lst, bigendian=False) as program: + sim = self.run_tst_program(program, initial_regs=gprs, + svstate=svstate) + print ("spr svstate ", sim.spr['SVSTATE']) + for i in range(len(vec)): + val = sim.gpr(16+i).value + res.append(val) + crf = sim.crl[i].get_range().value + print ("i", i, val, crf) + assert crf == crs_expected[i] + + def tst_sv_insert_sort(self): + """>>> lst = ["svshape 7, 0, 0, 7, 0", + "svremap 31, 0, 1, 0, 0, 0, 0", + "sv.add *0, *8, *16" + ] + REMAP add RT,RA,RB + ctr = alen-1 + li r10, 1 # prepare mask + sld r10, alen, r10 + addi r10, r10, -1 # all 1s. must be better way +loop: + setvl r3, ctr + sv.mv/m=1<