add first FP "expected state" use it in fmvis
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 26 Jul 2022 15:37:40 +0000 (16:37 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 26 Jul 2022 15:37:40 +0000 (16:37 +0100)
src/openpower/test/alu/fmvis_cases.py
src/openpower/test/state.py

index f3f75530ae32064f97b31b8cc966690c36eaaa92..cca4fb49d2f3dc1c2611bb642a6e1655b28f8625 100644 (file)
@@ -23,5 +23,5 @@ class FMVISTestCase(TestAccumulatorBase):
         expected_fprs[5] = 0x4000000000000000 # 2.0 in FP64 form
         expected_fprs[6] = 0x2122000000000000
         expected_fprs[7] = 0x3FD0000000000000 # 0.25 in FP64 form
-        e = ExpectedState(pc=4) # TODO, add FPRs
-        self.add_case(Program(lst, bigendian, e))
+        e = ExpectedState(pc=4, fp_regs=expected_fprs) # TODO, add FPRs
+        self.add_case(Program(lst, bigendian), expected=e)
index f8eae6485240a0ebfbf8b0f12c0d14ad108de01f..c20e75d3970a4deb327fc06be699529974114c8d 100644 (file)
@@ -73,6 +73,7 @@ class State:
     memory - stored as a dictionary {location: data}
     """
     def get_state(self):
+        yield from self.get_fpregs()
         yield from self.get_intregs()
         yield from self.get_crregs()
         yield from self.get_xregs()
@@ -80,6 +81,17 @@ class State:
         yield from self.get_mem()
 
     def compare(self, s2):
+        # Compare FP registers
+        for i, (fpreg, fpreg2) in enumerate(
+                zip(self.fpregs, s2.fpregs)):
+            log("asserting...reg", i, fpreg, fpreg2)
+            log("code, frepr(code)", self.code, repr(self.code))
+            self.dut.assertEqual(fpreg, fpreg2,
+                "fp reg %d (%s) not equal (%s) %s. "
+                " got %x  expected %x at pc %x %x\n" %
+                (i, self.state_type, s2.state_type, repr(self.code),
+                fpreg, fpreg2, self.pc, s2.pc))
+
         # Compare int registers
         for i, (intreg, intreg2) in enumerate(
                 zip(self.intregs, s2.intregs)):
@@ -175,6 +187,15 @@ class SimState(State):
     def __init__(self, sim):
         self.sim = sim
 
+    def get_fpregs(self):
+        if False:
+            yield
+        self.fpregs = []
+        for i in range(32):
+            simregval = self.sim.fpr[i].asint()
+            self.fpregs.append(simregval)
+        log("class sim fp regs", list(map(hex, self.fpregs)))
+
     def get_intregs(self):
         if False:
             yield
@@ -238,7 +259,12 @@ class ExpectedState(State):
     see openpower/test/shift_rot/shift_rot_cases2.py for examples
     """
     def __init__(self, int_regs=None, pc=0, crregs=None,
-                 so=0, ov=0, ca=0):
+                 so=0, ov=0, ca=0, fp_regs=None):
+        if fp_regs is None:
+            fp_regs = 32
+        if isinstance(fp_regs, int):
+            fp_regs = [0] * fp_regs
+        self.fpregs = deepcopy(fp_regs)
         if int_regs is None:
             int_regs = 32
         if isinstance(int_regs, int):
@@ -254,6 +280,8 @@ class ExpectedState(State):
         self.ov = ov
         self.ca = ca
 
+    def get_fpregs(self):
+        if False: yield
     def get_intregs(self):
         if False: yield
     def get_crregs(self):