From: Luke Kenneth Casson Leighton Date: Fri, 14 May 2021 16:47:48 +0000 (+0100) Subject: add SINGLE function to helpers, for FP Store X-Git-Tag: 0.0.3~51 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=651c2ce5e9fc8ab75327100f4eb84634542e2a0f;p=openpower-isa.git add SINGLE function to helpers, for FP Store --- diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index 97a7d8ae..aa2b58e1 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -168,7 +168,7 @@ def DOUBLE(WORD): if WORD[1:9] == 0 and WORD[9:32] != 0: sign = WORD[0] exp = -126 - frac[0:53] = selectconcat(z1, WORD[9:32], z29) + frac = selectconcat(z1, WORD[9:32], z29) # normalize the operand while frac[0] == 0: frac[0:53] = selectconcat(frac[1:53], z1) @@ -188,6 +188,34 @@ def DOUBLE(WORD): return FRT +def SINGLE(FRS): + """convert incoming FRS into 32-bit word. v3.0B p144 section 4.6.3 + """ + # result - WORD - start off all zeros + WORD = SelectableInt(0, 32) + + #No Denormalization Required (includes Zero / Infinity / NaN) + if FRS[1:12] > 896 or FRS[1:64] == 0: + WORD[0:2] = FRS[0:2] + WORD[2:32] = FRS[5:35] + + #Denormalization Required + if FRS[1:12] >= 874 and FRS[1:12] <= 896: + sign = FRS[0] + exp = FRS[1:12] - 1023 + frac = selectconcat(SelectableInt(1, 1), FRS[12:64]) + # denormalize operand + while exp < -126: + frac[0:53] = selectconcat(SelectableInt(0, 1), frac[0:52]) + exp = exp + 1 + WORD[0] = sign + WORD[1:9] = SelectableInt(0, 8) + WORD[9:32] = frac[1:24] + #else WORD = undefined # return zeros + + return WORD + + # For these tests I tried to find power instructions that would let me # isolate each of these helper operations. So for instance, when I was # testing the MASK() function, I chose rlwinm and rldicl because if I