From: lkcl Date: Tue, 15 Mar 2022 21:28:08 +0000 (+0000) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~3052 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4794bd731d407a9c7a39ce7938c507dd6d2514a;p=libreriscv.git --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 3774322ed..f319d5147 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -270,6 +270,20 @@ Immediate-variant is an overwrite form: | NN | RS | RB | sh | SH | itype | 1000 110 |Rc| bm*i | ``` +def MASK(x, y): + if x < y: + x = x+1 + mask_a = ((1 << x) - 1) & ((1 << 64) - 1) + mask_b = ((1 << y) - 1) & ((1 << 64) - 1) + elif x == y: + return 1 << x + else: + x = x+1 + mask_a = ((1 << x) - 1) & ((1 << 64) - 1) + mask_b = (~((1 << y) - 1)) & ((1 << 64) - 1) + return mask_a ^ mask_b + + uint_xlen_t bmset(RS, RB, sh) { int shamt = RB & (XLEN - 1);