From f6856526c4ce5a156b61095931c839de9318a3f3 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 2 Dec 2019 18:52:55 +0000 Subject: [PATCH] back.pysim: fix miscompilation of Signal(unsigned) - Signal(signed). --- nmigen/back/pysim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 == "//": -- 2.30.2