From: whitequark Date: Mon, 2 Dec 2019 18:52:55 +0000 (+0000) Subject: back.pysim: fix miscompilation of Signal(unsigned) - Signal(signed). X-Git-Tag: v0.2~45 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76504319962524b02c7d21111295b655e009bd76;p=nmigen.git back.pysim: fix miscompilation of Signal(unsigned) - Signal(signed). --- diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 6f905ff..b0449fe 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -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 == "//":