From: Luke Kenneth Casson Leighton Date: Wed, 23 Jun 2021 22:15:04 +0000 (+0100) Subject: add PowerOp.like function to be able to duplicate a PowerOp X-Git-Tag: xlen-bcd~400 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bc5d10263fdbd8272d2e410f1d2b9b60ebb4bc0;p=openpower-isa.git add PowerOp.like function to be able to duplicate a PowerOp --- diff --git a/src/openpower/decoder/power_decoder.py b/src/openpower/decoder/power_decoder.py index c06cb76f..1682941e 100644 --- a/src/openpower/decoder/power_decoder.py +++ b/src/openpower/decoder/power_decoder.py @@ -179,8 +179,13 @@ class PowerOp: which generates an awful lot of wires, hence the subsetting """ - def __init__(self, incl_asm=True, name=None, subset=None): + def __init__(self, incl_asm=True, name=None, subset=None, fields=None): + self.name = name self.subset = subset + if fields is not None: + for k, v in fields: + setattr(self, k, v) + return debug_report = set() fields = set() for field, ptype in power_op_types.items(): @@ -198,10 +203,19 @@ class PowerOp: debug_report.add(field) fname = get_pname(field, name) setattr(self, field, Signal(reset_less=True, name=fname)) + self._fields = fields # comment out, bit too high debug level #print("PowerOp debug", name, debug_report) #print(" fields", fields) + @staticmethod + def like(other): + fields = {} + for fname in other._fields: + sig = getattr(other, fname) + fields[fname] = sig.__class__.like(sig) + return PowerOp(subset=other.subset, fields=fields) + def _eq(self, row=None): if row is None: row = default_values