From: Dmitry Selyutin Date: Wed, 14 Sep 2022 22:50:10 +0000 (+0300) Subject: selectable_int: allow setting multiple bit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4f59f5dadad337a3482f3eaf9706af25d6bd766;p=openpower-isa.git selectable_int: allow setting multiple bit --- diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 73802958..02c8839a 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -386,7 +386,6 @@ class SelectableInt: return SelectableInt(value, bits) else: bits = [] - key = tuple(key) for bit in key: if not isinstance(bit, (int, SelectableInt)): raise ValueError(key) @@ -434,7 +433,21 @@ class SelectableInt: value = value << start self.value = (self.value & ~mask) | (value & mask) else: - raise ValueError(key) + bits = [] + for bit in key: + if not isinstance(bit, (int, SelectableInt)): + raise ValueError(key) + bits.append(bit) + + if isinstance(value, int): + if value.bit_count() > len(bits): + raise ValueError(value) + value = SelectableInt(value=value, bits=len(bits)) + if not isinstance(value, SelectableInt): + raise ValueError(value) + + for (src, dst) in enumerate(bits): + self[dst] = value[src] def __ge__(self, other): if isinstance(other, FieldSelectableInt):