add __bool__ override to selectable_int
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Apr 2020 19:00:37 +0000 (20:00 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Apr 2020 19:00:37 +0000 (20:00 +0100)
src/soc/decoder/selectable_int.py

index 05cf2b21604ce75f461412c0393ba16e141d8226..53b84f60957e9ed3c5e2b672b2aafb26d727b815 100644 (file)
@@ -129,6 +129,9 @@ class SelectableInt:
             return onebit(other == self.value)
         assert False
 
+    def __bool__(self):
+        return self.value != 0
+
     def __repr__(self):
         return "SelectableInt(value={:x}, bits={})".format(self.value,
                                                            self.bits)