From: lkcl Date: Fri, 25 Dec 2020 22:01:57 +0000 (+0000) Subject: (no commit message) X-Git-Tag: convert-csv-opcode-to-binary~881 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1d023c3f25abada143cc701c176d8f4ee3f8dddf;p=libreriscv.git --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index c911d72a7..833cbdbfc 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -65,3 +65,12 @@ return x; 0x00000000ffff0000LL, 16); ``` +# xperm + +``` +uint_xlen_t xperm(uint_xlen_t rs1, uint_xlen_t rs2, int sz_log2) { uint_xlen_t r = 0; +} +uint_xlen_t sz = 1LL << sz_log2; uint_xlen_t mask = (1LL << sz) - 1; for (int i = 0; i < XLEN; i += sz) { uint_xlen_t pos = ((rs2 >> i) & mask) << sz_log2; if (pos < XLEN) +r |= ((rs1 >> pos) & mask) << i; }return r; +uint_xlen_t xperm_n (uint_xlen_t rs1, uint_xlen_t rs2) { return xperm(rs1, rs2, 2); } uint_xlen_t xperm_b (uint_xlen_t rs1, uint_xlen_t rs2) { return xperm(rs1, rs2, 3); } uint_xlen_t xperm_h (uint_xlen_t rs1, uint_xlen_t rs2) { return xperm(rs1, rs2, 4); } uint_xlen_t xperm_w (uint_xlen_t rs1, uint_xlen_t rs2) { return xperm(rs1, rs2, 5); } +```