add first simulator mul test
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 6 Jul 2020 18:56:33 +0000 (19:56 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 6 Jul 2020 18:56:33 +0000 (19:56 +0100)
src/soc/simulator/test_mul_sim.py [new file with mode: 0644]
src/soc/simulator/test_sim.py

diff --git a/src/soc/simulator/test_mul_sim.py b/src/soc/simulator/test_mul_sim.py
new file mode 100644 (file)
index 0000000..9291207
--- /dev/null
@@ -0,0 +1,46 @@
+from nmigen import Module, Signal
+from nmigen.back.pysim import Simulator, Delay, Settle
+from nmigen.test.utils import FHDLTestCase
+import unittest
+from soc.decoder.power_decoder import (create_pdecode)
+from soc.decoder.power_enums import (Function, InternalOp,
+                                     In1Sel, In2Sel, In3Sel,
+                                     OutSel, RC, LdstLen, CryIn,
+                                     single_bit_flags, Form, SPR,
+                                     get_signal_name, get_csv)
+from soc.decoder.power_decoder2 import (PowerDecode2)
+from soc.simulator.program import Program
+from soc.simulator.qemu import run_program
+from soc.decoder.isa.all import ISA
+from soc.fu.test.common import TestCase
+from soc.simulator.test_sim import DecoderBase
+
+
+
+class MulTestCases(FHDLTestCase):
+    test_data = []
+
+    def __init__(self, name="div"):
+        super().__init__(name)
+        self.test_name = name
+
+    def test_mullw(self):
+        lst = [f"addi 1, 0, 0x5678",
+               f"addi 2, 0, 0x1234",
+               f"mullw 3, 1, 2"]
+        self.run_tst_program(Program(lst), [3])
+
+    def run_tst_program(self, prog, initial_regs=None, initial_sprs=None,
+                                    initial_mem=None):
+        initial_regs = [0] * 32
+        tc = TestCase(prog, self.test_name, initial_regs, initial_sprs, 0,
+                                            initial_mem, 0)
+        self.test_data.append(tc)
+
+
+class MulDecoderTestCase(DecoderBase, MulTestCases):
+    pass
+
+
+if __name__ == "__main__":
+    unittest.main()
index a619ba1bd39c533bebfad9b6d7512db5a2be8b3c..f6a52fc9491a1ee6a17560f61ce2d6b17dd0c4d3 100644 (file)
@@ -255,7 +255,7 @@ class DecoderBase:
         prog.reset()
         with run_program(prog, initial_mem) as q:
             self.qemu_register_compare(simulator, q, reglist)
-            self.qemu_mem_compare(simulator, q, reglist)
+            self.qemu_mem_compare(simulator, q, True)
         print(simulator.gpr.dump())
 
     def qemu_mem_compare(self, sim, qemu, check=True):