Repository navigation
fpnew_fma_multi: fix after-rounding underflow for narrow formats - #190
Open
theOfficeCat wants to merge 1 commit into
Open
theOfficeCat wants to merge 1 commit into
theOfficeCat wants to merge 1 commit into
Conversation
The after-rounding underflow detection reused the single-format expression `sum_sticky_bits[MAN_BITS*2 + 4]`, which only points to the bit just below the round bit when the datapath is sized for the destination format. In the multi-format unit the datapath is sized for the widest enabled format, so for narrower formats that bit lives in `final_mantissa[SUPER_MAN_BITS-MAN_BITS-1]` and `sum_sticky_bits` is typically zero, causing spurious underflow to be flagged when a subnormal result rounds up to the smallest normal.
|
Hi @theOfficeCat, Can confirm it is working with the new changes of this commit. |
There was a problem hiding this comment.
🟢 Approval recommended
The selected indices match the rounding-bit layout for narrow and widest formats, with no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes spurious after-rounding underflow flags for narrow destination formats in the multi-format FMA unit, addressing #182.
Changes:
- Selects the bit below the round bit relative to each format’s mantissa width.
- Preserves the existing behavior for the widest enabled format.
| File | Description |
|---|---|
| src/fpnew_fma_multi.sv | Uses a format-relative bit for after-rounding underflow detection. |
Review effort: Balanced
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.
Fixes #182
What
Use the format-relative remainder bit in the after-rounding underflow detection of
fpnew_fma_multiinstead of the single-format expressionsum_sticky_bits[MAN_BITS*2 + 4].Why
The after-rounding UF term handles the case where a subnormal pre-round value rounds up to the smallest normal, and looks at the bit just below the round bit (for RNE/RMM). In the single-format
fpnew_fmaunitPRECISION_BITS == MAN_BITS + 1, sosum_sticky_bits[MAN_BITS*2 + 4]is exactly that bit. In the multi-format unit the datapath is sized for the widest enabled format (SUPER_MAN_BITS), so for narrower destination formats the bit lives infinal_mantissa[SUPER_MAN_BITS-MAN_BITS-1]and thesum_sticky_bitsone is typically zero: the check then always takes the underflow branch and raises spurious underflow (RNE/RMM) when the result rounds up to the smallest normal, e.g. FP32 FMADD/MUL withFpFmtConfig={FP32,FP64}(ADDMUL merged).The remainder bit is now selected per format:
final_mantissa[SUPER_MAN_BITS-MAN_BITS-1]whenMAN_BITS < SUPER_MAN_BITS, andsum_sticky_bits[2*PRECISION_BITS+2]for the widest format (same bit as before, so FP64 is unchanged).cc @Axionix77 (who reported #182) — could you confirm this matches the case on your side?