Skip to content
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

back.pysim: Implement modulus operator #333

Merged
merged 2 commits into from Mar 15, 2020

Conversation

sjolsen
Copy link
Contributor

@sjolsen sjolsen commented Mar 15, 2020

It looks to me like the rtlil backend produces zero when the right-hand side of the modulus operation is zero, so that's what I did here.

@codecov
Copy link

codecov bot commented Mar 15, 2020

Codecov Report

Merging #333 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #333      +/-   ##
==========================================
+ Coverage   82.47%   82.54%   +0.06%     
==========================================
  Files          35       35              
  Lines        5913     5924      +11     
  Branches     1198     1199       +1     
==========================================
+ Hits         4877     4890      +13     
+ Misses        876      875       -1     
+ Partials      160      159       -1
Impacted Files Coverage Δ
nmigen/back/pysim.py 91.09% <100%> (+0.02%) ⬆️
nmigen/back/rtlil.py 82.95% <0%> (+0.32%) ⬆️
nmigen/lib/fifo.py 92.77% <0%> (+0.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12c7902...51c93bb. Read the comment docs.

@whitequark
Copy link
Member

Thanks for the PR! Could you add a test?

@sjolsen
Copy link
Contributor Author

sjolsen commented Mar 15, 2020

I copied the division test, replaced the division results with what the modulus results should be, and added a case for 2 % 0 = 0. The test passes if I run it with python -m unittest nmigen.test.test_sim.

@whitequark whitequark merged commit 7b9c8b4 into amaranth-lang:master Mar 15, 2020
@whitequark
Copy link
Member

Thanks!

@sjolsen sjolsen deleted the pysim-mod branch March 15, 2020 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants