From ed18e275f2b8f3fe2b4151c46e92e1ec3e76372f Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 27 Apr 2022 22:52:41 -0700 Subject: [PATCH] move GoldschmidtDivState --- .../fu/div/experiment/goldschmidt_div_sqrt.py | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/soc/fu/div/experiment/goldschmidt_div_sqrt.py b/src/soc/fu/div/experiment/goldschmidt_div_sqrt.py index e17f64c7..c3837e9a 100644 --- a/src/soc/fu/div/experiment/goldschmidt_div_sqrt.py +++ b/src/soc/fu/div/experiment/goldschmidt_div_sqrt.py @@ -315,35 +315,6 @@ class FixedPoint: return retval -@dataclass -class GoldschmidtDivState: - orig_n: int - """original numerator""" - - orig_d: int - """original denominator""" - - n: FixedPoint - """numerator -- N_prime[i] in the paper's algorithm 2""" - - d: FixedPoint - """denominator -- D_prime[i] in the paper's algorithm 2""" - - f: "FixedPoint | None" = None - """current factor -- F_prime[i] in the paper's algorithm 2""" - - quotient: "int | None" = None - """final quotient""" - - remainder: "int | None" = None - """final remainder""" - - n_shift: "int | None" = None - """amount the numerator needs to be left-shifted at the end of the - algorithm. - """ - - class ParamsNotAccurateEnough(Exception): """raised when the parameters aren't accurate enough to have goldschmidt division work.""" @@ -1005,6 +976,35 @@ class GoldschmidtDivOp(enum.Enum): assert False, f"unimplemented GoldschmidtDivOp: {self}" +@dataclass +class GoldschmidtDivState: + orig_n: int + """original numerator""" + + orig_d: int + """original denominator""" + + n: FixedPoint + """numerator -- N_prime[i] in the paper's algorithm 2""" + + d: FixedPoint + """denominator -- D_prime[i] in the paper's algorithm 2""" + + f: "FixedPoint | None" = None + """current factor -- F_prime[i] in the paper's algorithm 2""" + + quotient: "int | None" = None + """final quotient""" + + remainder: "int | None" = None + """final remainder""" + + n_shift: "int | None" = None + """amount the numerator needs to be left-shifted at the end of the + algorithm. + """ + + def goldschmidt_div(n, d, params): """ Goldschmidt division algorithm. -- 2.30.2