Skip to content

Commit

Permalink
Fix and simplify fmv execute clauses
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Timmmm committed Oct 31, 2024
1 parent c7902ae commit 0b8ff1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 4 additions & 8 deletions model/riscv_insts_dext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -934,18 +934,14 @@ function clause execute (F_UN_TYPE_D(rs1, rd, FCLASS_D)) = {
}

function clause execute (F_UN_TYPE_D(rs1, rd, FMV_X_D)) = {
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;
assert(xlen >= 64 & flen >= 64);
X(rd) = sign_extend(F(rs1)[63..0]);
RETIRE_SUCCESS
}

function clause execute (F_UN_TYPE_D(rs1, rd, FMV_D_X)) = {
assert(xlen >= 64);
let rs1_val_X = X(rs1);
let rd_val_D = rs1_val_X [63..0];
F(rd) = rd_val_D;
assert(xlen >= 64 & flen >= 64);
F(rd) = nan_box(X(rs1)[63..0]);
RETIRE_SUCCESS
}

Expand Down
8 changes: 2 additions & 6 deletions model/riscv_insts_fext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -1061,16 +1061,12 @@ function clause execute (F_UN_TYPE_S(rs1, rd, FCLASS_S)) = {
}

function clause execute (F_UN_TYPE_S(rs1, rd, FMV_X_W)) = {
let rs1_val_S = F(rs1)[31..0];
let rd_val_X : xlenbits = sign_extend(rs1_val_S);
X(rd) = rd_val_X;
X(rd) = sign_extend(F(rs1)[31 .. 0]);
RETIRE_SUCCESS
}

function clause execute (F_UN_TYPE_S(rs1, rd, FMV_W_X)) = {
let rs1_val_X = X(rs1);
let rd_val_S = rs1_val_X [31..0];
F(rd) = nan_box (rd_val_S);
F(rd) = nan_box(X(rs1)[31..0]);
RETIRE_SUCCESS
}

Expand Down

0 comments on commit 0b8ff1e

Please sign in to comment.