Add test_branch_loop_ctr
authorMichael Nolan <mtnolan2640@gmail.com>
Thu, 7 May 2020 19:54:32 +0000 (15:54 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Thu, 7 May 2020 19:54:32 +0000 (15:54 -0400)
src/soc/decoder/isa/test_caller.py

index 15a8997ed2e435580f4c7e7e3aa1108c50e74f0f..97499d49af265340ea02bbc13c576b7ee1c92a82 100644 (file)
@@ -154,7 +154,19 @@ class DecoderTestCase(FHDLTestCase):
             sim = self.run_tst_program(program)
             # Verified with qemu
             self.assertEqual(sim.gpr(2), SelectableInt(0x37, 64))
-                    
+
+    def test_branch_loop_ctr(self):
+        lst = ["addi 1, 0, 0",
+               "addi 2, 0, 7",
+               "mtspr 9, 2",    # set ctr to 7
+               "addi 1, 1, 5",
+               "bc 16, 0, -0x4"]  # bdnz to the addi above
+        with Program(lst) as program:
+            sim = self.run_tst_program(program)
+            # Verified with qemu
+            self.assertEqual(sim.gpr(1), SelectableInt(0x23, 64))
+
+
 
     def test_add_compare(self):
         lst = ["addis 1, 0, 0xffff",