From: Dmitry Selyutin Date: Wed, 17 Aug 2022 20:18:12 +0000 (+0300) Subject: selectable_int: allow multi-level fields X-Git-Tag: sv_maxu_works-initial~42 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bbd29547b0f5c83f6ae23e7b6efbcc6bc1d75627;p=openpower-isa.git selectable_int: allow multi-level fields --- 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):