From 42265144c9da1beb57c30c15bcb1e982915a4e51 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Mon, 9 Oct 2023 18:19:25 -0700 Subject: [PATCH] start adding DivModKnuthAlgorithmD class --- src/openpower/test/bigint/powmod.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/openpower/test/bigint/powmod.py b/src/openpower/test/bigint/powmod.py index 433a6b18..38ffeb45 100644 --- a/src/openpower/test/bigint/powmod.py +++ b/src/openpower/test/bigint/powmod.py @@ -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 -- 2.30.2