From d82196e5b61827456d69e94319f57f406b24878f Mon Sep 17 00:00:00 2001 From: lkcl Date: Fri, 25 Dec 2020 22:25:41 +0000 Subject: [PATCH] --- openpower/sv/bitmanip.mdwn | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 4b75b5d05..947c856a2 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -111,3 +111,20 @@ based on RV bitmanip uint_xlen_t cmix(uint_xlen_t rs1, uint_xlen_t rs2, uint_xlen_t rs3) { return (rs1 & rs2) | (rs3 & ~rs2); } ``` + +# carryless mul + +``` +uint_xlen_t clmul(uint_xlen_t rs1, uint_xlen_t rs2) { uint_xlen_t x = 0; +} +for (int i = 0; i < XLEN; i++) if ((rs2 >> i) & 1) +x ^= rs1 << i; return x; +uint_xlen_t clmulh(uint_xlen_t rs1, uint_xlen_t rs2) { uint_xlen_t x = 0; +} +for (int i = 1; i < XLEN; i++) if ((rs2 >> i) & 1) +x ^= rs1 >> (XLEN-i); return x; +uint_xlen_t clmulr(uint_xlen_t rs1, uint_xlen_t rs2) { uint_xlen_t x = 0; +} +for (int i = 0; i < XLEN; i++) if ((rs2 >> i) & 1) +x ^= rs1 >> (XLEN-i-1); return x; +``` -- 2.30.2