-
Notifications
You must be signed in to change notification settings - Fork 188
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 support for Zcmp extension #730
base: master
Are you sure you want to change the base?
Conversation
I think the logic for both extensions cannot be enabled together should be in the
|
what |
You should at least add a co-author( |
Hey @rez5427, thank you for pointing that out! I didn’t mean to overlook your contribution, which is why I linked to your pull request in my PR message. I’ve now added you as a co-author in the commit. |
Yes, we should make sure when rebasing older PRs to ensure the original authors are preserved with the Co-authored-by field. PR authors should also feel free to add themselves to the list of authors. |
@Alasdair Yeah sure, will do! In #8950389 I added the Zcmp extension to the C emulator along with the --enable-zcmp command-line argument. I retested everything, and it now works with or without virtual memory. However, the warnings are still there, even after using Maybe I missed something? |
Assuming you’re talking about the 4 warnings in your initial message, they won’t be impacted by these changes. They are new warnings introduced by the unreleased version of sail that I assume you’re using and either need changes to sail itself or #689. |
It looks like the co-author is messed up on the first commit because of an erroneous quotation mark. |
Yes as Jordan said, those warnings are unrelated to this commit. Don't worry about them. |
@jordancarlin Oh yes! Good catch, I am going to fix that! Btw. I forgot to change one line, which is fixed in 3d9cd3e Yes exactly I use the unreleased version of sail. But now I know thanks. |
Co-authored-by: guan jian <148229859+rez5427@users.noreply.github.com>
Co-authored-by: guan jian <148229859+rez5427@users.noreply.github.com>
- Added support for the Zcmp extension to the C Emulator, which can be enabled via the command-line argument `--enable-zcmp`. - Enabling Zcmp disables the Zcd extension. - By default, Zcmp is disabled, and Zcd remains enabled.
- Replace `width_bytes` with `xlen_bytes`. - Remove unused code. - Eliminate unnecessary assertions.
One aspect worth discussing: According to the spec, Additionally, an interrupt can occur during the read/write sequence and the interrupt handler might overwrite the written bytes and we have to start the whole read/write sequence from the beginning. For example, would it make sense to replace this block with repeated STORE calls?
replacing with
As implemented now, it seems no interrupt can be detected during execution (?). This raises the question: Can I even nest execution clauses? As far as I understand the simulation continues only once a instruction is either retired or has failed. In this case, PUSH would call STORE multiple times and PUSH is not yet retired and has not yet failed |
It might be better to factor out the core address logic from If interrupts are to be taken during the loop (which is up to the implementation, according to the spec), it would need to involve the stepper. This might be easier after something like #746. |
Yes, I agree on both points. Having some form of access to the stepper is probably the way to go, just in case someone wants to run a test case with interrupts between load and store sequences. |
Following #525 and #610, this is the third attempt to add support for the Zcmp extension.
Thankfully most the work was already done and the code remains largely the same as in #610, with a few minor fixes. I was able to compile the model and successfully run most tests (details on the issue below).
I have added a set of tests to the riscv-test suite, which can be found here:
To run the tests, you will need the latest RISC-V GNU Toolchain (version 15). I had to switch to the developer branches (trunk) of binutils and GCC to compile the extension successfully. While Zcmp is officially supported from version 14, a bug currently prevents compilation with the latest official release available on GitHub.
The command to execute is:
I ran into two problems which I would like to discuss here:
I am able to compile without warnings by incorporating the proposed changes from #689, but these changes have not been merged yet. Is there a way to get rid of these warnings?
This brings me to the second problem.
I had been running the test suite in two different environments, one with virtual memory disabled (p) and the other with virtual memory enabled (v).
All tests without virtual memory passed. However, once I enabled virtual memory, I noticed that all Zcmp instructions were incorrectly decoded and instructions were decoded as
c.fsdsp
. The Zcd extension definesc.fsdsp
, whose encoding overlaps with instructions of the Zcmp extension. I still don’t understand why enabling virtual memory caused this incorrect decoding.According to the RISC-V Unprivileged Specification, Zcmp cannot be used while the Zcd extension is enabled, and I am unsure how to properly integrate Zcmp into our current workflow (specifically in ./modal/CMakeLists.txt).
I am also uncertain whether this issue is related to the first problem. Maybe someone has some ideas?