From d4794bd731d407a9c7a39ce7938c507dd6d2514a Mon Sep 17 00:00:00 2001 From: lkcl Date: Tue, 15 Mar 2022 21:28:08 +0000 Subject: [PATCH] --- openpower/sv/bitmanip.mdwn | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); -- 2.30.2