```
-# carryless mul
-
-based on RV bitmanip
-see https://en.wikipedia.org/wiki/CLMUL_instruction_set
-
-```
-uint_xlen_t clmul(uint_xlen_t RA, uint_xlen_t RB)
-{
- uint_xlen_t x = 0;
- for (int i = 0; i < XLEN; i++)
- if ((RB >> i) & 1)
- x ^= RA << i;
- return x;
-}
-uint_xlen_t clmulh(uint_xlen_t RA, uint_xlen_t RB)
-{
- uint_xlen_t x = 0;
- for (int i = 1; i < XLEN; i++)
- if ((RB >> i) & 1)
- x ^= RA >> (XLEN-i);
- return x;
-}
-uint_xlen_t clmulr(uint_xlen_t RA, uint_xlen_t RB)
-{
- uint_xlen_t x = 0;
- for (int i = 0; i < XLEN; i++)
- if ((RB >> i) & 1)
- x ^= RA >> (XLEN-i-1);
- return x;
-}
-```
# Galois Field
see <https://courses.csail.mit.edu/6.857/2016/files/ffield.py>
return g1
```
+## carryless mul
+
+based on RV bitmanip
+see https://en.wikipedia.org/wiki/CLMUL_instruction_set
+
+these are GF2 operations with the modulo set to 2^degree.
+they are worth adding as their own non-overwrite operations
+(in the same pipeline).
+
+```
+uint_xlen_t clmul(uint_xlen_t RA, uint_xlen_t RB)
+{
+ uint_xlen_t x = 0;
+ for (int i = 0; i < XLEN; i++)
+ if ((RB >> i) & 1)
+ x ^= RA << i;
+ return x;
+}
+uint_xlen_t clmulh(uint_xlen_t RA, uint_xlen_t RB)
+{
+ uint_xlen_t x = 0;
+ for (int i = 1; i < XLEN; i++)
+ if ((RB >> i) & 1)
+ x ^= RA >> (XLEN-i);
+ return x;
+}
+uint_xlen_t clmulr(uint_xlen_t RA, uint_xlen_t RB)
+{
+ uint_xlen_t x = 0;
+ for (int i = 0; i < XLEN; i++)
+ if ((RB >> i) & 1)
+ x ^= RA >> (XLEN-i-1);
+ return x;
+}
+```
+
# bitmatrix
```