From: Dmitry Selyutin Date: Tue, 6 Sep 2022 18:26:53 +0000 (+0300) Subject: power_fields: allow getting individual field bits X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a4178d8ef60c19fa5f6ef4da5a117c17759c76cf;p=openpower-isa.git power_fields: allow getting individual field bits --- diff --git a/src/openpower/decoder/power_fields.py b/src/openpower/decoder/power_fields.py index 48cd23d4..fe2713d2 100644 --- a/src/openpower/decoder/power_fields.py +++ b/src/openpower/decoder/power_fields.py @@ -175,6 +175,13 @@ class Field(Reference, metaclass=FieldMeta): for bit in self.__class__: yield self.storage[bit] + def __getitem__(self, key): + if isinstance(key, int): + bit = self.storage[self.__class__.__members__[key]] + return _SelectableInt(value=bit, bits=1) + + return _selectconcat(*(self[bit] for bit in tuple(key))) + class ArrayMeta(type): def __new__(metacls, clsname, bases, ns, items=()):