when mtocrf FXM is 0, the CR has to be set to CR7
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 2 Sep 2020 22:08:27 +0000 (23:08 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 2 Sep 2020 22:08:27 +0000 (23:08 +0100)
src/soc/decoder/power_decoder2.py
src/soc/fu/cr/test/test_pipe_caller.py

index 8ef8959aec54e8cd6a075b40b2cf1a2316133087..edbbf8783037c4d3a97c29be805cf26b88752822 100644 (file)
@@ -586,7 +586,10 @@ class DecodeCROut(Elaboratable):
                     with m.If(move_one):
                         # must one-hot the FXM field
                         comb += ppick.i.eq(self.dec.FXM)
-                        comb += self.whole_reg.data.eq(ppick.o)
+                        with m.If(ppick.en_o):
+                            comb += self.whole_reg.data.eq(ppick.o)
+                        with m.Else():
+                            comb += self.whole_reg.data.eq(0b00000001) # CR7
                     with m.Else():
                         comb += self.whole_reg.data.eq(self.dec.FXM)
                 with m.Else():
index 8e71a3a84882f686679a04837e29d70a63db046e..8b8a4616d56e4f6a32302fc119d45bae2ddd6beb 100644 (file)
@@ -134,6 +134,19 @@ class CRTestCase(TestAccumulatorBase):
         p.assembly = '\n'.join(dis)+'\n'
         self.add_case(p, initial_regs=initial_regs, initial_cr=cr)
 
+    def case_mtocrf_regression_2(self):
+        """microwatt 1.bin regression, zero fxm
+           mtocrf 0,16     14928:   21 09 10 7e     .long 0x7e100921
+        """
+        dis = ["mtocrf 16, 0"]
+        lst = bytes([0x21, 0x09, 0x10, 0x7e]) # 0x7e100921
+        cr = 0x3F089F7F
+        initial_regs = [0] * 32
+        initial_regs[16] = 0x0001C020
+        p = Program(lst, bigendian)
+        p.assembly = '\n'.join(dis)+'\n'
+        self.add_case(p, initial_regs=initial_regs, initial_cr=cr)
+
     def case_mfocrf_1(self):
         lst = [f"mfocrf 2, 1"]
         cr = 0x1234