From: Luke Kenneth Casson Leighton Date: Mon, 6 Jul 2020 19:19:06 +0000 (+0100) Subject: fix SelectableInt abs X-Git-Tag: div_pipeline~162^2~27 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=216d90427012b1b8086bcae4bb564867c8c77e84;p=soc.git fix SelectableInt abs --- diff --git a/src/soc/decoder/selectable_int.py b/src/soc/decoder/selectable_int.py index 3036b6f6..1bd2b94c 100644 --- a/src/soc/decoder/selectable_int.py +++ b/src/soc/decoder/selectable_int.py @@ -197,7 +197,10 @@ class SelectableInt: def __xor__(self, b): return self._op(xor, b) def __abs__(self): - return SelectableInt(0, self.bits) - self + print ("abs", self.value & (1<<(self.bits-1))) + if self.value & (1<<(self.bits-1)) != 0: + return SelectableInt(0, self.bits) - self + return self def __rsub__(self, b): if isinstance(b, int):