From: Michael Nolan Date: Sat, 9 May 2020 15:15:34 +0000 (-0400) Subject: Fix broken mask when x == y X-Git-Tag: div_pipeline~1311 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e0abaa00e301ef461c43e894cc171cc2690bfb66;p=soc.git Fix broken mask when x == y --- diff --git a/src/soc/decoder/helpers.py b/src/soc/decoder/helpers.py index 0efdc439..ef28c7ca 100644 --- a/src/soc/decoder/helpers.py +++ b/src/soc/decoder/helpers.py @@ -53,6 +53,8 @@ def MASK(x, y): y = 63-y mask_a = ((1 << x) - 1) & ((1 << 64) - 1) mask_b = ((1 << y) - 1) & ((1 << 64) - 1) + elif x == y: + return 1 << (63-x) else: x = 64-x y = 63-y @@ -109,6 +111,10 @@ class HelperTests(unittest.TestCase): # slw 1, 1, 2 self.assertHex(MASK(32, 63-5), 0xffffffe0) + self.assertHex(MASK(32, 33), 0xc0000000) + self.assertHex(MASK(32, 32), 0x80000000) + self.assertHex(MASK(33, 33), 0x40000000) + def test_ROTL64(self): # r1 = 0xdeadbeef12345678 value = 0xdeadbeef12345678