From e978c3f52c60ca4ed5bceec45037a7e4b6892ec6 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 28 Sep 2021 11:34:50 +0100 Subject: [PATCH] convert test_caller_svp64_dct.py unit test to use new helper class to get at DOUBLE2SINGLE previously could import it as a (global) function --- .../decoder/isa/test_caller_svp64_dct.py | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/openpower/decoder/isa/test_caller_svp64_dct.py b/src/openpower/decoder/isa/test_caller_svp64_dct.py index 61bf5494..564ed5af 100644 --- a/src/openpower/decoder/isa/test_caller_svp64_dct.py +++ b/src/openpower/decoder/isa/test_caller_svp64_dct.py @@ -9,7 +9,7 @@ from openpower.decoder.isa.test_caller import run_tst from openpower.sv.trans.svp64 import SVP64Asm from copy import deepcopy from openpower.decoder.helpers import fp64toselectable, SINGLE -from openpower.decoder.isafunctions.double2single import DOUBLE2SINGLE +from openpower.decoder.isafunctions.double2single import ISACallerFnHelper from openpower.decoder.isa.remap_dct_yield import (halfrev2, reverse_bits, iterate_dct_inner_butterfly_indices, iterate_dct_outer_butterfly_indices, @@ -18,6 +18,10 @@ from openpower.decoder.isa.fastdctlee import inverse_transform_iter import unittest import math +# really bad hack. need to access the DOUBLE2SINGLE function auto-generated +# from pseudo-code. +fph = ISACallerFnHelper(XLEN=64) + def transform_inner_radix2_dct(vec, ctable): @@ -281,11 +285,11 @@ class DCTTestCase(FHDLTestCase): # and FPSUB32 directly to be honest. t = a + b diff = (a - b) - diff = DOUBLE2SINGLE(fp64toselectable(diff)) # FP32 round + diff = fph.DOUBLE2SINGLE(fp64toselectable(diff)) # FP32 round diff = float(diff) u = diff * c - tc = DOUBLE2SINGLE(fp64toselectable(t)) # convert to Power single - uc = DOUBLE2SINGLE(fp64toselectable(u)) # from double + tc = fph.DOUBLE2SINGLE(fp64toselectable(t)) # cvt to Power single + uc = fph.DOUBLE2SINGLE(fp64toselectable(u)) # from double res.append((uc, tc)) print ("DCT", i, "in", a, b, "c", c, "res", t, u) @@ -366,7 +370,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -428,7 +432,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -486,7 +490,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -537,7 +541,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -619,7 +623,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -688,7 +692,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -907,7 +911,7 @@ class DCTTestCase(FHDLTestCase): print ("i", i, float(sim.fpr(i)), "expected", expected) for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -997,7 +1001,7 @@ class DCTTestCase(FHDLTestCase): for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test @@ -1089,7 +1093,7 @@ class DCTTestCase(FHDLTestCase): for i, expected in enumerate(res): # convert to Power single - expected = DOUBLE2SINGLE(fp64toselectable(expected)) + expected = fph.DOUBLE2SINGLE(fp64toselectable(expected)) expected = float(expected) actual = float(sim.fpr(i)) # approximate error calculation, good enough test -- 2.30.2