pass SPR MicroOp to MMU function unit
authorTobias Platen <tplaten@posteo.de>
Thu, 4 Feb 2021 19:19:39 +0000 (20:19 +0100)
committerTobias Platen <tplaten@posteo.de>
Thu, 4 Feb 2021 19:19:39 +0000 (20:19 +0100)
src/soc/decoder/power_decoder2.py
src/soc/simple/core.py

index 2f6c0bdec572db0ab605e83087ec7b72758e704c..bfe9eda4d3a29f6f6f37a3d4248248fcff6d0c90 100644 (file)
@@ -889,7 +889,16 @@ class PowerDecodeSubset(Elaboratable):
 
         # set up instruction type
         # no op: defaults to OP_ILLEGAL
-        comb += self.do_copy("insn_type", self.op_get("internal_op"))
+        if self.fn_name=="MMU":
+            # mmu is special case: needs SPR opcode as well
+            mmu0 = self.mmu0_spr_dec
+            with m.If(((mmu0.dec.op.internal_op == MicrOp.OP_MTSPR) |
+                       (mmu0.dec.op.internal_op == MicrOp.OP_MFSPR))):
+                comb += self.do_copy("insn_type", mmu0.op_get("internal_op"))
+            with m.Else():
+                comb += self.do_copy("insn_type", self.op_get("internal_op"))
+        else:
+            comb += self.do_copy("insn_type", self.op_get("internal_op"))
 
         # function unit for decoded instruction: requires minor redirect
         # for SPR set/get
index 9d115a3dc297e450b5fc02e854a90b9c8b0d28bc..d3a66bb1e9916c50277b1d5b1dc2a859707fc90b 100644 (file)
@@ -114,6 +114,9 @@ class NonProductionCore(Elaboratable):
                                                       state=self.state)
             self.des[funame] = self.decoders[funame].do
 
+        if "mmu0" in self.decoders:
+            self.decoders["mmu0"].mmu0_spr_dec = self.decoders["spr0"]
+
     def elaborate(self, platform):
         m = Module()
         # for testing purposes, to cut down on build time in coriolis2