Commit graph

902 commits

Author SHA1 Message Date
Elliot Baptist
6b88138a90 [dv] Fix typos 2025-06-27 11:09:24 +00:00
Harry Callahan
f0d408a546 [fcov] Add fcov for the interaction of pmp with debug module accesses
Accesses to the debug module in debug mode should never be denied by the PMP
unit. This commit implements fcov to confirm we have stimulated this particular
behaviour in relevant related states.

Illegal bins are used for incorrect behaviour (e.g. denied access in debug mode)
Other behaviours such as debug module accesses outside of debug mode are left as
ignore_bins for now. This is not explicitly disallowed by the specification, and
our implementation does not have any opinion about its validity, but external
debug modules opine that it should not be allowed. We could possibly expand the
stimulus in the future to test this condition, but it is low priority.
2025-06-24 16:47:59 +00:00
Harry Callahan
db07ab174e Change '/bin/bash' shebangs to '/usr/bin/env bash'
This improves portability across different unix-like operating systems
by using bash from the PATH, instead of bash from a hardcoded location.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2025-06-23 10:48:34 +00:00
Marno van der Maas
125445f692 [dv/formal] Warning fixes
Some minor warning fixes in the top check file.
2025-05-16 13:21:42 +00:00
Marno van der Maas
a8b07c4e49 [dv/formal] Alt LSU undefined in and out
Resolve undefined inputs and unconnected outputs as well as removing
signals that were not used or driven in the first place.
2025-05-16 13:21:42 +00:00
Marno van der Maas
299eea6226 [dv/formal] Memory protocol rearranged
This commit has no functional changes, but it just rewrites the
mem_assume_t interface to improve clarity.
It also puts the error assumption inside the interface instead of
outside.
2025-05-16 13:21:42 +00:00
Marno van der Maas
fa84591215 [dv/formal] FetchErrRoot proven with engine Hp
This adds an annotation to the verify script that you should use Hp as
an engine to prove FetchErrRoot. It is proven in Hp 3.
2025-05-12 08:46:58 +00:00
Marno van der Maas
0b718c5eac [dv/formal] Helpers for DivInstrStable
To make the proof of DivInstrStable, this commit adds two helper
properties in the previous step. One that when an instruction is not a
multiply that the multiplier state must never leave ALBL and one that
the writeback stage must have a valid instruction in it if it is
blocking an instruction from proceeding from EX to WB. This allow
DivInstrStable to be proven with Hp 2.
2025-05-12 08:46:58 +00:00
Marno van der Maas
4fe6b7d53f [dv/formal] Performance improvement for divide PC
The MType_{Div,DivU,Rem,RemU}_PC properties were proving very slow
before this. They were proving with Hp 45, which was very slow. This
change groups them together so that the engines can help each other out,
the N engine helps with proving these properties much faster than with
Hp alone. In the long-term it is better to capture a relavant assumption
in the proof files instead of putting this in the TCL script.
2025-05-09 10:20:03 +00:00
mndstrmr
50e7331f42 [dv,formal] Remove patches, better proof script
The old patchfile disabled clock gating and set ResetAll = 1.
We don't need either of these things any more with some minor
invariant tweaks. This also improves the proof script, which
should be faster now.
2025-04-30 13:30:45 +00:00
Gary Guo
10270b6e9a [dv,formal] constrain CSR values for mvendorid and mimpid
These values were originally constants but now are parameters.
Constrain them for formal.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-04-30 13:30:45 +00:00
Gary Guo
2c2dc5040f [dv,formal] FirstFetchNoInstr helper property for FetchErrRoot
FetchErrRoot is very slow to prove, and via SST I discovered that it
was exploring the state space where ctrl FSM is in FIRST_FETCH, and
there was a memory load instruction latched by IF, and it causes the stall
logic to think there is a memory-induced stall.

This is unreachable state because in FIRST_FETCH there can't be instructions
latched, so add a helper property to aid the proof.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-04-30 13:30:45 +00:00
Gary Guo
f79e858c81 [dv,formal] do not assume on MType assertions
M extension is not currently proven. This should be disabled rather than
assumed as otherwise its property might be used to prove other
properties in the same step (and thus not performing actual work).

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-04-30 13:30:45 +00:00
Marno van der Maas
abaed83dbf [dv,formal,doc] Formal README revision
This includes renaming Jasper Gold to just Jasper

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2025-04-30 13:30:45 +00:00
Harry Callahan
cea3d04caf [dv,formal,nix] Use Nix to setup formal development and test environment
Adds a Nix environment which provides a development shell for the formal
verification flow. All dependencies are fetched and built upon entering the
shell (nix develop .#formal), except for the proprietary Cadence Jasper.

The dev shell (nix develop .#formal-dev) is identical to the normal
shell, but prints some information on how to swap out components. This
is also documented in the README.

Documentation on how to use this environment is added to the dv/formal/README.md
The provided Makefile/.tcl scripts make assumptions about the environment
they are run within which are provided by the Nix environment. Using Nix is
the recommended way to run this flow, but if you cannot do this, you will need
to duplicate the setup done by Nix in terms of environment variables and
provided dependencies.

Jasper Gold options:
- allow_unsupported_OS is required on both the machines I use.
- acquire_proj means that if JG is killed (which happens somewhat
  often) the next it runs it will still be able to take ownership
  of the project.

Co-authored-by: Louis-Emile Ploix <louis-emile.ploix@lowrisc.org>
Co-authored-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
Co-authored-by: Gary Guo <gary.guo@lowrisc.org>
Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2025-04-30 13:30:45 +00:00
Harry Callahan
293b4bccac [dv,formal] Add a fusesoc flow for generating the fileset
This lets fusesoc do the heavy lifting in identify the correct files for us.
Fusesoc is already extensively used for this purpose for synthesis and simulation.

As part of this step, apply RTL patches that work around some current
restrictions in the formal flow to the /build fileset copied by fusesoc.

Co-authored-by: Gary Guo <gary.guo@lowrisc.org>
Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2025-04-30 13:30:45 +00:00
Louis-Emile
c0636dcbde [dv,formal] Add flow for formal equivalence checking with Sail
Here's a high-level overview of what this commit does:
- Compiles Sail into SystemVerilog including patchin compiler bugs
- Create a TCL file that tells JasperGold what to prove and assume
- Check memory operations modelling the LSU
  Most of these properties now prove without time-bound on the response
  from memory due to alternative LSUs
- Check memory even with Smepmp errors:
  Continues on top of https://github.com/riscv/sail-riscv/pull/196
- CSR verification
- Checks for instruction types such as B-Type, I-Type, R-Type
- Check illegal instructions and WFI instructions
- Using psgen language for proof generation
- Documentation on how to use the setup
- Wrap around proof that proves instructions executed in a row still
  match the specification.
- Liveness proof to guarantee instructions will retire within a upper
  bound of cycles.

All of these proofs make heavy use of the concept of k-induction. All
the different properties and steps are necessary to help the tool get
the useful properties it needs to prove the next step. The instruction
correctness, wrap-around and liveness all give us increased confidence
that Ibex is trace-equivalent to Sail.

Throughout this process an issue was found in Ibex where the pipeline
was not flushing properly on changing PMP registers using clear: #2193

Alternative LSUs:
This makes all top level memory properties prove quickly and at a low
proof effort (1 or 2-induction). Three 'alternative LSUs' representing
three stages of memory instructions:
1. Before the first response is received, in the EX stage
2. After the first response is received, but not the second grant,
also in the EX stage
3. Before the last response is received in the WB stage.
In each case we ask 'if the response came now, would the result
be correct?'. Similar is applied for CSRs/PC though less directly.
This is particularly interesting (read: ugly) in the case of a PMP error

wbexc_exists makes Wrap properties fast to prove. The bottleneck becomes
SpecPastNoWbexcPC, which fails only due to a bug. See the comment
in riscv.proof.

Co-authored-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
Signed-off-by: Louis-Emile Ploix <louis-emile.ploix@lowrisc.org>
2025-04-30 13:30:45 +00:00
Samuel Riedel
f0c6f76be7 [cosim] Disable Verilator's IMPERFECTSCH warning 2025-04-25 11:19:27 +00:00
Andreas Kurth
594ea976c9 [dv] Plan test for DM accesses in debug mode
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2025-04-03 08:48:00 +00:00
Greg Chadwick
60fbb6ba2f [cosim] Update comment on set_mip in Cosim interface
The concept of pre and post MIP values was introduced a while ago but
the comments in the interface weren't updated to explain what they are.
2025-02-18 16:56:40 +00:00
Priyanshu Mishra
8f4c75c5e4 Update core_ibex_pmp_fcov_if.sv 2024-12-20 12:09:26 +00:00
Andreas Kurth
a05d4d825c [rtl,pmp] Allow all accesses to Debug Module in debug mode
The RISC-V Debug Specification (current release 1.0.0-rc4) in Section
A.2 states that the PMP must not disallow accesses to addresses of the
Debug Module when the hart is in debug mode, regardless of how the PMP
is configured.  This commit changes the PMP accordingly.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2024-12-19 10:42:48 +00:00
Marno van der Maas
88d27a0944 ibex_pcounts: resolve uninitialize warning
Although the current code isn't wrong as far as I can tell, it would be
better to initialize the lognest_name_length variable when it is
declared to avoid a build warning with older Verilator versions.
2024-12-18 16:05:47 +00:00
Harry Callahan
fb49826c16 [dv] Cleanup some code in the compile_tb.py module
Add comments, and move some variable declarations around to be closer to their use.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2024-10-01 15:21:40 +00:00
Harry Callahan
8e77bb39d5 [dv] Tweak ISS linker arg construction for Xcelium
The previous code here was a bit too hacky, so implement a solution that
directly follows the suggestion in the Cadence support article.
An example was also added to make it clear what this transformation is
achieving.

Add some more typehints, and cleanup names.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2024-10-01 15:21:40 +00:00
Elliot Baptist
4ed20f4ac3 Update more documentation links 2024-09-19 08:57:07 +00:00
Gary Guo
03ba286570 Fix icache regression failure on VCS
It appears that VCS require expression after `iff` to be wrapped inside
parenthesis otherwise it will complain about syntax error.

This should fix the weekly VCS regression.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2024-08-26 14:44:27 +00:00
Greg Chadwick
96a1c02ba0 [dv] Increase iterations and instructions in riscv_rf_intg_test
This enables more scenarios begin stimulated per regression run around
RF ECC errors.
2024-07-15 22:02:06 +01:00
Greg Chadwick
6ac0ddc46e [dv] Alter riscv_rf_intg_test to cover more scenarios
Previously the riscv_rf_intg_test skipped certain scenarios where an ECC
error from the register file should trigger an alert. This change stops
it from skipping those scenarios.
2024-07-15 22:02:06 +01:00
Greg Chadwick
668233699d [dv] Add spurious responses to memory agent
A spurious response is one that isn't associated with any on-going
request. With this new feature the memory agent can generate them
randomly when the interface is idle (i.e. there are no outstanding
requests).
2024-07-04 22:51:30 +00:00
Pascal Nasahl
0e0f27ad14 [dv] Add riscv_ram_intg_test
This test injects a fault into different MuBi encoded signals within
the prim_ram_1p_scr and prim_ram_1p_adv and checks whether a fatal
alert is triggered.

I have excluded the addr_match signal from FI as its encoding
is not directly checked. If the signal was a MuBi True, a
fault into it is treated by the mubi4_and_hi as a False.
If the signal was a MuBi False, a fault into it is treated
by the mubi4_and_hi also as a False. Hence, no address
collision occurs and the holding register is not returned.

This PR is based on #2182 and closes #2173.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-07-04 10:58:40 +00:00
Greg Chadwick
3384bf4c42 [cosim] Clang lint fix 2024-07-03 15:31:44 +00:00
Greg Chadwick
470b39a2a2 [dv] Output warning message on problematic MIP changes
When an interrupt is raised the Ibex controller will move from the
DECODE state to the IRQ_TAKEN state when it chooses to handle the
interrupt. When in IRQ_TAKEN it's possible for the interrupt state to
change again which aborts the interrupt entry. This leads to mis-matches
against cosim.

This change adds a warning to flag up cases where this has occurred to
enable quick triage of failures related to this scenario.
2024-07-03 15:31:44 +00:00
Greg Chadwick
65a7231a29 [cosim] Correctly deal with checking top of range memory accesses
The cosimulation environment does not know if a memory access from spike
is due to an instruction fetch or a data memory access. It uses a
heuristic to differentiate the two. Any access between the PC and the PC
+ 8 is considered an instruction fetch.

This heuristic did not correctly handle addresses at the top of the
range where the PC + 8 calculation overflows. This commit fixes the top
of range handling.
2024-07-03 15:31:44 +00:00
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
89f4d86719 [dv] Fix exception_stall_instr_cross illegal bins 2024-07-03 15:31:44 +00:00
Greg Chadwick
2c132113c0 [dv] Add riscv_rf_ctrl_intg_test
This tests new hardening added to the register file around read and
write control signals.
2024-07-03 14:21:10 +00:00
Greg Chadwick
1449ed5ea8 [dv] Add cover points for memory interface behaviour 2024-06-21 11:18:41 +00:00
Greg Chadwick
604ba343bb [dv] Fix race condition in ibex_mem_intf_agent
Previous code working with clocking blocks synced to the raw clock
event. Instead they should sync to the clocking block event. This
ensures the values being read are the latest values rather than a cycle
old.

In particular for ibex_mem_intf_agent this meant it was unable to
produce a single cycle response to any memory transaction. With this fix
these are now observed.
2024-06-21 11:18:41 +00:00
Pascal Nasahl
d019dccb4b [dv] Remove phase argument from collect_trans
This commit applies the patch from lowRISC/opentitan@18b0ced to the Ibex
repository.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
957529c4bd [dv] Add mubi and prim_count pkg to DV environment
With the latest update in vendor/lowrisc_ip, two additional packages
need to be imported.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
5cea5d65c3 [rtl] Add error port to iCache
This commit adds the error port to the iCache which was introduced
with lowRISC/opentitan#23292.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
0b0b01006c [rtl] Update RAM ports inside ibex_top
This commit updates the RAM ports inside ibex_top to reflect recent
changes introduced with lowRISC/opentitan#23212 (SRAM readback mode).

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
James Wainwright
c1139477dc Add missing copyright headers
Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
2024-03-28 08:41:30 +00:00
Rupert Swarbrick
621b89969a [simple_system] Bump C++ version in core files
This sets the C++ standard that's being used for a compiler that's
building a Verilator simulation. Recent versions of Verilator (since
5.020) require the compiler to be in C++14 mode, so passing -std=c++11
breaks the build with them.

Looking at history, -std=c++14 has been supported since GCC
6.1 (released in 2016), so I don't think this argument is going to
cause any tooling problems.
2024-03-27 17:48:25 +00:00
Greg Chadwick
eb668b064b [dv] Output VCS simulation log to file
The DV flow is expecting log files to be produced with a particular file
name, without it the reporting mechanisms do not work correctly. This
adds VCS log output to a named rather rather than just capturing stdout.
2024-03-07 15:20:43 +00:00
Greg Chadwick
926a9865d9 [dv] Add flag needed to allow force under VCS
Tests targetting security features make use of force to corrupt values.
Under VCS this requires building with a particular flag.
2024-03-07 15:20:43 +00:00
Greg Chadwick
6bdbcfabf2 [dv] Fix use of plusargs
Previously some $value$plusargs calls weren't explictly specifying a
format for a number to read from the plusarg. Under some simulators this
is acceptable under others it generates an error.
2024-03-07 15:20:43 +00:00
Greg Chadwick
5db718c153 [fcov] Fix illegal bins related to stall types
An instruction stall on a FENCE.I had been mistakenly placed in an
illegal bin. A FENCE.I acts much like a branch or jump so can produce
instruction stalls just as those instructions can.
2024-03-07 15:20:43 +00:00