-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nMigen thinks -5 / 2 = 3 #621
Comments
It took me a minute or two to work out what is going on here: the same nMigen code evaluates differently in the nmigen simulator than it does in Verilator. |
Yes. It's an issue with the emitted Verilog code, I believe; so not specific to Verilator. |
Obviously up to you @whitequark what is canonical nMigen behavior. module arithmetic_operators();
initial begin
$display (" -5 / 2 = %d", -5/2);
#10 $finish;
end
endmodule
|
negative integer division behavior in Python strikes me as less common |
Consider the three snippets: |
OK you got me. Probably not worth fighting Python itself about this. |
Thanks for the report! This is now fixed by using the upstream Yosys support for flooring division and modulo operators, added in YosysHQ/yosys#1885. As a result, Yosys >=0.10 is now required. |
nMigen thinks
-5 / 2 = 3
, but verilator disagrees.I suspect this is because
-5 // 2
evaluates to -3 in Python.Commands
FIles
div.py
sim_main.cpp
The text was updated successfully, but these errors were encountered: