From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 16:15:17 +0000 (+0100) Subject: allow int in addition and subtraction X-Git-Tag: div_pipeline~1530 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0fab64475349665fae53c30970a6a66b969cc614;p=soc.git allow int in addition and subtraction --- diff --git a/src/soc/decoder/selectable_int.py b/src/soc/decoder/selectable_int.py index b8998b89..1dd41511 100644 --- a/src/soc/decoder/selectable_int.py +++ b/src/soc/decoder/selectable_int.py @@ -9,10 +9,14 @@ class SelectableInt: self.bits = bits def __add__(self, b): + if isinstance(b, int): + b = SelectableInt(b, self.bits) assert b.bits == self.bits return SelectableInt(self.value + b.value, self.bits) def __sub__(self, b): + if isinstance(b, int): + b = SelectableInt(b, self.bits) assert b.bits == self.bits return SelectableInt(self.value - b.value, self.bits)