From e4f59f5dadad337a3482f3eaf9706af25d6bd766 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Thu, 15 Sep 2022 01:50:10 +0300 Subject: [PATCH] selectable_int: allow setting multiple bit --- src/openpower/decoder/selectable_int.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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): -- 2.30.2