projects
/
nmigen.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
834fe3c
)
back.rtlil: extend shorter operand of a binop when matching sign.
author
whitequark
<whitequark@whitequark.org>
Mon, 18 Nov 2019 10:39:55 +0000
(10:39 +0000)
committer
whitequark
<whitequark@whitequark.org>
Mon, 18 Nov 2019 10:39:55 +0000
(10:39 +0000)
This is necessary because converting a large unsigned value to
a signed value of the same width may change its sign.
Fixes #271.
nmigen/back/rtlil.py
patch
|
blob
|
history
diff --git
a/nmigen/back/rtlil.py
b/nmigen/back/rtlil.py
index 5cd9f97fc914686db2d9d8ac54552d8ba84e808a..7806ace3ed47cc195fed8936149c452c50679075 100644
(file)
--- a/
nmigen/back/rtlil.py
+++ b/
nmigen/back/rtlil.py
@@
-490,6
+490,7
@@
class _RHSValueCompiler(_ValueCompiler):
rhs_wire = self(rhs)
else:
lhs_sign = rhs_sign = True
+ lhs_bits = rhs_bits = max(lhs_bits, rhs_bits)
lhs_wire = self.match_shape(lhs, lhs_bits, lhs_sign)
rhs_wire = self.match_shape(rhs, rhs_bits, rhs_sign)
res_bits, res_sign = value.shape()