[Bug 580] redirect MMU SPRs to the MMU
[soc.git] / src / soc / decoder / power_decoder2.py
index 5e89916a28d5f9d3d6a5ed7588f7a53cfb0df4c3..1633d1912aa468bf44b8f4ed1568cbc28a1ddd82 100644 (file)
@@ -632,9 +632,11 @@ class PowerDecodeSubset(Elaboratable):
         if opkls is None:
             opkls = Decode2ToOperand
         self.do = opkls(fn_name)
+        col_subset = self.get_col_subset(self.do)
+
+        # only needed for "main" PowerDecode2
         if not self.final:
             self.e = Decode2ToExecute1Type(name=self.fn_name, do=self.do)
-        col_subset = self.get_col_subset(self.do)
 
         # create decoder if one not already given
         if dec is None:
@@ -723,7 +725,25 @@ class PowerDecodeSubset(Elaboratable):
         # set up instruction, pick fn unit
         # no op: defaults to OP_ILLEGAL
         comb += self.do_copy("insn_type", self.op_get("internal_op"))
-        comb += self.do_copy("fn_unit", self.op_get("function_unit"))
+
+        #function unit for decoded instruction
+        fn = self.op_get("function_unit")
+        spr = Signal(10, reset_less=True)
+        comb += spr.eq(decode_spr_num(self.dec.SPR)) # from XFX
+
+        # for first test only forward SPR 18 to mmu
+        with m.If(self.dec.op.internal_op == MicrOp.OP_MTSPR):
+            with m.If((spr == 18) | (spr == 19)):
+                comb += self.do_copy("fn_unit",Function.MMU)
+            with m.Else():
+                comb += self.do_copy("fn_unit",fn)
+        with m.If(self.dec.op.internal_op == MicrOp.OP_MFSPR):
+            with m.If((spr == 18) | (spr == 19)):
+                comb += self.do_copy("fn_unit",Function.MMU)
+            with m.Else():
+                comb += self.do_copy("fn_unit",fn)
+        with m.Else():
+            comb += self.do_copy("fn_unit",fn)
 
         # immediates
         if self.needs_field("zero_a", "in1_sel"):