From 0324e31625e68283847bc7d599060e1e3c31a7ff Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 17 Mar 2022 21:56:18 -0700 Subject: [PATCH] delete redundant sections --- openpower/sv/bitmanip.mdwn | 106 ------------------------------------- 1 file changed, 106 deletions(-) diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 44d99c99d..e8ceb8b7f 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -826,112 +826,6 @@ term = (RC) (RS) = gfpmsubr(factor1, factor2, term) ``` -## Twin Butterfly (Tukey-Cooley) Mul-add-sub - -used in combination with SV FFT REMAP to perform -a full NTT in-place. possible by having 3-in 2-out, -to avoid the need for a temp register. RS is written -to as well as RT. - - gffmadd RT,RA,RC,RB (Rc=0) - gffmadd. RT,RA,RC,RB (Rc=1) - -Pseudo-code: - - RT <- GFADD(GFMUL(RA, RC), RB)) - RS <- GFADD(GFMUL(RA, RC), RB)) - - -## Multiply - -with the modulo and degree being in an SPR, multiply can be identical -equivalent to standard integer add - - RS = GFMUL(RA, RB) - -| 0.5|6.10|11.15|16.20|21.25| 26..30 |31| -| -- | -- | --- | --- | --- | ------ |--| -| NN | RT | RA | RB |11000| 01110 |Rc| - - - -``` -from functools import reduce - -def gf_degree(a) : - res = 0 - a >>= 1 - while (a != 0) : - a >>= 1; - res += 1; - return res - -# constants used in the multGF2 function -mask1 = mask2 = polyred = None - -def setGF2(irPoly): - """Define parameters of binary finite field GF(2^m)/g(x) - - irPoly: coefficients of irreducible polynomial g(x) - """ - # degree: extension degree of binary field - degree = gf_degree(irPoly) - - def i2P(sInt): - """Convert an integer into a polynomial""" - return [(sInt >> i) & 1 - for i in reversed(range(sInt.bit_length()))] - - global mask1, mask2, polyred - mask1 = mask2 = 1 << degree - mask2 -= 1 - polyred = reduce(lambda x, y: (x << 1) + y, i2P(irPoly)[1:]) - -def multGF2(p1, p2): - """Multiply two polynomials in GF(2^m)/g(x)""" - p = 0 - while p2: - # standard long-multiplication: check LSB and add - if p2 & 1: - p ^= p1 - p1 <<= 1 - # standard modulo: check MSB and add polynomial - if p1 & mask1: - p1 ^= polyred - p2 >>= 1 - return p & mask2 - -if __name__ == "__main__": - - # Define binary field GF(2^3)/x^3 + x + 1 - setGF2(0b1011) # degree 3 - - # Evaluate the product (x^2 + x + 1)(x^2 + 1) - print("{:02x}".format(multGF2(0b111, 0b101))) - - # Define binary field GF(2^8)/x^8 + x^4 + x^3 + x + 1 - # (used in the Advanced Encryption Standard-AES) - setGF2(0b100011011) # degree 8 - - # Evaluate the product (x^7)(x^7 + x + 1) - print("{:02x}".format(multGF2(0b10000000, 0b10000011))) -``` - -## carryless Twin Butterfly (Tukey-Cooley) Mul-add-sub - -used in combination with SV FFT REMAP to perform -a full NTT in-place. possible by having 3-in 2-out, -to avoid the need for a temp register. RS is written -to as well as RT. - - clfmadd RT,RA,RC,RB (Rc=0) - clfmadd. RT,RA,RC,RB (Rc=1) - -Pseudo-code: - - RT <- CLMUL(RA, RC) ^ RB - RS <- CLMUL(RA, RC) ^ RB - - # bitmatrix ``` -- 2.30.2