From: Luke Kenneth Casson Leighton Date: Fri, 14 May 2021 17:28:31 +0000 (+0100) Subject: add very quick float convert to SelectableInt X-Git-Tag: 0.0.3~49 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2b9817e66686f162a2aafc989795eee424861d5;p=openpower-isa.git add very quick float convert to SelectableInt --- diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 1481f289..c997acd5 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -1,4 +1,5 @@ import unittest +import struct from copy import copy from openpower.decoder.power_fields import BitRange from operator import (add, sub, mul, floordiv, truediv, mod, or_, and_, xor, @@ -416,6 +417,14 @@ class SelectableInt: def asint(self): return self.value + def __float__(self): + """convert to double-precision float. TODO, properly convert + rather than a hack-job: must actually support Power IEEE754 FP + """ + assert self.bits == 64 # must be 64-bit + data = self.value.to_bytes(8, byteorder='little') + return struct.unpack('