-
Notifications
You must be signed in to change notification settings - Fork 603
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
Update reported width from div/rem to match FIRRTL results #1748
Conversation
@albert-magyar Thanks, and I agree your proposed tests would be beneficial in general. |
This looks like a "backport all the way to 3.2.x" fix yeah? |
Yes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I'm working on some tests, hope to push shortly then merge. |
I added tests, they all fail without this change (except UInt division which was correct), and they all pass with this change. |
Thanks for reminding me @jackkoenig, I had some tests that are better than nothing and test a broader space of widths/ops, but I hadn't pushed them since they felt a little silly. But test > no tests, so I added them, too. |
d5703e0
to
4da8dc4
Compare
* Update reported width from div/rem to match FIRRTL results * Add tests for width of % and / on UInt and SInt * Add loop-based test for known UInt/SInt op result widths Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 98ce919) # Conflicts: # core/src/main/scala/chisel3/internal/firrtl/IR.scala
* Update reported width from div/rem to match FIRRTL results * Add tests for width of % and / on UInt and SInt * Add loop-based test for known UInt/SInt op result widths Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 98ce919)
* Update reported width from div/rem to match FIRRTL results * Add tests for width of % and / on UInt and SInt * Add loop-based test for known UInt/SInt op result widths Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 98ce919)
…1769) * Update reported width from div/rem to match FIRRTL results * Add tests for width of % and / on UInt and SInt * Add loop-based test for known UInt/SInt op result widths Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 98ce919) Co-authored-by: Albert Magyar <albert.magyar@gmail.com>
…1770) * Update reported width from div/rem to match FIRRTL results * Add tests for width of % and / on UInt and SInt * Add loop-based test for known UInt/SInt op result widths Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 98ce919) Co-authored-by: Albert Magyar <albert.magyar@gmail.com> Co-authored-by: Jack Koenig <koenig@sifive.com>
See #1746. I think it's reasonable to add a test where op result
.getWidth
values are compared against FIRRTL IR values using a few nested for loops, so I will update this soon.Type of improvement: bug fix
API impact:
getWidth
now returns correct width for div/rem resultsBackend code-generation impact: the most notable case is where a user supplies a computed width depending on
getWidth
as a specified width for a declared Wire/Reg/IO. These widths will change; while the error in therem
cases led to over-provisioned widths, theSInt
div
case led to excessively small widths. Therefore, the existing behavior of signed division in Chisel could have led to observable functional bugs in hardware.Release Notes:
Previously, Chisel returned incorrect values when calling
getWidth
on the direct result of a%
operation or signed division operation, yielding the width of the numerator rather than the actual result width. While the operation is computed with appropriate FIRRTL-defined widths, the results ofgetWidth
can be used during hardware elaboration. The most notable case is where a user supplies a computed width depending ongetWidth
as a specified width for a declared Wire/Reg/IO. These widths will change; while the error in therem
cases led to over-provisioned widths, theSInt
div
case led to excessively small widths. Therefore, the previous behavior of signed division in Chisel could have led to observable functional bugs in hardware.Contributor Checklist
docs/src
?Reviewer Checklist (only modified by reviewer)
Please Merge
?