debugging branch fast registers
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 2 Jun 2020 18:59:34 +0000 (19:59 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 2 Jun 2020 18:59:41 +0000 (19:59 +0100)
src/soc/decoder/power_decoder2.py
src/soc/fu/branch/pipe_data.py
src/soc/fu/compunits/test/test_branch_compunit.py

index a3d8d9b6d4e26e0507967107f2c030303d194ca5..e50d1ca5d35d45e1297a7d24e8ebe06d38b5b95e 100644 (file)
@@ -62,7 +62,8 @@ class DecodeA(Elaboratable):
         # BC or BCREG: potential implicit register (CTR) NOTE: same in DecodeOut
         with m.If((op.internal_op == InternalOp.OP_BC) |
                   (op.internal_op == InternalOp.OP_BCREG)):
-            with m.If(~self.dec.BO[2]): # 3.0B p38 BO2=0, use CTR reg
+            with m.If(~self.dec.BO[2] |        # 3.0B p38 BO2=0, use CTR reg
+                       self.dec.FormXL.XO[9]): # 3.0B p38 top bit of XO
                 comb += self.fast_out.data.eq(FastRegs.CTR) # constant: CTR
                 comb += self.fast_out.ok.eq(1)
 
@@ -156,13 +157,13 @@ class DecodeB(Elaboratable):
 
         # decode SPR2 based on instruction type
         op = self.dec.op
-        # BCREG implicitly uses CTR or LR for 2nd reg
-        with m.If(op.internal_op == InternalOp.OP_BCREG):
-            with m.If(self.dec.FormXL.XO[9]): # 3.0B p38 top bit of XO
-                comb += self.fast_out.data.eq(FastRegs.CTR)
-            with m.Else():
+        # BCREG implicitly uses LR or TAR for 2nd reg (TODO: TAR)
+        # CTR however is already in fast_spr1 *not* 2.
+        with m.If((op.internal_op == InternalOp.OP_BC) |
+                 (op.internal_op == InternalOp.OP_BCREG)):
+            with m.If(~self.dec.FormXL.XO[9]): # 3.0B p38 top bit of XO
                 comb += self.fast_out.data.eq(FastRegs.LR)
-            comb += self.fast_out.ok.eq(1)
+                comb += self.fast_out.ok.eq(1)
 
         return m
 
index e29f0374b5c1f6fb2ad6d734ed6c8fdefa0cebfd..f8481db397841a7071a07e933348b3deadf7d83e 100644 (file)
@@ -95,6 +95,6 @@ class BranchPipeSpec(CommonPipeSpec):
     opsubsetkls = CompBROpSubset
     def rdflags(self, e): # in order of regspec
         cr1_en = e.read_cr1.ok # CR A
-        spr1_ok = e.read_spr1.ok # SPR1
-        spr2_ok = e.read_spr2.ok # SPR2
-        return Cat(spr1_ok, spr2_ok, cr1_en, 1) # CIA CR SPR1 SPR2
+        fast1_ok = e.read_fast1.ok # SPR1
+        fast2_ok = e.read_fast2.ok # SPR2
+        return Cat(fast1_ok, fast2_ok, cr1_en, 1) # SPR1 SPR2 CR CIA
index c8d02b67855e3c78ae5c6e8b6611d691c6b89173..312d3348b69787870a068a90bac9750d3a52ec31 100644 (file)
@@ -36,23 +36,24 @@ class BranchTestRunner(TestRunner):
 
         # CIA (PC)
         res['cia'] = sim.pc.CIA.value
+
         # CR A
         cr1_en = yield dec2.e.read_cr1.ok
         if cr1_en:
             cr1_sel = yield dec2.e.read_cr1.data
             res['cr_a'] = sim.crl[cr1_sel].get_range().value
 
-        # SPR1
-        spr_ok = yield dec2.e.read_spr1.ok
-        spr_num = yield dec2.e.read_spr1.data
+        # Fast1
+        spr_ok = yield dec2.e.read_fast1.ok
+        spr_num = yield dec2.e.read_fast1.data
         # HACK
         spr_num = fast_reg_to_spr(spr_num)
         if spr_ok:
             res['spr1'] = sim.spr[spr_dict[spr_num].SPR].value
 
         # SPR2
-        spr_ok = yield dec2.e.read_spr2.ok
-        spr_num = yield dec2.e.read_spr2.data
+        spr_ok = yield dec2.e.read_fast2.ok
+        spr_num = yield dec2.e.read_fast2.data
         # HACK
         spr_num = fast_reg_to_spr(spr_num)
         if spr_ok: