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

Add bool for writing to destination reg to RVFI output #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cheri_insts.sail
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ function clause execute (CClear(q, m)) = {
if q_u == 0 & i == 0 then
DDC = null_cap
else
C(8 * q_u + i) = null_cap;
wC (false, 8 * q_u + i, null_cap);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the bit that will show in the ISA doc, and the no-context false may be confusing. I wonder if there's a clearer way, for example wrapping wc(false, ....) in a function. Not sure what to call that function though, since RVFI isn't really visible from the instruction-level description.

RETIRE_SUCCESS
}

Expand Down
14 changes: 9 additions & 5 deletions src/cheri_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function rC r = {
}

/* writes a register with a capability value */
val wC : forall 'n, 0 <= 'n < 32. (regno('n), regtype) -> unit effect {wreg, escape}
function wC (r, v) = {
val wC : forall 'n, 0 <= 'n < 32. (bool, regno('n), regtype) -> unit effect {wreg, escape}
function wC (b, r, v) = {
match r {
0 => (),
1 => x1 = v,
Expand Down Expand Up @@ -141,17 +141,21 @@ function wC (r, v) = {
_ => internal_error(__FILE__, __LINE__, "Invalid capability register")
};
if (r != 0) then {
rvfi_wX(r, v.address);
if b then
rvfi_wX(r, v.address);
if get_config_print_reg() then
print_reg("x" ^ dec_str(r) ^ " <- " ^ RegStr(v));
}
}

function rC_bits(r: bits(5)) -> regtype = rC(unsigned(r))

function wC_bits(r: bits(5), v: regtype) -> unit = wC(unsigned(r), v)
function wC_bits(r: bits(5), v: regtype) -> unit = wC (true, unsigned(r), v)

overload C = {rC_bits, wC_bits, rC, wC}
val wC_rvfi : forall 'n, 0 <= 'n < 32. (regno('n), regtype) -> unit effect {wreg, escape}
function wC_rvfi (r, v) = wC (true, r, v)

overload C = {rC_bits, wC_bits, rC, wC_rvfi}

val ext_init_regs : unit -> unit effect {wreg}
function ext_init_regs () = {
Expand Down