From: lkcl Date: Tue, 19 Apr 2022 17:37:41 +0000 (+0100) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~2690 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e518ba5e301402195f943d4ab6e6da367294d532;p=libreriscv.git --- diff --git a/openpower/sv/biginteger/appendix.mdwn b/openpower/sv/biginteger/appendix.mdwn index 9d21e2959..586d5f3c0 100644 --- a/openpower/sv/biginteger/appendix.mdwn +++ b/openpower/sv/biginteger/appendix.mdwn @@ -6,6 +6,8 @@ links * * +## Variant 1 + Row-based multiply using temporary vector. Simple implementation of Knuth M: @@ -48,6 +50,29 @@ These two combine as, simply: # here, RS=RB+VL, therefore again RS starts at r8.v sv.addxd r0.v, r18, r0.v +## Variant 2 + +``` + for (i = 0; i < m; i++) { + unsigned product = u[i]*v[j] + k; + k = product>>16; + plo[i] = product; // & 0xffff + } + k = 0; + for (i = 0; i < m; i++) { + t = plo[i] + w[i + j] + k; + w[i + j] = t; // (I.e., t & 0xFFFF). + k = t >> 16; // carry: should only be 1 bit + } +``` + +**maddx RT, RA, RB, RC** + + prod[0:127] = (RA) * (RB) + sum[0:127] = EXTZ(RC) + prod + RT <- sum[64:127] + RC <- sum[0:63] + # big integer division links