add comments to power decoder
[soc.git] / src / soc / simulator / test_sim.py
index 95e0d291f0f165c7c4d445ce8d948c5674fd6478..0a26380cd996d20f4bd65585bc1bbcea257bd5bc 100644 (file)
@@ -46,7 +46,7 @@ class DecoderTestCase(FHDLTestCase):
 
         sim.add_process(process)
         with sim.write_vcd("simulator.vcd", "simulator.gtkw",
-                           traces=[pdecode2.ports()]):
+                           traces=pdecode2.ports()):
             sim.run()
 
     def test_example(self):
@@ -55,7 +55,7 @@ class DecoderTestCase(FHDLTestCase):
                "add  3, 1, 2",
                "and  4, 1, 2"]
         with Program(lst) as program:
-            self.run_test_program(program, [1, 2, 3, 4])
+            self.run_tst_program(program, [1, 2, 3, 4])
 
     def test_ldst(self):
         lst = ["addi 1, 0, 0x1234",
@@ -63,7 +63,7 @@ class DecoderTestCase(FHDLTestCase):
                "stw  1, 0(2)",
                "lwz  3, 0(2)"]
         with Program(lst) as program:
-            self.run_test_program(program, [1, 2, 3])
+            self.run_tst_program(program, [1, 2, 3])
 
     def test_ldst_extended(self):
         lst = ["addi 1, 0, 0x1234",
@@ -72,7 +72,7 @@ class DecoderTestCase(FHDLTestCase):
                "stw  1, 0x40(2)",
                "lwzx  3, 4, 2"]
         with Program(lst) as program:
-            self.run_test_program(program, [1, 2, 3])
+            self.run_tst_program(program, [1, 2, 3])
 
     def test_ldst_widths(self):
         lst = [" lis 1, 0xdead",
@@ -86,16 +86,43 @@ class DecoderTestCase(FHDLTestCase):
                "stb 5, 5(2)",
                "ld  5, 0(2)"]
         with Program(lst) as program:
-            self.run_test_program(program, [1, 2, 3, 4, 5])
+            self.run_tst_program(program, [1, 2, 3, 4, 5])
 
     def test_sub(self):
         lst = ["addi 1, 0, 0x1234",
                "addi 2, 0, 0x5678",
-               "subf 1, 1, 2"]
+               "subf 3, 1, 2",
+               "subfic 4, 1, 0x1337",
+               "neg 5, 1"]
         with Program(lst) as program:
-            self.run_test_program(program, [1, 2])
+            self.run_tst_program(program, [1, 2, 3, 4, 5])
+
+    def test_add_with_carry(self):
+        lst = ["addi 1, 0, 5",
+               "neg 1, 1",
+               "addi 2, 0, 7",
+               "neg 2, 2",
+               "addc 3, 2, 1",
+               "addi 3, 3, 1"
+               ]
+        with Program(lst) as program:
+            self.run_tst_program(program, [1, 2, 3])
+
+    def test_addis(self):
+        lst = ["addi 1, 0, 0x0FFF",
+               "addis 1, 1, 0x0F"
+               ]
+        with Program(lst) as program:
+            self.run_tst_program(program, [1])
+
+    def test_mulli(self):
+        lst = ["addi 1, 0, 3",
+               "mulli 1, 1, 2"
+               ]
+        with Program(lst) as program:
+            self.run_tst_program(program, [1])
 
-    def run_test_program(self, prog, reglist):
+    def run_tst_program(self, prog, reglist):
         simulator = InternalOpSimulator()
         self.run_tst(prog, simulator)
         prog.reset()