sign-extend rs2 for AMOMIN.W/AMOMAX.W operations#267
Open
zyk632 wants to merge 1 commit into
Open
Conversation
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.
fix(atomalu): sign-extend rs2 for AMOMIN.W/AMOMAX.W operations
Summary
Fix a hardware bug in AtomALU where rs2 is not properly sign-extended for
.Watomic operations.Background & Changes
In
LSU.scala:181(AtomALU), the following issues were identified:AMOMIN.W/AMOMAX.W: rs2 was not sign-extended from 32-bit to 64-bitAMOMINU.W/AMOMAXU.W: rs2 was not zero-extended for unsigned comparisonExample:
0x00000000ffffffffshould be treated as-1forAMOMIN.W, but the original RTL treated it as a positive 64-bit value (0xffffffff).Fix applied:
AMOMIN.W/AMOMAX.W): sign-extend lower 32 bits of rs2AMOMINU.W/AMOMAXU.W): zero-extend lower 32 bits of rs2.Doperations: unchanged (64-bit behavior)Test Results
Before fix:
a0 different: right = 0xffffffffffffffff, wrong = 0x0000000000000001After fix:
HIT GOOD TRAP at pc = 0x800000d2, exit code = 0All 35 existing NutShell cputest images pass DiffTest (
failed=0).Modified Files
src/main/scala/nutcore/backend/fu/LSU.scala: Fix rs2 extension for.WAMO operationsRelease Notes
Fix signed/unsigned comparison behavior for AMOMIN.W/AMOMAX.W/AMOMINU.W/AMOMAXU.W operations in AtomALU.