From: Luke Kenneth Casson Leighton Date: Wed, 5 Aug 2020 18:46:51 +0000 (+0100) Subject: MULS on parameter b needed to check whether it was sign-extended X-Git-Tag: semi_working_ecp5~429^2~1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c9d96f162b1bc4a48e95cd6a8ed25b82c11a95a4;p=soc.git MULS on parameter b needed to check whether it was sign-extended --- 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)