From: lkcl Date: Sun, 10 Jan 2021 01:16:43 +0000 (+0000) Subject: (no commit message) X-Git-Tag: convert-csv-opcode-to-binary~496 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44bec8dfc4112ff102f54d6bf1c67497ddc5bdd4;p=libreriscv.git --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 86acf073d..ebee70ac9 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -9,7 +9,7 @@ # vector bit deposit -vpdepd VRT,VRA,VRB +vpdepd VRT,VRA,VRB, identical to RV bitmamip bdep do while(m < 64) if VSR[VRB+32].dword[i].bit[63-m]=1 then do @@ -18,10 +18,39 @@ vpdepd VRT,VRA,VRB k = k + 1 m = m + 1 +``` + +uint_xlen_t bdep(uint_xlen_t RA, uint_xlen_t RB) +{ + uint_xlen_t r = 0; + for (int i = 0, j = 0; i < XLEN; i++) + if ((RB >> i) & 1) { + if ((RA >> j) & 1) + r |= uint_xlen_t(1) << i; + j++; + } + return r; +} + +``` + # vector bit extract -other way round +other way round: identical to RV bext +``` +uint_xlen_t bext(uint_xlen_t RA, uint_xlen_t RB) +{ + uint_xlen_t r = 0; + for (int i = 0, j = 0; i < XLEN; i++) + if ((RB >> i) & 1) { + if ((RA >> i) & 1) + r |= uint_xlen_t(1) << j; + j++; + } + return r; +} +``` # ternary bitops for every bit perform a lookup into a table using an 8bit immediate @@ -260,36 +289,6 @@ uint_xlen_t cmix(uint_xlen_t RA, uint_xlen_t RB, uint_xlen_t RC) { } ``` -# bdep, bext - -based on RV bitmanip - -``` -uint_xlen_t bext(uint_xlen_t RA, uint_xlen_t RB) -{ - uint_xlen_t r = 0; - for (int i = 0, j = 0; i < XLEN; i++) - if ((RB >> i) & 1) { - if ((RA >> i) & 1) - r |= uint_xlen_t(1) << j; - j++; - } - return r; -} -uint_xlen_t bdep(uint_xlen_t RA, uint_xlen_t RB) -{ - uint_xlen_t r = 0; - for (int i = 0, j = 0; i < XLEN; i++) - if ((RB >> i) & 1) { - if ((RA >> j) & 1) - r |= uint_xlen_t(1) << i; - j++; - } - return r; -} - -``` - # carryless mul based on RV bitmanip