(no commit message)
authorlkcl <lkcl@web>
Tue, 19 Apr 2022 17:37:41 +0000 (18:37 +0100)
committerIkiWiki <ikiwiki.info>
Tue, 19 Apr 2022 17:37:41 +0000 (18:37 +0100)
openpower/sv/biginteger/appendix.mdwn

index 9d21e29593dd2e20d84f83616ff4e93ab0e79532..586d5f3c015ef116314d8246134f83c9732b1392 100644 (file)
@@ -6,6 +6,8 @@ links
 * <https://lists.libre-soc.org/pipermail/libre-soc-dev/2022-April/004700.html>
 * <https://news.ycombinator.com/item?id=21151646>
 
+## Variant 1
+
 Row-based multiply using temporary vector. Simple implementation
 of Knuth M: <https://git.libre-soc.org/?p=libreriscv.git;a=blob;f=openpower/sv/bitmanip/mulmnu.c;hb=HEAD>
 
@@ -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