-
Notifications
You must be signed in to change notification settings - Fork 177
Fix width of signed addition when input to mux #2440
Conversation
private def isSignedAdd(e: Expression): Boolean = e match { | ||
case DoPrim(PrimOps.Add, _, _, _: SIntType) => true | ||
case _ => false | ||
} |
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.
This may be prefetching, too far, but maybe we want to do this for any arithmetic op of SIntType
? E.g., I can produce a similar error with subtraction:
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.
Definitely not prefetching too far. If you can produce the same error with other ops then we should fix those as well. I'm leaning toward the VerilogEmitter change instead since it should fix the whole class of issues but it makes me a little nervous.
Fix bugs related to arithmetic ops inlined into a mux leg. Add formal equivalence checks to lock in this behavior. Signed-off-by: Schuyler Eldridge <[email protected]>
Skipping formal CI because it should fail |
I added the label a bit late. Formal equiv for Ops failed (as it should because we're fixing it), now rerunning. |
Extremely focused fix for #2439. I'm not sure if this is the best fix but I think the test is pretty good at least so wanted to put this out there.
Fixes #2439
h/t to @youngar for finding an OG bug.
I'm wondering if it would be better to just remove the casts in the VerilogEmitter, do we ever actually need to cast the inputs to a mux?
firrtl/src/main/scala/firrtl/backends/verilog/VerilogEmitter.scala
Line 182 in 4347f57
That's just a lot scarier of a change 😨
I'm backporting this as far as it will go...
Contributor Checklist
Type of Improvement
API Impact
No impact
Backend Code Generation Impact
Minimal, will split out signed addition into another Statement if it is a direct input to a mux
Desired Merge Strategy
Release Notes
Fix width of signed addition when it is an input to a mux.
Reviewer Checklist (only modified by reviewer)
Please Merge
?