use new PowerOp.like function in PowerDecoder, fix missing fields
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 24 Jun 2021 14:34:43 +0000 (15:34 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 24 Jun 2021 14:34:43 +0000 (15:34 +0100)
src/openpower/decoder/power_decoder.py
src/openpower/decoder/power_decoder2.py

index 229073242d731587d4476cca9bca695a54554f5c..8d7fcfa921b1dbbee1e5dc65303338818861bd16 100644 (file)
@@ -183,7 +183,7 @@ class PowerOp:
         self.name = name
         self.subset = subset
         if fields is not None:
-            for k, v in fields:
+            for k, v in fields.items():
                 setattr(self, k, v)
             return
         debug_report = set()
@@ -214,8 +214,9 @@ class PowerOp:
         """
         fields = {}
         for fname in other._fields:
-            sig = getattr(other, fname)
-            fields[fname] = sig.__class__.like(sig)
+            sig = getattr(other, fname, None)
+            if sig is not None:
+                fields[fname] = sig.__class__.like(sig)
         return PowerOp(subset=other.subset, fields=fields)
 
     def _eq(self, row=None):
index 10906ede7ba75541ef5764858c03a84beeb664ed..9d26e6778467575f0fdb8a6528a39b4caa419092 100644 (file)
@@ -25,7 +25,8 @@ from openpower.sv.svp64 import SVP64Rec
 
 from openpower.decoder.power_regspec_map import regspec_decode_read
 from openpower.decoder.power_decoder import (create_pdecode,
-                                             create_pdecode_svp64_ldst,)
+                                             create_pdecode_svp64_ldst,
+                                             PowerOp)
 from openpower.decoder.power_enums import (MicrOp, CryIn, Function,
                                      CRInSel, CROutSel,
                                      LdstLen, In1Sel, In2Sel, In3Sel,
@@ -788,6 +789,9 @@ class PowerDecodeSubset(Elaboratable):
                                               row_subset=self.rowsubsetfn)
             self.svdecldst = svdecldst
 
+        # set up a copy of the PowerOp
+        self.op = PowerOp.like(self.dec.op)
+
         # state information needed by the Decoder
         if state is None:
             state = CoreState("dec2")
@@ -875,6 +879,10 @@ class PowerDecodeSubset(Elaboratable):
         m.submodules.dec_rc = self.dec_rc = dec_rc = DecodeRC(self.dec)
         m.submodules.dec_oe = dec_oe = DecodeOE(self.dec, op)
 
+        # use op from first decoder (self.dec.op) if not in SVP64-LDST mode
+        # (TODO)
+        comb += self.op.eq(self.dec.op)
+
         if self.svp64_en:
             # and SVP64 RM mode decoder
             m.submodules.sv_rm_dec = rm_dec = self.rm_dec
@@ -1104,7 +1112,7 @@ class PowerDecode2(PowerDecodeSubset):
         m = super().elaborate(platform)
         comb = m.d.comb
         state = self.state
-        e_out, op, do_out = self.e, self.dec.op, self.e.do
+        op, e_out, do_out = self.op, self.e, self.e.do
         dec_spr, msr, cia, ext_irq = state.dec, state.msr, state.pc, state.eint
         rc_out = self.dec_rc.rc_out.data
         e = self.e_tmp