From: lkcl Date: Wed, 4 May 2022 16:04:41 +0000 (+0100) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~2477 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18d7ed90f1c8396ec6494f4505c97c7306977ec3;p=libreriscv.git --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 26f60956d..a2da88a75 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -467,6 +467,8 @@ uint64_t grevlut64(uint64_t RA, uint64_t RB, uint8 imm, bool iv) # grev +superceded by grevlut + based on RV bitmanip, this is also known as a butterfly network. however where a butterfly network allows setting of every crossbar setting in every row and every column, generalised-reverse (grev) only allows @@ -497,6 +499,43 @@ uint64_t grev64(uint64_t RA, uint64_t RB) ``` +# gorc + +based on RV bitmanip, gorc is superceded by grevlut + +``` +uint32_t gorc32(uint32_t RA, uint32_t RB) +{ + uint32_t x = RA; + int shamt = RB & 31; + if (shamt & 1) x |= ((x & 0x55555555) << 1) | ((x & 0xAAAAAAAA) >> 1); + if (shamt & 2) x |= ((x & 0x33333333) << 2) | ((x & 0xCCCCCCCC) >> 2); + if (shamt & 4) x |= ((x & 0x0F0F0F0F) << 4) | ((x & 0xF0F0F0F0) >> 4); + if (shamt & 8) x |= ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8); + if (shamt & 16) x |= ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16); + return x; +} +uint64_t gorc64(uint64_t RA, uint64_t RB) +{ + uint64_t x = RA; + int shamt = RB & 63; + if (shamt & 1) x |= ((x & 0x5555555555555555LL) << 1) | + ((x & 0xAAAAAAAAAAAAAAAALL) >> 1); + if (shamt & 2) x |= ((x & 0x3333333333333333LL) << 2) | + ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2); + if (shamt & 4) x |= ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) | + ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4); + if (shamt & 8) x |= ((x & 0x00FF00FF00FF00FFLL) << 8) | + ((x & 0xFF00FF00FF00FF00LL) >> 8); + if (shamt & 16) x |= ((x & 0x0000FFFF0000FFFFLL) << 16) | + ((x & 0xFFFF0000FFFF0000LL) >> 16); + if (shamt & 32) x |= ((x & 0x00000000FFFFFFFFLL) << 32) | + ((x & 0xFFFFFFFF00000000LL) >> 32); + return x; +} + +``` + # xperm based on RV bitmanip. @@ -545,43 +584,6 @@ uint_xlen_t xperm_w (uint_xlen_t RA, uint_xlen_t RB) { return xperm(RA, RB, 5); } ``` -# gorc - -based on RV bitmanip - -``` -uint32_t gorc32(uint32_t RA, uint32_t RB) -{ - uint32_t x = RA; - int shamt = RB & 31; - if (shamt & 1) x |= ((x & 0x55555555) << 1) | ((x & 0xAAAAAAAA) >> 1); - if (shamt & 2) x |= ((x & 0x33333333) << 2) | ((x & 0xCCCCCCCC) >> 2); - if (shamt & 4) x |= ((x & 0x0F0F0F0F) << 4) | ((x & 0xF0F0F0F0) >> 4); - if (shamt & 8) x |= ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8); - if (shamt & 16) x |= ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16); - return x; -} -uint64_t gorc64(uint64_t RA, uint64_t RB) -{ - uint64_t x = RA; - int shamt = RB & 63; - if (shamt & 1) x |= ((x & 0x5555555555555555LL) << 1) | - ((x & 0xAAAAAAAAAAAAAAAALL) >> 1); - if (shamt & 2) x |= ((x & 0x3333333333333333LL) << 2) | - ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2); - if (shamt & 4) x |= ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) | - ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4); - if (shamt & 8) x |= ((x & 0x00FF00FF00FF00FFLL) << 8) | - ((x & 0xFF00FF00FF00FF00LL) >> 8); - if (shamt & 16) x |= ((x & 0x0000FFFF0000FFFFLL) << 16) | - ((x & 0xFFFF0000FFFF0000LL) >> 16); - if (shamt & 32) x |= ((x & 0x00000000FFFFFFFFLL) << 32) | - ((x & 0xFFFFFFFF00000000LL) >> 32); - return x; -} - -``` - # bitmatrix ```