back.pysim: fix miscompilation of Signal(unsigned) - Signal(signed).
authorwhitequark <whitequark@whitequark.org>
Mon, 2 Dec 2019 18:52:55 +0000 (18:52 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 2 Dec 2019 18:52:55 +0000 (18:52 +0000)
nmigen/back/pysim.py

index 6f905ffa71ba09357b2b24b84b7557c08ebc911a..b0449fe6f372a7e1556f5dd1e8a039ad9c22cd44 100644 (file)
@@ -424,9 +424,9 @@ class _RHSValueCompiler(_ValueCompiler):
             lhs_mask = (1 << len(lhs)) - 1
             rhs_mask = (1 << len(rhs)) - 1
             if value.operator == "+":
-                return f"({mask(lhs)} + {mask(rhs)})"
+                return f"({sign(lhs)} + {sign(rhs)})"
             if value.operator == "-":
-                return f"({mask(lhs)} - {mask(rhs)})"
+                return f"({sign(lhs)} - {sign(rhs)})"
             if value.operator == "*":
                 return f"({sign(lhs)} * {sign(rhs)})"
             if value.operator == "//":