(no commit message)
authorlkcl <lkcl@web>
Mon, 18 Apr 2022 21:06:05 +0000 (22:06 +0100)
committerIkiWiki <ikiwiki.info>
Mon, 18 Apr 2022 21:06:05 +0000 (22:06 +0100)
openpower/sv/bitmanip/appendix.mdwn

index dc1f64c690a3a09f2fd3e202cf851a91289762c6..643d4e94f364e4a4fa0bf33d253245ad8cc8956d 100644 (file)
@@ -6,7 +6,21 @@ links
 * <https://lists.libre-soc.org/pipermail/libre-soc-dev/2022-April/004700.html>
 * <https://news.ycombinator.com/item?id=21151646>
 
-Row-based multiply using temporary vector
+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>
+
+```
+      for (i = 0; i < m; i++) {
+         unsigned product = u[i]*v[j] + w[i + j];
+         phi[i] = product>>16;
+         plo[i] = product;
+      }
+      for (i = 0; i < m; i++) {
+         t = (phi[i]<<16) | plo[i] + k;
+         w[i + j] = t;          // (I.e., t & 0xFFFF).
+         k = t >> 16;
+      }
+```
 
 # big integer division