allow FieldSelectableInt to initialise from list or tuple
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 7 Apr 2020 14:30:26 +0000 (15:30 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 7 Apr 2020 14:30:26 +0000 (15:30 +0100)
src/soc/decoder/selectable_int.py

index 13ab4807150edf1538af6bf59530c0efe98711d6..2e663bc92215ec985d10446cf8a4cd2bf57c4d27 100644 (file)
@@ -15,6 +15,11 @@ class FieldSelectableInt:
     """
     def __init__(self, si, br):
         self.si = si # target selectable int
+        if isinstance(br, list) or isinstance(br, tuple):
+            _br = BitRange()
+            for i, v in enumerate(br):
+                _br[i] = v
+            br = _br
         self.br = br # map of indices.
 
     def _op(self, op, b):