From 99565bb98a3e5e7b770efc529a5134699cab3c31 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 18 Aug 2022 21:48:58 +0100 Subject: [PATCH] selectable_int: fix check on SI constructor Specifying the number of bits *is* allowed, it should mean "override the length". More unit tests need running to confirm. --- src/openpower/decoder/selectable_int.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 56ba07c3..22985014 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -221,7 +221,9 @@ class SelectableInt: def __init__(self, value, bits=None): if isinstance(value, SelectableInt): if bits is not None: - raise ValueError(value) + # check if the bitlength is different. TODO, allow override? + if bits != value.bits: + raise ValueError(value) bits = value.bits value = value.value elif isinstance(value, FieldSelectableInt): -- 2.30.2