return cvt
+def signinv(res, sign):
+ if sign == 1:
+ return res
+ if sign == 0:
+ return 0.0
+ if sign == -1:
+ return -res
+
+
def FPMUL32(FRA, FRB, sign=1):
from openpower.decoder.isafunctions.double2single import DOUBLE2SINGLE
#return FPMUL64(FRA, FRB)
- #FRA = DOUBLE(SINGLE(FRA))
- #FRB = DOUBLE(SINGLE(FRB))
- result = float(FRA) * float(FRB) * float(sign)
+ FRA = DOUBLE(SINGLE(FRA))
+ FRB = DOUBLE(SINGLE(FRB))
+ result = signinv(float(FRA) * float(FRB), sign)
log ("FPMUL32", FRA, FRB, float(FRA), float(FRB), result, sign)
cvt = fp64toselectable(result)
cvt = DOUBLE2SINGLE(cvt)
#return FPDIV64(FRA, FRB)
#FRA = DOUBLE(SINGLE(FRA))
#FRB = DOUBLE(SINGLE(FRB))
- result = float(sign) * float(FRA) / float(FRB)
+ result = signinv(float(FRA) / float(FRB), sign)
cvt = fp64toselectable(result)
cvt = DOUBLE2SINGLE(cvt)
log ("FPDIV32", FRA, FRB, result, cvt)
def FPMUL64(FRA, FRB, sign=1):
- result = float(FRA) * float(FRB) * float(sign)
+ result = signinv(float(FRA) * float(FRB), sign)
cvt = fp64toselectable(result)
log ("FPMUL64", FRA, FRB, result, cvt, sign)
return cvt
def FPDIV64(FRA, FRB, sign=1):
- result = float(sign) * float(FRA) / float(FRB)
+ result = signinv(float(FRA) / float(FRB), sign)
cvt = fp64toselectable(result)
log ("FPDIV64", FRA, FRB, result, cvt, sign)
return cvt
with Program(lst, bigendian=False) as program:
sim = self.run_tst_program(program, initial_fprs=fprs)
- self.assertEqual(sim.fpr(3), SelectableInt(0x3d9d8b31c0000000, 64))
+ self.assertEqual(sim.fpr(3), SelectableInt(0x3d8b1663a0000000, 64))
def test_fp_muls4(self):
""">>> lst = ["fmuls 3, 1, 2",