sim._pyrtl: py3.12+: convert to int before bitwise negating.
Amaranth bitwise negation `~` compiles to Python bitwise negation `~` in simulation; the same holds for comparison operators such as `==`. Thus an expression such as `~(a == b)` in simulation will compile to Python that takes the bitwise negation of the comparison result, which will be an actual bool. On 3.12, the result is a `DeprecationWarning` emitted only at simulation run-time. When negating in simulation, coerce the value to an int. `mask` is sufficient as we do no further arithmetic here.
This commit is contained in:
parent
63f9976267
commit
4ec9cbbffe
2 changed files with 11 additions and 1 deletions
|
|
@ -138,7 +138,7 @@ class _RHSValueCompiler(_ValueCompiler):
|
|||
if len(value.operands) == 1:
|
||||
arg, = value.operands
|
||||
if value.operator == "~":
|
||||
return f"(~{self(arg)})"
|
||||
return f"(~{mask(arg)})"
|
||||
if value.operator == "-":
|
||||
return f"(-{sign(arg)})"
|
||||
if value.operator == "b":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue