Repository navigation
[hardware] 🐛 Fix fixed-point rounding, vssrl shift and vnclip clamp - #515
Open
davidharrishmc wants to merge 1 commit into
Open
davidharrishmc wants to merge 1 commit into
davidharrishmc wants to merge 1 commit into
Conversation
fixed_p_rounding used the whole shift-amount element, read bit -1 for a shift of 0, ignored the sticky bits for rne and rounded vnclip on SEW lanes instead of the 2*SEW source. Compute the increment with one function from the RVV 1.0 roundoff definition. vssrl now uses only log2(SEW) bits of the shift amount, and vnclip/vnclipu clamp to the destination range and set vxsat on the destination element's bytes. Fixes pulp-platform#506 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 #506.
fixed_p_roundingis rewritten around one function that computes the rounding increment from the RVV 1.0 roundoff definition (3.8), using the low log2(SEW) bits of the shift amount (log2(2SEW) and the 2SEW source forvnclip/vnclipu) and returning 0 for a shift of 0.vssrluses only log2(SEW) bits of the shift amount.vnclip/vnclipunow saturate to the destination range and setvxsaton the destination element's bytes.valustill keeps only the latest ALU operation'svxsat, so for a narrowing pair the first half's saturation can be lost; that is not addressed here.Verification (Verilator, NrLanes=4, VLEN=512): 96
vssra.vx/vssrl.vx/vnclip.wx/vnclipu.wxcases (several values and shift amounts, all fourvxrmmodes, result andvxsat) against a reference implementation of the spec: 48 wrong on main, all correct with this change. This likely covers part of #163.Changelog
Fixed
vssra/vssrl/vnclip/vnclipurounding increment, thevssrlshift amount andvnclip/vnclipusaturation (vssra/vssrl/vnclip/vnclipu: wrong rounding increment, vssrl shift amount, no vnclip saturation #506)Checklist