From: Luke Kenneth Casson Leighton Date: Wed, 22 Jun 2022 14:57:52 +0000 (+0100) Subject: add mask mode to bmask.py X-Git-Tag: opf_rfc_ls005_v1~1596 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76a532dfc0e0b702e0bb12cf260333e4bd9e37b3;p=libreriscv.git add mask mode to bmask.py --- diff --git a/openpower/sv/bmask.py b/openpower/sv/bmask.py index d190f06f4..9930d0a37 100644 --- a/openpower/sv/bmask.py +++ b/openpower/sv/bmask.py @@ -1,17 +1,16 @@ def bmask(mode, RA, RB=None, zero=False): - RT = RA if RB is not None and not zero else 0 mask = RB if RB is not None else 0xffffffffffffffff - RA = RA & mask - a1 = RA if mode&1 else ~RA + ra = RA & mask + a1 = ra if mode&1 else ~ra mode2 = (mode >> 1) & 0b11 if mode2 == 0: - a2 = -RA + a2 = -ra if mode2 == 1: - a2 = RA-1 + a2 = ra-1 if mode2 == 2: - a2 = RA+1 + a2 = ra+1 if mode2 == 3: - a2 = ~(RA+1) + a2 = ~(ra+1) a1 = a1 & mask a2 = a2 & mask mode3 = (mode >> 3) & 0b11 @@ -21,9 +20,11 @@ def bmask(mode, RA, RB=None, zero=False): RT = a1 & a2 if mode3 == 2: RT = a1 ^ a2 - return RT & mask - -SBF = 0b01010 -SOF = 0b01001 -SIF = 0b10000 # 10011 also works no idea why yet + RT &= mask + if not zero: + RT |= RA & ~mask + return RT +SBF = 0b01010 # set before first +SOF = 0b01001 # set only first +SIF = 0b10000 # set including first 10011 also works no idea why yet