From: Luke Kenneth Casson Leighton Date: Mon, 11 Jul 2022 11:55:51 +0000 (+0100) Subject: fix issue in SelectableInt using slices involving SelectableInts X-Git-Tag: sv_maxu_works-initial~257 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ebeb965606db0b7d9acf5577722abbb2960dc19;p=openpower-isa.git fix issue in SelectableInt using slices involving SelectableInts --- diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 1e7458ee..a3eca3d4 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -333,14 +333,19 @@ class SelectableInt: mask = 1 << key self.value = (self.value & ~mask) | (value & mask) 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, \ - "key stop %d bits %d" % (key.stop, self.bits) - - stop = self.bits - key.start - start = self.bits - key.stop + kstart, kstop, kstep = key.start, key.stop, key.step + if isinstance(kstart, SelectableInt): kstart = kstart.asint() + if isinstance(kstop, SelectableInt): kstop = kstop.asint() + if isinstance(kstep, SelectableInt): kstep = kstep.asint() + log ("__setitem__ slice ", kstart, kstop, kstep) + assert kstep is None or kstep == 1 + assert kstart < kstop + assert kstart >= 0 + assert kstop <= self.bits, \ + "key stop %d bits %d" % (kstop, self.bits) + + stop = self.bits - kstart + start = self.bits - kstop bits = stop - start #log ("__setitem__ slice num bits", bits)