X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Fdiv%2Fexperiment%2Fgoldschmidt_div_sqrt.py;h=c3837e9afc2f661ffc864d088d3ead1a3b0cd2ab;hb=ed18e275f2b8f3fe2b4151c46e92e1ec3e76372f;hp=e17f64c7280c1a30f9ba0c400e8fbbcd2888a202;hpb=b5d416df741e016d096d412ef2d310f3d21595ea;p=soc.git 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.