From: Luke Kenneth Casson Leighton Date: Fri, 10 Jul 2020 19:49:49 +0000 (+0100) Subject: rename trunc_div/rem to trunc_divs X-Git-Tag: 24jan2021_ls180~39 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=085d1b2cfb6f8dd68b3313952a09e325f272d142;p=nmutil.git rename trunc_div/rem to trunc_divs --- diff --git a/src/nmutil/divmod.py b/src/nmutil/divmod.py index 488e225..99e6847 100644 --- a/src/nmutil/divmod.py +++ b/src/nmutil/divmod.py @@ -1,21 +1,21 @@ -# this is a POWER ISA 3.0B compatible div function +# this is a POWER ISA 3.0B compatible *signed* div function # however it is also the c, c++, rust, java *and* x86 way of doing things -def trunc_div(n, d): +def trunc_divs(n, d): abs_n = abs(n) abs_d = abs(d) abs_q = abs_n // abs_d - #print ("trunc_div", n.value, d.value, - # abs_n.value, abs_d.value, abs_q.value, - # n == abs_n, d == abs_d) + print ("trunc_div", n.value, d.value, + abs_n.value, abs_d.value, abs_q.value, + n == abs_n, d == abs_d) if (n == abs_n) == (d == abs_d): return abs_q return -abs_q -# this is a POWER ISA 3.0B compatible mod / remainder function +# this is a POWER ISA 3.0B compatible *signed* mod / remainder function # however it is also the c, c++, rust, java *and* x86 way of doing things -def trunc_rem(n, d): - m = d * trunc_div(n, d) +def trunc_rems(n, d): + m = d * trunc_divs(n, d) m.bits = n.bits # cheat - really shouldn't do this. mul returns full length return n - m