Add sail_project file to modularise the specification#572
Add sail_project file to modularise the specification#572Timmmm merged 8 commits intoriscv:masterfrom
Conversation
|
First of all, I think this is a good idea and needs to be pursued.
However, as the model stands now, it would seem to be a bit difficult to
split up files based on extensions. I'm specifically referring to the CSRs.
They seem to be lumped together and not tied to an extension. For example,
the HPM CSRs are listed in the riscv_csr_begin.sail file. It seems like
they
should be put into an "hpm extension" file.
Also, the implementation of some individual CSRs is based on multiple
extensions. The simplest one I can think of is the misa CSR. As an
example, how would a vector module implement the V bit in the misa?
How can that functionality be scattered?
Bill Mc.
…On Thu, Oct 3, 2024 at 9:07 AM github-actions[bot] ***@***.***> wrote:
Test Results
396 tests ±0 396 ✅ ±0 0s ⏱️ ±0s
4 suites ±0 0 💤 ±0
1 files ±0 0 ❌ ±0
Results for commit e1082d2
<e1082d2>.
± Comparison against base commit 47380fa
<47380fa>
.
—
Reply to this email directly, view it on GitHub
<#572 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXROLOFN5YVVISH37OTGVM3ZZVTUXAVCNFSM6AAAAABPKC4BVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJRG44TQNJTGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Bill McSpadden
Formal Verification Engineer
RISC-V International
mobile: 503-807-9309
Join me at RISC-V Summit North America <http://www.riscvsummit.com/> in
October!
|
|
Everything in the When it comes to things like bits in the (using an attribute just to avoid any concrete syntax for now) where you could push the definition of a field into another module without making it a scattered definition, but I'm not sure it's really needed. |
|
I have also considered adding a feature that would allow you to require a module in such a way that you can only use it in a guarded way, i.e. from the The way that would work is it just combines Sail's existing flow-sensitive typing with the 'in_scope' check the type-system now does, and it means you can add functionality to the base model from an extension in a way where we can statically guarantee it gets compiled out when the extension doesn't exist. |
|
This looks like a huge improvement. I think even if it doesn't solve all the modularisation & organisation issues we should switch to it ASAP. Does the private keyword mean that no other modules can refer to that definition even if they say they depend on it? That sounds very useful too. I think when this is done we should work on improving the organisation of the modules and maybe reducing their size. There are a few places in the code where people have just kind of given up, e.g. this one: |
Exactly, if you have and another file and link them like: You'll get an error like I think there are a few places in the virtual memory code where we have something like |
|
Seems like a great improvement. It might be worth thinking about how we nest the extensions though. |
|
What's the significance of the nested modules? Is it that Another question: is the intention that you can exclude modules from compilation? I mean I don't think we would want that for the C simulator use case (except maybe to exclude Vector for compilation time reasons), but I guess you might want that for the SV backend? |
|
Currently the module namespace is flat, and the nesting just allows you to require a group of related modules, so the following is equivalent to so |
Yes, rather than giving Sail a list of files you can give it a list of module names and it just uses them. The |
Timmmm
left a comment
There was a problem hiding this comment.
Did you have any idea how this would work with the CHERI repo? I guess the simplest thing is to just copy & paste the whole file and then change all the riscv_s to cheri_s where appropriate.
Or maybe add a load of if $CHERI then..? Hmm.
|
The idea was you could have |
|
This would be a good PR to revive so that we can get some of the last RVA23 extensions (hints and control flow) that are waiting on it into the model. Especially now that initial configuration support is merged. @Alasdair I assume that now that Sail 0.19 is released all of the necessary features for this should be available? |
|
Just need to update this to CMake and make sure any new files since this was added are included |
|
Rebased, and update to use CMake. Let's see what the CI thinks... |
|
Down to a single error in the Lean output about |
pmundkur
left a comment
There was a problem hiding this comment.
Some dependencies don't seem to be required.
This PR uses the Sail module system to organise the files in the model. Rather than passing a list of files on the command line, the files are specified using the model/riscv.sail_project file.
…tructions so they don't need it
|
I rebased this, added the unit tests Sail code and addressed the review comments. Hope that's ok! I think we should merge this now. |
|
I now have a minimal example to reproduce the Lean issue, so hopefully I will have it fixed upstream in Sail soon. |
|
I think the Lean is broken due to #1086 now too, so I think we should merge this now anyway. Also I noticed that we now do the classic |
|
I have fixed the Sail to Lean bug now, so CI should start working when I get it merged. |
Use the Sail module system to organise the files in the model. Rather than passing a list of files on the command line, the files are specified using the `model/riscv.sail_project` file. The previous version uses a big flat list of files which is unwieldy and hard to understand as it is not clear immediately what the high level structure of the model is, and the way we configure the model does not allow for extensions to easily be added and removed without hand-modifying the CMake. This doesn't matter for the C backend but it does for formal/SV backends. To solve this problem, I have added a basic module system to Sail, which allows for the structure of the specification to be specified as a collection of modules in a `.sail_project` file. The key ideas here are as follows: - Each of these modules consists of a list of files (much like how we passed a list of files to Sail on the command line previously), as well as a list of modules that module requires. - The module system ensures that if a module does not require another module, it cannot refer to any definitions contained within it. There is also a `private` keyword which can be used to encapsulate implementation details. - Modules can specify other modules that must come before or after them, but without requiring them. This is to support the scattered definition feature. - The `.sail_project` file serves as an instant reference to the overall model structure, it isn't embedded in the files. You can also have multiple `.sail_project` files, so you could pass `riscv.sail_project cheri.sail_project` to Sail, and it would be able to link them together in much the same way we do now. - There is some basic support for conditional includes. With this, building the model becomes as simple as: sail --project model/riscv.sail_project --variable ARCH=RV64 --all-modules --------- Co-authored-by: Tim Hutt <timothy.hutt@codasip.com>
Use the Sail module system to organise the files in the model. Rather than passing a list of files on the command line, the files are specified using the
model/riscv.sail_projectfile.The previous version uses a big flat list of files which is unwieldy and hard to understand as it is not clear immediately what the high level structure of the model is, and the way we configure the model does not allow for extensions to easily be added and removed without hand-modifying the CMake. This doesn't matter for the C backend but it does for formal/SV backends.
To solve this problem, I have added a basic module system to Sail, which allows for the structure of the specification to be specified as a collection of modules in a
.sail_projectfile. The key ideas here are as follows:Each of these modules consists of a list of files (much like how we passed a list of files to Sail on the command line previously), as well as a list of modules that module requires.
The module system ensures that if a module does not require another module, it cannot refer to any definitions contained within it. There is also a
privatekeyword which can be used to encapsulate implementation details.Modules can specify other modules that must come before or after them, but without requiring them. This is to support the scattered definition feature.
The
.sail_projectfile serves as an instant reference to the overall model structure, it isn't embedded in the files. You can also have multiple.sail_projectfiles, so you could passriscv.sail_project cheri.sail_projectto Sail, and it would be able to link them together in much the same way we do now.There is some basic support for conditional includes.
With this, building the model becomes as simple as: