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 Zawrs extension #398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Zawrs extension #398

wants to merge 1 commit into from

Conversation

ved-rivos
Copy link
Contributor

Copy link

github-actions bot commented Jun 22, 2024

Test Results

712 tests  ±0   712 ✅ ±0   0s ⏱️ ±0s
  6 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit edd2e35. ± Comparison against base commit 77bd4d5.

♻️ This comment has been updated with latest results.

model/riscv_insts_zawrs.sail Outdated Show resolved Hide resolved

platform_start_wrs_timeout(if op == WRS_STO then true else false);

while reservation_set_valid() & not(interrupts_pending()) & not(platform_is_wrs_timed_out()) do ();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if the best way to handle this is via waiting in the actual execute function. WFI doesn't work like this (to be fair it doesn't work at all because there's no proper interface for injecting interrupts currently).

Maybe the model should be a state machine and the step() function handled the WFI and WRS states explicitly?

I dunno, we probably need to think about this properly. Maybe this is fine for now though since the platform callbacks are just hard-coded to time out immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent here is two folds:

  1. As a precise documentation of the ISA - this shows that the execution stalls while the instruction waits for these three conditions a) a snoop that invalidates the reservation set due to a store from another hart or a device b) an interrupt becomes pending c) the wait times out.
  2. Allows the platform test bench to inject these into the mode - a snoop invalidation or the platform specific timer timeout. This would also include advancing cycles and time.

We cannot step() as it is presently as we cannot fetch or execute instructions when stalled.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I agree it is nice to document the stalls like this. But documentation isn't the only purpose of the model. I think we want to be a bit careful about this because this is the first bit of code in the model that assumes that step() can block.

We cannot step() as it is presently as we cannot fetch or execute instructions when stalled.

My feeling is that step() should really mean "step the model state", not "fetch and execute an instruction". At the moment those are exactly the same because none of the execute functions call platform callbacks to wait for an event, including WFI. If step() blocks you need threads in lots of situations (e.g. multiple harts, cosimulation), which are quite a pain in C++ and even worse in C.

But it's true that turning step() into an explicit state machine would make the code less clear. Hmm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats why I wrote "as it is presently". I dont think it would make the code less clear as a state machine. We would need instead of RETIRE_SUCCESS, something like STALL_UNTIL and the code should setup the conditions for "until". The model would then want the execution to resume after the STALL_UNTIL - STALL_UNTIL then becomes sort of like a swapcontext().

Copy link
Collaborator

Choose a reason for hiding this comment

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

something like STALL_UNTIL

Yeah exactly! We also use RETIRE_DEBUG_TRIGGER in Retired, and we should really have RETIRE_ILLEGAL too - see #412.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's no proper interface for injecting interrupts currently

#395 provides timer interrupts.

model/riscv_insts_zawrs.sail Outdated Show resolved Hide resolved
model/riscv_insts_zawrs.sail Show resolved Hide resolved
model/riscv_insts_zawrs.sail Show resolved Hide resolved
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.

4 participants