From 216d90427012b1b8086bcae4bb564867c8c77e84 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 6 Jul 2020 20:19:06 +0100 Subject: [PATCH] fix SelectableInt abs --- src/soc/decoder/selectable_int.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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): -- 2.30.2