projects
/
soc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e62b475
)
Fix broken mask when x == y
author
Michael Nolan
<mtnolan2640@gmail.com>
Sat, 9 May 2020 15:15:34 +0000
(11:15 -0400)
committer
Michael Nolan
<mtnolan2640@gmail.com>
Sat, 9 May 2020 15:15:34 +0000
(11:15 -0400)
src/soc/decoder/helpers.py
patch
|
blob
|
history
diff --git
a/src/soc/decoder/helpers.py
b/src/soc/decoder/helpers.py
index 0efdc439600fab381eb1c3902dfca2d54a4cb251..ef28c7ca7ef77a4386c91302401c0a2e6682ca22 100644
(file)
--- 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