projects
/
soc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1214dfe
)
add MULS (signed) version of multiply
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 6 Jul 2020 19:19:58 +0000
(20:19 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 6 Jul 2020 19:19:58 +0000
(20:19 +0100)
src/soc/decoder/helpers.py
patch
|
blob
|
history
diff --git
a/src/soc/decoder/helpers.py
b/src/soc/decoder/helpers.py
index 53edaca2cc6927bdd8e103069054788dba8ec69d..8cab8d50176856c733567a2522d553f44e1aef52 100644
(file)
--- a/
src/soc/decoder/helpers.py
+++ b/
src/soc/decoder/helpers.py
@@
-27,6
+27,17
@@
def EXTS64(value):
return SelectableInt(exts(value.value, value.bits) & ((1 << 64)-1), 64)
+# signed version of MUL
+def MULS(a, b):
+ a_s = a.value & (1<<(a.bits-1)) != 0
+ b_s = b.value & (1<<(b.bits-1)) != 0
+ result = abs(a) * abs(b)
+ print ("MULS", result, a_s, b_s)
+ if a_s == b_s:
+ return result
+ return -result
+
+
# XXX should this explicitly extend from 32 to 64?
def EXTZ64(value):
if isinstance(value, SelectableInt):