Skip to content

[hardware] 🐛 Saturate vsmul only for the most negative product - #516

Open
davidharrishmc wants to merge 1 commit into
pulp-platform:mainfrom
davidharrishmc:fix/vsmul-saturation
Open

davidharrishmc wants to merge 1 commit into
pulp-platform:mainfrom
davidharrishmc:fix/vsmul-saturation

Conversation

@davidharrishmc

Copy link
Copy Markdown

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. vsmul sets vxsat only 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, vxsat was 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.vx cases at SEW 8/16/32/64, all four vxrm modes, result and vxsat: 40 wrong on main; with this change vxsat is 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

Checklist

  • Automated tests pass (Ara's own test suite was not run; see Verification)
  • Changelog updated
  • Code style guideline is observed

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vsmul sets vxsat for products that do not saturate and does not saturate (-2^(SEW-1))^2

1 participant