start adding DivModKnuthAlgorithmD class
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 10 Oct 2023 01:19:25 +0000 (18:19 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 7 Dec 2023 17:51:21 +0000 (17:51 +0000)
src/openpower/test/bigint/powmod.py

index 433a6b18963b088ac12dacc29c5860892d07a815..38ffeb45a437bf22939560855eeed3eab61587e1 100644 (file)
@@ -19,6 +19,7 @@ from openpower.test.state import ExpectedState
 from openpower.test.util import assemble
 from nmutil.sim_util import hash_256
 from openpower.util import log
+from nmutil.plain_data import plain_data
 
 
 MUL_256_X_256_TO_512_ASM = (
@@ -267,6 +268,20 @@ def python_divmod_shift_sub_algorithm(n, d, width=256, log_regex=False):
     return q, r
 
 
+@plain_data()
+class DivModKnuthAlgorithmD:
+    __slots__ = "n_size", "d_size", "word_size",
+
+    def __init__(self, n_size=8, d_size=4, word_size=64):
+        assert n_size >= d_size, \
+            "the dividend's length must be >= the divisor's length"
+        assert word_size > 0
+
+        self.n_size = n_size
+        self.d_size = d_size
+        self.word_size = word_size
+
+
 def python_divmod_knuth_algorithm_d(n, d, word_size=64, log_regex=False,
                                     on_corner_case=lambda desc: None):
     do_log = _DivModRegsRegexLogger(enabled=log_regex).log