From: lkcl Date: Tue, 19 Jan 2021 13:58:29 +0000 (+0000) Subject: (no commit message) X-Git-Tag: convert-csv-opcode-to-binary~406 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=866988efe0384585a1070ef9a19ccfdf32603aea;p=libreriscv.git --- diff --git a/openpower/sv/remap.mdwn b/openpower/sv/remap.mdwn index 2ac51201c..e821b47ab 100644 --- a/openpower/sv/remap.mdwn +++ b/openpower/sv/remap.mdwn @@ -186,5 +186,31 @@ A 2D REMAP allows: * the columns themselves to be iterated as an outer loop * a 32 bit `GF(256)` multiply on the vec4 to be performed. -This entirely in-place without special 128-bit opcodes. - +This entirely in-place without special 128-bit opcodes. Below is +the pseudocode for [[!wiki Rindael MixColumns]] + +``` +void gmix_column(unsigned char *r) { + unsigned char a[4]; + unsigned char b[4]; + unsigned char c; + unsigned char h; + // none of these need swizzle but they do need SUBVL.Remap + for (c = 0; c < 4; c++) { + a[c] = r[c]; + h = (unsigned char)((signed char)r[c] >> 7); + b[c] = r[c] << 1; + b[c] ^= 0x1B & h; /* Rijndael's Galois field */ + } + // SUBVL.Remap still needed here + // These may each be 32 bit Swizzled + // r0.vec4 = b.vec4 + // r0.vec4 ^= a.vec4.WXYZ + // r0.vec4 ^= a.vec4.ZWXY + // r0.vec4 ^= b.vec4.YZWX ^ a.vec4.YZWX + r[0] = b[0] ^ a[3] ^ a[2] ^ b[1] ^ a[1]; + r[1] = b[1] ^ a[0] ^ a[3] ^ b[2] ^ a[2]; + r[2] = b[2] ^ a[1] ^ a[0] ^ b[3] ^ a[3]; + r[3] = b[3] ^ a[2] ^ a[1] ^ b[0] ^ a[0]; +} +```