fix bug in cmpli (and cmplw)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 2 Sep 2020 17:48:34 +0000 (18:48 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 2 Sep 2020 17:48:34 +0000 (18:48 +0100)
src/soc/fu/alu/main_stage.py
src/soc/fu/alu/test/test_pipe_caller.py
src/soc/litex/florent/sim.py

index 7f98c344535ea6665262afb2f71fb4e8e4f0f18c..b4c4bb2a0e705a6086b23b9f34981ffdb0acefba 100644 (file)
@@ -60,7 +60,10 @@ class ALUMainStage(PipeModBase):
 
         a_i = Signal.like(a)
         b_i = Signal.like(b)
-        with m.If(is_32bit):
+        with m.If(op.insn_type == MicrOp.OP_CMP): # another temporary hack
+            comb += a_i.eq(a)                     # reaaaally need to move CMP
+            comb += b_i.eq(b)                     # into trap pipeline
+        with m.Elif(is_32bit):
             with m.If(op.is_signed):
                 comb += a_i.eq(exts(a, 32, 64))
                 comb += b_i.eq(exts(b, 32, 64))
index 5d8122c7af3e382bc4b2a29127056022796c6b86..5cf37307f21282435b9e886070b40f077be89290 100644 (file)
@@ -288,6 +288,25 @@ class ALUTestCase(TestAccumulatorBase):
                                 initial_sprs = {'XER': XER},
                                 initial_cr = CR)
 
+    def case_cmpli_microwatt(self):
+        """microwatt 1.bin: cmpli
+           123ac:   9c 79 8d 2a     cmpli   cr5,0,r13,31132
+            gpr: 00000000301fc7a7 <- r13
+            cr : 0000000090215393
+            xer: so 1 ca 0 32 0 ov 0 32 0
+
+        """
+
+        lst = ["cmpli 5, 0, 13, 31132"]
+        initial_regs = [0] * 32
+        initial_regs[13] = 0x301fc7a7
+        XER = 0xe00c0000
+        CR = 0x90215393
+
+        self.add_case(Program(lst, bigendian), initial_regs,
+                                initial_sprs = {'XER': XER},
+                                initial_cr = CR)
+
     def case_extsb(self):
         insns = ["extsb", "extsh", "extsw"]
         for i in range(10):
index 13e41029ae48dce8a8ca0e30f58f635032aff380..afe4140f9de89e86df49c8afa0fcb43dc74c2661 100755 (executable)
@@ -308,7 +308,7 @@ class LibreSoCSim(SoCSDRAM):
         )
 
         if cpu == "libresoc":
-            self.comb += active_dbg_cr.eq((0x10300 <= pc) & (pc <= 0x12000))
+            self.comb += active_dbg_cr.eq((0x10300 <= pc) & (pc <= 0x12600))
             #self.comb += active_dbg_cr.eq(1)
 
             # get the CR