From 4bc5d10263fdbd8272d2e410f1d2b9b60ebb4bc0 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 23 Jun 2021 23:15:04 +0100 Subject: [PATCH] add PowerOp.like function to be able to duplicate a PowerOp --- src/openpower/decoder/power_decoder.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 -- 2.30.2