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

Question: how to make implementation-defined behaviour customisable #278

Open
Timmmm opened this issue Jun 27, 2023 · 4 comments
Open

Question: how to make implementation-defined behaviour customisable #278

Timmmm opened this issue Jun 27, 2023 · 4 comments
Labels
configuration Additional configuration settings needed for the model question Further information is requested

Comments

@Timmmm
Copy link
Collaborator

Timmmm commented Jun 27, 2023

In the RISC-V spec there are many places where there's a choice about how to behave. In this model there are already a few flags that encode those choices in riscv_platform.sail, e.g. plat_mtval_has_illegal_inst_bits or plat_enable_dirty_update.

However as far as I can see all of the existing options are essentially booleans. That works when the spec says "implementations must always do either A or B", but there are plenty of places where it says "the behaviour is implementation defined", or "implementations can do A or B depending on X". Stuff that can't be encoded with a boolean.

I couldn't find anywhere in the current model that handles those things. I was thinking the obvious solution is to move the customisable functionality into its own function and put that function in its own file. That way if people want to change it they just write a new version of the function in another file and then edit the Makefile. Kind of like the ..._ext.sail files.

Does that seem reasonable? Do you have a plan for this?

@billmcspadden-riscv
Copy link
Collaborator

billmcspadden-riscv commented Jun 27, 2023 via email

@Timmmm
Copy link
Collaborator Author

Timmmm commented Jun 27, 2023

I agree, building the Sail model is quite a pain due to the use of OCaml (we ended up storing the generated C in Git so only people editing the model need OCaml & Sail). But I don't see how you can avoid compile-time configuration in some cases because the range of possible behaviours is too large.

For example for WARL CSRs the spec says:

Implementations can return any legal value on the read of a WARL field when the last write was of an illegal value, but the legal value returned should deterministically depend on the illegal written value and the architectural state of the hart.

A runtime option can't cover all the possible implementations here. In cases like these would you say the approach of putting the implementation function (e.g. legalize_somecsr()) in its own file would be the least bad option?

I guess an alternative is to give up on trying to cover all the possible implementations, and just have a set of predefined implementations, and maybe add more if people implement behaviours that aren't on the list?

I'm mainly asking so we can keep our modifications as upstreamable as possible.

@billmcspadden-riscv
Copy link
Collaborator

billmcspadden-riscv commented Jun 27, 2023 via email

@PeterSewell
Copy link
Collaborator

PeterSewell commented Jun 28, 2023 via email

@Timmmm Timmmm added question Further information is requested configuration Additional configuration settings needed for the model labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Additional configuration settings needed for the model question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants