From c9d96f162b1bc4a48e95cd6a8ed25b82c11a95a4 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 5 Aug 2020 19:46:51 +0100 Subject: [PATCH] MULS on parameter b needed to check whether it was sign-extended --- src/soc/decoder/helpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/soc/decoder/helpers.py b/src/soc/decoder/helpers.py index 17534800..a50d0092 100644 --- a/src/soc/decoder/helpers.py +++ b/src/soc/decoder/helpers.py @@ -4,6 +4,7 @@ from nmutil.divmod import trunc_divs, trunc_rems from operator import floordiv, mod from soc.decoder.selectable_int import selectltu as ltu from soc.decoder.selectable_int import selectgtu as gtu +from soc.decoder.selectable_int import check_extsign trunc_div = floordiv trunc_rem = mod @@ -37,6 +38,9 @@ def EXTS64(value): # signed version of MUL def MULS(a, b): + if isinstance(b, int): + b = SelectableInt(b, self.bits) + b = check_extsign(a, b) a_s = a.value & (1 << (a.bits-1)) != 0 b_s = b.value & (1 << (b.bits-1)) != 0 result = abs(a) * abs(b) -- 2.30.2