From 205f38092767d1623eda386e5543060a0d9035ff Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Tue, 1 Nov 2022 20:35:11 +0300 Subject: [PATCH] selectable_int: support variable concatenation --- src/openpower/decoder/selectable_int.py | 31 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 18174121..e90b68f1 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -371,14 +371,25 @@ class SelectableInt: #log("getitem", key, self.bits, hex(self.value), value) return SelectableInt(value, 1) elif isinstance(key, slice): - assert key.step is None or key.step == 1 - assert key.start < key.stop - assert key.start >= 0 - assert key.stop <= self.bits - - stop = self.bits - key.start - start = self.bits - key.stop - + start = key.start + if isinstance(start, SelectableInt): + start = start.value + stop = key.stop + if isinstance(stop, SelectableInt): + stop = stop.value + step = key.step + if isinstance(step, SelectableInt): + step = step.value + + assert step is None or step == 1 + assert start < stop + assert start >= 0 + assert stop <= self.bits + + (start, stop) = ( + (self.bits - stop), + (self.bits - start), + ) bits = stop - start #log ("__getitem__ slice num bits", start, stop, bits) mask = (1 << bits) - 1 @@ -548,7 +559,9 @@ def selectassign(lhs, idx, rhs): def selectconcat(*args, repeat=1): - if repeat != 1 and len(args) == 1 and isinstance(args[0], int): + if isinstance(repeat, SelectableInt): + repeat = repeat.value + if len(args) == 1 and isinstance(args[0], int) and args[0] in (0, 1): args = [SelectableInt(args[0], 1)] if repeat != 1: # multiplies the incoming arguments tmp = [] -- 2.30.2