Repository navigation
[hardware] 🐛 Saturate vsmul only for the most negative product - #516
Open
davidharrishmc wants to merge 1 commit into
Open
davidharrishmc wants to merge 1 commit into
davidharrishmc wants to merge 1 commit into
Conversation
vxsat was set whenever the result sign differed from the product sign, which includes small negative products that round to 0, and (-2^(SEW-1))^2 wrapped instead of saturating. Only that product overflows, so detect it from the operands and clamp it after the multiply case. Fixes pulp-platform#507 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: David Harris <David_Harris@hmc.edu>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caution
This pull request was generated by an AI assistant (Claude Code) and has not been reviewed by a human. Please review it with that in mind.
Fixes #507.
vsmulsetsvxsatonly when both operands are -2^(SEW-1), the one product that overflows, and saturates that product to 2^(SEW-1)-1 in a separate statement after the multiply case. Before,vxsatwas set whenever the result sign differed from the product sign, which includes small negative products that round to 0, and the overflowing product wrapped. This does not touch the SEW=16 shift amount fixed by #503.Verification (Verilator, NrLanes=4, VLEN=512): 96
vsmul.vxcases at SEW 8/16/32/64, all fourvxrmmodes, result andvxsat: 40 wrong on main; with this changevxsatis right in all 96 and the only wrong results are 8 SEW=16 cases that are half the expected value, the shift amount #503 fixes.Changelog
Fixed
vsmulvxsatonly for (-2^(SEW-1))^2 and saturate that product to 2^(SEW-1)-1 (vsmul sets vxsat for products that do not saturate and does not saturate (-2^(SEW-1))^2 #507)Checklist