aboutsummaryrefslogtreecommitdiff
path: root/c_emulator/riscv_model_impl.cpp
AgeCommit message (Collapse)AuthorFilesLines
2026-04-24Add a configuration option for exact matches on reservation addresses for ↵Prashanth Mundkur1-2/+8
LR/SC. (#1675) This enables configuration of the Sail model to match the behavior of implementations such as Spike.
2026-04-17Tweak trap loop detector heuristic. (#1666)Prashanth Mundkur1-0/+7
The previous heuristic did not suffice for a few ACT4 tests where the trap count grew slowly but steadily over the xret count. Adjust by introducing an instruction retired callback and resetting the loop detector when a sufficient number of instructions have retired since the last trap. This still catches tight trap loops but allows the above tests to complete successfully. --------- Co-authored-by: Alex Richardson <alexrichardson@google.com>
2026-04-14Detect potentially infinite trap loops. (#1656)Prashanth Mundkur1-0/+7
This helps in automated tested environments where an infinite loop caused by a failing test can cause issues. An `xret_callback` is used in combination with the existing `trap_callback` to detect trap loops. The `trap_callback` is now called after the state changes due to the trap are visible.
2026-04-13Add --trace-tlb trace flag for TLB tracing (#1652)Nadime Barhoumi1-0/+28
Add a --trace-tlb feature to log changes to the TLB. This also changes the `--trace-all` CLI option to just `--trace` and removes especially verbose options that people probably don't want by default.
2026-02-19Log Sail exceptions into the execution trace. (#1555)2026-02-23-c4d3140Prashanth Mundkur1-0/+6
With a thrown Sail exception, the log now terminates with something like: ``` [119] [M]: 0x000000008000200E (0x10A29073) csrrw x0, senvcfg, x5 main+14 Fatal reserved behavior: xenvcfg.CBIE = 0b10 Exiting due to uncaught exception: prelude/errors.sail:28.2-28.41 ``` where previously it would only show ``` [119] [M]: 0x000000008000200E (0x10A29073) csrrw x0, senvcfg, x5 main+14 Exiting due to uncaught exception: prelude/errors.sail:28.2-28.41 ``` This fixes #1553.
2026-02-08Make `config` settings non-global (#1535)2026-02-09-de7c9e8Tim Hutt1-10/+49
Move the `config_..` settings into `CLIOptions` and `ModelImpl` so they are no longer global.
2026-01-14Rename the `ext_access_type` type to `mem_payload`. (#1479)Prashanth Mundkur1-1/+1
This was initially introduced as a hook for CHERI to override as an external (`ext_`) extension. However, this type can also be used to support memory accesses for standard extensions such as Zicfiss (and possibly others in addition to CHERI). The type is also redefined to an `enum` (from `unit`) to support these forthcoming extensions.
2025-12-22Improved clang-format style (#1396)Tim Hutt1-104/+52
This fixes various annoyances in our clang-format style that have been bothering me for a while: * Binpacking arguments/parameters and aligning them to the opening `(` is *really* bad for diffs/conflict resolution. This changes it to try to match the "prettier" algorithm (also used by Sail's autoformatter), which has much simpler and better behaviour - if the arguments fit on one line do that, otherwise put each argument on its own line. * Don't put functions on one line. This is also a little diff-unfriendly and feels unnecessarily inconsistent to me. * The line length limit of 80 characters is very constrictive so I increased it to 120 characters. * For some reason it didn't put `{` on a new line... except for function bodies, which is weirdly inconsistent. Now `{` never starts on a new line. * Sort `#include`s. This might have been needed in the past but I verified it builds with sorted includes now.
2025-12-10Add callbacks and logging for page table walks (#1370)Ariel Xiong1-0/+35
Add callbacks for each step of the page table walk process, and an option to log them. This required some quite awkward changes to resolve a dependency loop. We can fix this better with [a change to the Sail compiler](https://github.com/rems-project/sail/issues/1560#issuecomment-3628341263). Fixes #1356 --------- Signed-off-by: Ariel Xiong <ArielHeleneto@outlook.com> Co-authored-by: Tim Hutt <tdhutt@gmail.com>
2025-12-05Use C++ Sail output (#1274)Tim Hutt1-0/+278
This switches from using Sail's C output to using C++. The output code gets wrapped in a `class`, which means we can create more than one instance of it (e.g. for multicore). The `Model` class is currently *not* thread safe due to the use of temporary globals in `sail.c`. So although you can simulate multicore systems, you have to execute them one at a time. The handling of platform callbacks is a little convoluted but I think this is a quite flexible solution. Sail is instructed to derive the `Model` class from `PlatformImpl` which has virtual methods for all of the platform callbacks with default nop implementations. This means the default `Model` can be constructed and has a "nop" platform. Then we add our implementation of the platform with `ModelImpl` which overrides those methods. `ModelImpl` also allows registering callback receivers. This is not 100% perfect yet. We still have a global `g_model`, which is not ideal. --------- Signed-off-by: Tim Hutt <tdhutt@gmail.com> Co-authored-by: Tim Hutt <timothy.hutt@codasip.com> Co-authored-by: Nadime Barhoumi <nadime@riscv.org>