This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
forked from lowRISC/ibex
-
Notifications
You must be signed in to change notification settings - Fork 1
Add TestRIG and Direct Instruction Injection support #1
Draft
ivanmgribeiro-google
wants to merge
23
commits into
AmbiML:ibex_dii
Choose a base branch
from
ivanmgribeiro-google:ibex_dii
base: ibex_dii
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add TestRIG and Direct Instruction Injection support #1
ivanmgribeiro-google
wants to merge
23
commits into
AmbiML:ibex_dii
from
ivanmgribeiro-google:ibex_dii
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds some barebones files to try to add support for TestRIG as well as its required additions (Direct Instruction Injection). This includes a new simulation file, and also adds SocketPacketUtils from https://github.com/CTSRD-CHERI/SocketPacketUtils (SocketPacketUtils is not vendored in correctly at the moment, this will be changed in a later commit)
The bus does not currently set the error signal when a request is out of ranges, so this commit adds a very simple error detection in the toplevel. At the moment writes are not cancelled.
The SRAM block provided by the shared libraries does not handle reset, so memory is instead implemented in C++ so that it can be reset.
The in_count and out_count variables might have strange values when we encounter exceptions and jumps, so remove these as a factor when extracting RVFI data.
Previously, all our verilator "logic" happened while the clock cycle was low (apart from setting gnt_i signals which happened after it when high). Now, all our logic happens while the clock is high, then we evaluate the core so it can update, and then we set the clock low and evaluate. This commit also makes some tracing dependent on the verbosity - the next commit makes more printing and tracing dependent on verbosity.
If there is no real instruction to insert (ie we have run out of instructions, or for some reason our received, in_count or out_count variables got messed up), then insert NOPs instead. This should prevent the core from locking up if we run out of instructions, and should help in debugging.
When control flow changes occur in the core, the simulation environment needs to replay some instructions (since the instructions that have been inserted were flushed out of the pipeline). This commit adds that logic and also explains it.
This is used to track when a MRET or DRET instruction occurs, so that the simulation environment can correctly replay instructions.
When an xRET or exception is encountered, the controller goes into the FLUSH state. RVFI data is read while the controller is in the FLUSH state, but the PC is only available the next cycle, so for RVFI we need to set the PC WData again once it is available.
In typical uses, MTVEC can be set after the core fetches the first instruction and we can use the boot_addr_i signal to set it. However, when using TestRIG it is possible that the first instruction causes an exception, and in this case there is not enough time to set MTVEC before the exception is handled, so the exception vector will be whatever was in boot_addr_i on boot. This is incompatible with TestRIG, so MTVEC is set to 0 on boot rather than using boot_addr_i.
With the changes so far, Ibex reports the same results in RVFI as the Sail-RISCV model modulo the caveats mentioned in the README.
This was done using the vendor script from the OpenTitan repository. The SocketPacketUtils repository is pinned at the latest commit that successfully built; later commits seem to break compilation.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds support for TestRIG support, which requires supporting Direct Instruction Injection (bypassing the fetch logic and always fetching the correct instruction).