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

Conversation

francislaus
Copy link
Contributor

In sail, when an instruction writes to a register, the register number will also be written to the rvfi_rd_addr field (if it has been built for RVFI output). When an instruction has no destination register, the rvfi_rd_addr remains zero. The CClear instruction in the CHERI is an exception to the regular RISC-V instruction format. It can write to up to eight registers. However, CClear has no destination register, but rather a two-bit immediate determining which quarter of the register file this instruction will write to.

Currently, the sail implementation for CClear writes the highest register number to rvfi_rd_addr. This PR changes this behaviour and never writes a destination register to the field, which results in the field containing zeros. I think this is the correct behaviour for the model as the rvfi_rd_addr field cannot correctly represent the destination register behaviour of CClear.

@francislaus francislaus self-assigned this Oct 31, 2022
@@ -783,7 +783,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.

@jrtc27
Copy link
Member

jrtc27 commented Oct 31, 2022

Why not have it auto detect when it’s been called twice?

@PeterRugg
Copy link
Contributor

Why not have it auto detect when it’s been called twice?

I thought about that, but what if you call it with an immediate where only one bit is set?

@jrtc27
Copy link
Member

jrtc27 commented Oct 31, 2022

Then it reports a single register write, which is accurate?

@PeterRugg
Copy link
Contributor

Hmm, I guess that's one way of looking at it. It might be a little tricky to have Toooba detect that case, although if we're not hoping to synthesise with RVFI there's probably an easy enough hacky way to do it.

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.

3 participants