From 73e48dc3b73b22752858c4ba94303292a20da7cf Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 8 Jun 2021 13:09:01 +0100 Subject: [PATCH] add better debug logs and asserts for SelectableInt slice --- src/openpower/decoder/selectable_int.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 81e28d34..a3e2974c 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -310,14 +310,15 @@ class SelectableInt: def __setitem__(self, key, value): if isinstance(key, SelectableInt): key = key.value - log("setitem", key, self.bits, hex(self.value)) if isinstance(key, int): - assert key < self.bits - assert key >= 0 - key = self.bits - (key + 1) if isinstance(value, SelectableInt): assert value.bits == 1 value = value.value + log("setitem", key, self.bits, hex(self.value), hex(value)) + + assert key < self.bits + assert key >= 0 + key = self.bits - (key + 1) value = value << key mask = 1 << key @@ -326,7 +327,8 @@ class SelectableInt: assert key.step is None or key.step == 1 assert key.start < key.stop assert key.start >= 0 - assert key.stop <= self.bits + assert key.stop <= self.bits, \ + "key stop %d bits %d" % (key.stop, self.bits) stop = self.bits - key.start start = self.bits - key.stop @@ -336,6 +338,7 @@ class SelectableInt: if isinstance(value, SelectableInt): assert value.bits == bits, "%d into %d" % (value.bits, bits) value = value.value + log("setitem", key, self.bits, hex(self.value), hex(value)) mask = ((1 << bits) - 1) << start value = value << start self.value = (self.value & ~mask) | (value & mask) -- 2.30.2