From: Luke Kenneth Casson Leighton Date: Sun, 15 Aug 2021 21:52:58 +0000 (+0100) Subject: allow constructor of SelectableInt to pass in (and copy) X-Git-Tag: xlen-bcd~126 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1b8082182ea982ee87f5d86489845b8c2a839f13;p=openpower-isa.git allow constructor of SelectableInt to pass in (and copy) another SelectableInt --- diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index 5e2c0fe8..34ea0155 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -170,6 +170,7 @@ class FieldSelectableIntTestCase(unittest.TestCase): fs[0:2] = 0b10 self.assertEqual(fs.get_range(), 0b1011) + class SelectableInt: """SelectableInt - a class that behaves exactly like python int @@ -182,8 +183,9 @@ class SelectableInt: including negative start/end points. """ - def __init__(self, value, bits): + def __init__(self, value, bits=None): if isinstance(value, SelectableInt): + bits = value.bits value = value.value mask = (1 << bits) - 1 self.value = value & mask