Commit graph

21 commits

Author SHA1 Message Date
Greg Chadwick
e784d27464 [dv] Update testbench to use new 'pre_val' MIP
The 'pre_val' MIP addresses the scenario where MIP changes as an
instruction is excuting, this means a CSR instruction can observe a
different MIP from the one that decides whether or not that instruction
will be interrupted.
2024-07-03 15:31:44 +00:00
Greg Chadwick
3964804815 [dv] Fix model mismatches in cases where an access crosses PMP regions
Where an access is unaligned Ibex splits it into two transactions, each
of which undergoes a PMP check. It is possible for the first half to
fail a PMP check and the second to succeed and hence produce a request
on the memory interface.

In Spike it accesses memory byte by byte and if it encounters a PMP
error for a particular byte it won't try any further bytes.

This results in a mis-match between Ibex and spike when an unaligned
transaction is split across two PMP regions, one of which allows the
access and the other doesn't. Ibex generates a transaction and spike
doesn't producing an error.

This adds a fixup into the co-simulation environment. It detects when we
have an access that fails PMP that is misaligned. Where this has
resulted in Ibex producing a memory request that spike would not we
remove it from the list of memory requests to check after checking that
the request passes PMP within spike.
2024-07-03 15:31:44 +00:00
Greg Chadwick
126f9c3450 [cosim] Fix SIGSEGV in ~SpikeCosim
When SpikeCosim is getting destructed a SIGSEGV was observed on CentOS
7. The root cause hasn't been identified other than it relates to the
deletion of `isa_parser_t`, potentially some kind of use after free
error.

This is an (optional) hacky workaround that simply never deletes the
`isa_parser_t` pointer in SpikeCosim. As in practise this occurs at the
end of simulation when the process is terminating the memory leak is of
little consequence.

Longer term this issue should be investigated and properly fixed.
2024-03-07 15:20:43 +00:00
Greg Chadwick
1120e8ddbf [dv] Improve interrupt signalling to cosim
Previously any changes in interrupt state or debug requests were
strictly associated with retired instructions. This causes cosim
mismatches where a lower priority interrupt occurs in time before a
higher priority interrupt or debug request but between instruction
fetches/retirements so both the low and high priority interrupts are
signalled with the instruction retirement.

This introduces a way for the RVFI to signal an interrupt has occurred
that isn't associated with an instruction retirement to allow the cosim
to see the seperation in time between different interrupts and debug
requests and hence model behaviour correctly.
2023-04-27 12:04:22 +00:00
Greg Chadwick
346eacb46c [cosim] Add write suppress support
When Ibex does a load that receives data with bad integrity it
suppresses the write to the destination register. The implements
matching functionality for cosim.
2022-11-07 16:24:48 +00:00
Canberk Topal
715292ce55 [cosim] Cosim integration of internal NMI
This commit is mainly an extension to cosim environment to drive the newly
introduced state variable `nmi_int` in Spike.

This commit
 - Extends RVFI interface by a single bit (ext_nmi_int)
 - Configures cosim to set nmi_int inside Spike

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Greg Chadwick
980f73b047 [cosim] Fixup ebreak behaviour
When DCSR is set such that ebreak will enter debug mode we were getting
cosim mismatches. This was because Ibex produces the ebreak on the RVFI
interface and spike effectively skips right over it and executes the
first instruction of the debug handler immediately. Traps have similar
but not identical behaviour so we need a special case in the step
function to handle this.
2022-10-31 16:15:09 +00:00
Greg Chadwick
4effc487e0 [cosim] Implement double fault detection
This adds an implementation of the double_fault_seen and sync_exc_seen
fields in cpuctrlsts.
2022-10-22 20:30:49 +01:00
Canberk Topal
e27deb1015 [dv] Add MHPM Counter number param to SpikeCosim
This commit adds another field in SpikeCosim class so that Spike
can hardcode the correct event registers.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-11 15:52:42 +01:00
Greg Chadwick
4084dc4a46 [cosim] Fix spike cosim instruction count
The count wasn't being initialised in the constructor and should be of
type 'unsigned int'.
2022-09-30 09:41:07 +01:00
Greg Chadwick
70186c57ae [rtl] Add ic_scr_key_valid field to CPUCTRL (renamed CPUCTRLSTS)
The ic_scr_key_valid field indicates whether the ICache scrambling key
is valid.

CPUCTRL is also renamed CPUCTRLSTS as it contains both control and
status bits.
2022-09-22 16:17:31 +01:00
Greg Chadwick
95e0947e77 [cosim] Fix various CSR mismatches
This sets the initial values of a few CSRs in spike to match Ibex. It
also adds an mcause fixup so we get WARL behaviour matching Ibex.
2022-08-30 13:12:11 +01:00
Greg Chadwick
7e9eef2cf9 [cosim] Pass PMP configuration through to spike 2022-08-11 17:43:34 +01:00
Harry Callahan
8beddf5e8a Rework spike_cosim::step() to handle exception on 1st ISR instr
Seperate concerns so the flow of stepping spike and checking against
the ibex RVFI data is clearer. One 'step' of either system produces
different amounts of progress, and this conditional-checking-and-stepping
is needed to tie up the flows.
2022-07-25 22:27:47 +01:00
Canberk Topal
1e613cc7f4 [cosim,dv] Add support to set mcount registers
Extends RVFI connections further to include 30 mhpmcounterX registers.
Sets them up before every cosim step to let Spike know their real values.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-25 08:51:31 +01:00
Pirmin Vogel
e1f614887e Update spike_cosim.cc to be able to build against newer Spike versions
This works with versions ibex-cosim-v0.2 and ibex-cosim-v0.3. The latter
version is required to support the mseccfg CSR added with ePMP.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-06-01 00:50:49 +02:00
Rupert Swarbrick
9f14922382 [dv] Construct ISA string from RTL parameters for cosim tests 2022-02-17 16:06:53 +00:00
Greg Chadwick
cedabf062a [dv] Add recoverable NMI handling to cosim
Ibex implements a custom recoverable NMI handling scheme. This adds
modeling of it to the cosim.
2021-12-09 14:08:05 +00:00
Greg Chadwick
b57cad5387 [dv] Add matched instruction count to cosim 2021-11-12 09:39:38 +00:00
Greg Chadwick
c10b56ed17 [dv] Adjust cosim include paths
Some Spike include files can clash with libelf include files. Avoid
directly adding riscv and fesvr directories to include path to prevent
this.
2021-11-12 09:39:38 +00:00
Greg Chadwick
648fadb34a [dv] Add co-simulation framework 2021-10-15 11:30:35 +01:00