fix div tests
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 7 Oct 2020 04:01:15 +0000 (21:01 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Wed, 7 Oct 2020 04:01:15 +0000 (21:01 -0700)
src/soc/decoder/helpers.py
src/soc/decoder/pseudo/pywriter.py
src/soc/fu/div/test/test_pipe_caller.py

index a50d009263a839271a136ceacc3995ff44d85b63..41ab2c789c337c8075a01985adcc1ffb6ce2fdba 100644 (file)
@@ -36,6 +36,13 @@ def EXTS64(value):
     return SelectableInt(exts(value.value, value.bits) & ((1 << 64)-1), 64)
 
 
+def EXTS128(value):
+    """ extends sign bit out from current MSB to 128 bits
+    """
+    assert isinstance(value, SelectableInt)
+    return SelectableInt(exts(value.value, value.bits) & ((1 << 128)-1), 128)
+
+
 # signed version of MUL
 def MULS(a, b):
     if isinstance(b, int):
index 56a1a2e653ea89903de6bd7e1b993ad6213db59a..6cf005f059042ccf9581667b0cad746e5c5dd167 100644 (file)
@@ -22,7 +22,8 @@ header = """\
 from soc.decoder.isa.caller import inject, instruction_info
 from soc.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32, MASK,
                                  ne, eq, gt, ge, lt, le, ltu, gtu, length,
-                                 trunc_divs, trunc_rems, MULS, DIVS, MODS)
+                                 trunc_divs, trunc_rems, MULS, DIVS, MODS,
+                                 EXTS128)
 from soc.decoder.selectable_int import SelectableInt
 from soc.decoder.selectable_int import selectconcat as concat
 from soc.decoder.orderedset import OrderedSet
index db572332991268a624891aa53f8355110d87478f..c636a068ddc079b786e425f1480cedeed27b2fdc 100644 (file)
@@ -11,6 +11,38 @@ from soc.fu.div.test.helper import (log_rand, get_cu_inputs,
 
 
 class DivTestCases(TestAccumulatorBase):
+    def case_divdeu_regression(self):
+        lst = ["divdeu 3, 1, 2"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x1
+        initial_regs[2] = 0x2
+        with Program(lst, bigendian) as prog:
+            self.add_case(prog, initial_regs)
+
+    def case_divde_regression3(self):
+        lst = ["divde 3, 1, 2"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x8000000000000000
+        initial_regs[2] = 0xFFFFFFFFFFFFFFFF
+        with Program(lst, bigendian) as prog:
+            self.add_case(prog, initial_regs)
+
+    def case_divwe_regression2(self):
+        lst = ["divwe 3, 1, 2"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x80000000
+        initial_regs[2] = 0xFFFFFFFF
+        with Program(lst, bigendian) as prog:
+            self.add_case(prog, initial_regs)
+
+    def case_divde_regression2(self):
+        lst = ["divde 3, 1, 2"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x1
+        initial_regs[2] = 0xfffffffffffffffe
+        with Program(lst, bigendian) as prog:
+            self.add_case(prog, initial_regs)
+
     def case_divde_regression(self):
         lst = ["divde 3, 1, 2"]
         initial_regs = [0] * 32