From e0abaa00e301ef461c43e894cc171cc2690bfb66 Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Sat, 9 May 2020 11:15:34 -0400 Subject: [PATCH] Fix broken mask when x == y --- src/soc/decoder/helpers.py | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.30.2