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

Draft: refactor the instruction stepper to better support waiting instructions like WFI, WRS.{NTO, STO} #746

Closed
wants to merge 4 commits into from

Conversation

pmundkur
Copy link
Collaborator

This tries to address the issues raised in #398 and implements some ideas discussed in #412.

The first commit refactors the stepper and instruction retirement, and addresses #412.
The second adds a Wait state to the stepper and exposes it to the C emulator.
The third adds a configuration option for the max number of wait states before the Wait (for WFI) expires. This should provide a better foundation for #398.

This is an invasive and backwards-incompatible change, and so mainly submitted for discussion.

I am unsure of the effects on RVFI. Is it still being used?

The main goal here is to surface wait-states of the hart
(e.g. as caused by WFI and WRS.{NTO,STO}) into the stepper.

The stepper is the main interface to the Sail-external harness.
This makes it easier to communicate wait-states to the harness,
allowing the pausing of Sail execution could be made configurable.

The refactor makes interrupt and exception handling more
symmetrical: both are now handled in the stepper.

The type related to retirement failure is now in its own file.

This also removes the model-internal global instbits register into
a stepper-local variable.

Some stepper-specific retirement codes have been introduced that
are unrelated to the execute clause; it should be possible to fix
those in a less invasive refactor of the stepper.
…lator.

The Wait state is exited on interrupts or if requested by the C
emulator.  The current implementation requests an immediate exit.

This allows a wait loop to be implemented in the Sail-external
harness.
This adds an option to configure the maximum steps to remain in
the Wait state.

This is currently only used for WFI, but the basic mechanism can
be re-used for adding WRS.{STO, NTO} in the future.
Copy link

github-actions bot commented Feb 17, 2025

Test Results

392 tests  ±0   392 ✅ ±0   1m 22s ⏱️ +2s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 282e485. ± Comparison against base commit c650166.

♻️ This comment has been updated with latest results.

@jordancarlin
Copy link
Collaborator

I am unsure of the effects on RVFI. Is it still being used?

It is still being used. There are plans to transition it to a runtime option instead of compile time, but we definitely don't want to break compatibility with it.

@pmundkur
Copy link
Collaborator Author

What is the recommended way of testing RVFI?

I tried using CTSRD-CHERI/TestRig with utils/scripts/runTestRIG.py -a sail -b toooba -r rv64g. It was able to run on both master and this PR, but errors were reported against both.

@jordancarlin
Copy link
Collaborator

What is the recommended way of testing RVFI?

That's a good question and another thing that should be added to CI. Right now we only test building the RVFI model in CI.

@pmundkur
Copy link
Collaborator Author

I confirmed with TestRig that there is no RVFI regression in this PR vs master. The command used was:
utils/scripts/runTestRIG.py -a manual -b manual --implementation-A-port 8080 --implementation-B-port 8081
where the riscv_rvfi_RV64 from the PR and the master were pre-launched with -r <port>

@billmcspadden-riscv billmcspadden-riscv added the tgmm-agenda Tagged for the next Golden Model meeting agenda. label Feb 24, 2025
@pmundkur
Copy link
Collaborator Author

@Alasdair I tried out your suggestion to reduce the size of this PR by defining in riscv_inst_retire.sail:

let RETIRE_SUCCESS : Retired(Retire_Failure) = RETIRE_SUCCESS()

But this results in:

Warning: Identifier RETIRE_SUCCESS found in pattern is also a union constructor at riscv_inst_retire.sail:33.4-18:
33 |let RETIRE_SUCCESS : Retired(Retire_Failure) = RETIRE_SUCCESS()
   |    ^------------^
   | 
Suggestion: Maybe you meant to match against RETIRE_SUCCESS() instead?

Type error:
riscv_inst_retire.sail:33.4-18:
33 |let RETIRE_SUCCESS : Retired(Retire_Failure) = RETIRE_SUCCESS()
   |    ^------------^
   | Local variable RETIRE_SUCCESS is already bound as a function name

i.e. it results in both a warning and a type error.

@Alasdair
Copy link
Collaborator

You would need to give the constructor a different name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tgmm-agenda Tagged for the next Golden Model meeting agenda.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants