From bbd29547b0f5c83f6ae23e7b6efbcc6bc1d75627 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Wed, 17 Aug 2022 23:18:12 +0300 Subject: [PATCH] selectable_int: allow multi-level fields --- src/openpower/decoder/selectable_int.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 5a8a9b9d..baeab54f 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -24,15 +24,27 @@ class FieldSelectableInt: """ def __init__(self, si, br): - if not isinstance(si, SelectableInt): + if not isinstance(si, (FieldSelectableInt, SelectableInt)): raise ValueError(si) - self.si = si # target selectable int + if isinstance(br, (list, tuple, range)): _br = BitRange() for i, v in enumerate(br): _br[i] = v br = _br - self.br = br # map of indices. + + if isinstance(si, FieldSelectableInt): + fsi = si + if len(br) > len(fsi.br): + raise OverflowError(br) + _br = BitRange() + for (i, v) in br.items(): + _br[i] = fsi.br[v] + br = _br + si = fsi.si + + self.si = si # target selectable int + self.br = br # map of indices def eq(self, b): if isinstance(b, int): -- 2.30.2