Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RV64F compilation, simplify fmv implementation, and make nan boxing functions generic #594

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Timmmm
Copy link
Collaborator

@Timmmm Timmmm commented Oct 15, 2024

Simplify the implementations with fewer intermediate variables, and fix compilation of RV64F.

I also added relevant quote from the spec because the spec for these instructions is very confusing. This is a prime candidate for getting Sail code into the spec.

Fixes #556

Copy link

Test Results

396 tests  ±0   396 ✅ ±0   0s ⏱️ ±0s
  4 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 60448aa. ± Comparison against base commit 2b65a0d.

Copy link
Collaborator

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: The title of the commit sounds like there is an implementation bug. Maybe Fix RV64F compilation and simplify fmv implementation?

Change LGTM.

assert(xlen >= 64);
let rs1_val_D = F(rs1)[63..0];
let rd_val_X : xlenbits = sign_extend(rs1_val_D);
X(rd) = rd_val_X;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the extends/truncates, they generalise the code to support xlen != 64 and flen != 64 (RV128 or RVQ), whereas yours assumes xlen == flen == 64.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, the only code changes needed should be to add && flen >= 64 to the asserts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This will need to be reverted in #445, so no reason to remove it here. Simplifying it to all happen in-line like you did with F seems cleaner though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm good point! I think it was technically missing the nan_box, presumably because the Q version wasn't available here so I added it, and pulled the code from #448 to make the nan boxing functions support all of the float sizes.

let rd_val_X : xlenbits = sign_extend(rs1_val_S);
X(rd) = rd_val_X;
// A narrower n-bit transfer out of the floating-point registers will
// transfer the lower n bits of the register ignoring the upper FLEN-n bits.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point of these comments? These behave exactly as one would expect, and are entirely consistent with the rest of the ISA.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, reading a 32-bit value reads that 32-bit sub register, and writing one either sign-extends, in the case of integer destinations, or nan boxes, in the case of float destinations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it wasn't meant to contradict any expectations - it's a direct quote from the spec; just explain why the code was doing what it is (because it's not obvious IMO unless you are an expert). I can remove it if you like. Or maybe put it in quotes?

@Timmmm Timmmm changed the title Fix and simplify fmv execute clauses Fix RV64F compilation and simplify fmv implementation Oct 17, 2024
This simplifies the code and allows easily supporting the Q extension.
Simplify the implementations with fewer intermediate variables, and fix compilation of RV64F.

I also added relevant quote from the spec because the spec for these instructions is very confusing. This is a prime candidate for getting Sail code into the spec.
@Timmmm Timmmm changed the title Fix RV64F compilation and simplify fmv implementation Fix RV64F compilation, simplify fmv implementation, and make nan boxing functions generic Oct 28, 2024
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.

Doesn't build with FLEN != XLEN
4 participants