From: Luke Kenneth Casson Leighton Date: Mon, 6 Jul 2020 18:44:58 +0000 (+0100) Subject: SelectableInt: make __mul__ return enough space to fit the result X-Git-Tag: div_pipeline~162^2~30 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=30d70888160a45ec0562b3610d35d06145447102;p=soc.git SelectableInt: make __mul__ return enough space to fit the result --- diff --git a/src/soc/decoder/selectable_int.py b/src/soc/decoder/selectable_int.py index 0c5e560c..3036b6f6 100644 --- a/src/soc/decoder/selectable_int.py +++ b/src/soc/decoder/selectable_int.py @@ -178,7 +178,12 @@ class SelectableInt: def __sub__(self, b): return self._op(sub, b) def __mul__(self, b): - return self._op(mul, b) + # different case: mul result needs to fit the total bitsize + if isinstance(b, int): + b = SelectableInt(b, self.bits) + print ("SelectableInt mul", hex(self.value), hex(b.value), + self.bits, b.bits) + return SelectableInt(self.value * b.value, self.bits + b.bits) def __floordiv__(self, b): return self._op(floordiv, b) def __truediv__(self, b):