[RVBNA] correcting pseudo-code description (round-to-odd masking in particular)#3244
Draft
Nicolas Brunie (nibrunieAtSi5) wants to merge 3 commits into
Draft
[RVBNA] correcting pseudo-code description (round-to-odd masking in particular)#3244Nicolas Brunie (nibrunieAtSi5) wants to merge 3 commits into
Nicolas Brunie (nibrunieAtSi5) wants to merge 3 commits into
Conversation
…nge) Signed-off-by: Nicolas Brunie <nibrunie@gmail.com>
Signed-off-by: Nicolas Brunie <nibrunie@gmail.com>
Signed-off-by: Nicolas Brunie <nibrunie@gmail.com>
Nicolas Brunie (nibrunie)
force-pushed
the
rvbna-lzc-jam-fix
branch
from
July 12, 2026 17:39
d3ce237 to
93c538a
Compare
Normative Rule Changes DetectedThis PR modifies normatively tagged text. Please review the changes below to ensure they are intentional. View Detected ChangesNormative Tag Change Reportriscv-spec SpecificationWhat happens next:
How to update reference files (if needed): make update-ref
git add ref/*.json
git commit -m "Update normative tag reference files"
This comment was automatically generated by the normative tag check workflow. |
Contributor
|
Thank you Nicolas Brunie (@nibrunie) for the fixes. Nice work. |
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.
Numerous errors have been found in the RVBNA pseudo-code specification (thanks to Aryan Agarwal (@AAgarwal04) and Joseph Rahmeh (@jrahmeh)).
This PR addresses the known issues:
Mask for jamming normal results
The mask used for normal results was incorrect
The
jamMaskshould have a size of (o+1+g - lzc) bits if applied before the normalization shift, or have a size of (o+1+g) bits if applied after the left normalization shift by lzc bits.So the following is not correct:
In particular:
should actually either be
Or
Denormalization and Mask for jamming subnormal results
Both the denormalization of the result and the mask jamming for subnormal result were incorrect.
For the least normal result, the expected biased exponent is
resExp=1.resExp=0and any negativeresExpvalues correspond to a subnormal result.if
resExp < -(q-1), then the result's MSB is smaller than the least representable subnormal.Once normalized by the leading zero count
lzc, the denormalized result can be obtained by keeping (q-1) mantissa bits with the MSB corresponding toresExp=0.Mask for jamming products
The product jamming scheme looks correct:

Methodology
To uncover the issues and test the corrections, I have developed a benchmark to compare the pseudo-code (AI generated translation) and the spike implementation: nibrunieAtSi5/riscv-experimental#2.
At the moment, the spike implementation seems clear of issues (
(https://github.com/riscv-software-src/riscv-isa-sim/blob/master/riscv/bulknormdot.h)