From 0fab64475349665fae53c30970a6a66b969cc614 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 17:15:17 +0100 Subject: [PATCH] allow int in addition and subtraction --- src/soc/decoder/selectable_int.py | 4 ++++ 1 file changed, 4 insertions(+) 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) -- 2.30.2