Commit graph

2832 commits

Author SHA1 Message Date
Elliot Baptist
f0a57f0c7c [examples] Fix typos 2025-06-27 11:09:24 +00:00
Elliot Baptist
bd2599387f [rtl, syn] Fix typos 2025-06-27 11:09:24 +00:00
Elliot Baptist
6b88138a90 [dv] Fix typos 2025-06-27 11:09:24 +00:00
Elliot Baptist
41c2fd8d90 [doc] 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
0613e7850c [rtl] Split pmp_req_err_o logic to allow easier binding for fcov 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
Pascal Nasahl
71a1fc6af4 [syn] Add keep_hierarchy constraints to prim_generic
Some FI countermeasures in Ibex use redundancy to detect fault attacks
(e.g., the onehot encoding & checker in the RF). As synthesis tools
are great in detecting redundant logic and reducing it, this commit
puts a keep_hierarchy synthesis constraint on prim_generic* modules.
This is exactely the purpose of the prim_generic_buf, prim_generic_flop,
and prim_generic_and2 modules - having synthesis barriers to avoid
optimizations.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2025-06-10 05:22:16 +00:00
Pascal Nasahl
a92221ae22 [syn] Enable synthesis for SecureIbex config
This commit adds the new `ibex_secure_ibex` variable that allows
the user to configure whether the SecureIbex configuration is
synthesized. By default, the non-SecureIbex version is
synthesized.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2025-06-10 05:22:16 +00:00
Robert Schilling
0d1b172325 [ibex] Pass mvendorid and mimpid also to lockstep core
Otherwise an alert is raised if a core has a different
configuration than zero. There, the primary core would
return the non-zero value but the lockstep core zero.
This difference causes an alert.

This PR fixes this bug and passes the mvendirid and mimpid
parameters also to the lockstep core so that they are in sync

Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
2025-05-30 11:39:44 +00:00
Andreas Kurth
9156029e77 [ci] Use non-default mirror of package repositories
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2025-05-30 11:39:22 +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
Adrian Lees
8140d8689e [simple_system] Use correct RAM base address and size
Correct the base address and size of the RAM memory model
within the simulator environment. Previously the error in
the RAM size was masking the incorrect base address (zero)
and it simulated as intended but could fail if the base
address and/or RAM size were modified.
2025-05-15 12:53:29 +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
Harry Callahan
8a3d46f095 [doc] Update cosim.rst to point to current spike cosim branch 2025-05-01 00:53:59 +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
Robert Schilling
0369438105 [ibex] Pass mvendorid and mimpid as top-level params
Instead of using default values from a package, create a top-level
parameter to define these and pass them down. This allows integrators
to specify them on a per-instance basis.

Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
2025-04-25 13:28:44 +00:00
Rupert Swarbrick
0199c03ea4 [rtl] Minor tweak to decoder to avoid dead code
The "else" part of the if/else check here wasn't possible because the
surrounding else branch (starting at line 406) is already in the case
where instr[26] is zero.
2025-04-25 12:43:52 +00:00
Samuel Riedel
00a6f2fcd7 [ibex] Remove workarounds for Verilator's IMPERFECTSCH warning 2025-04-25 11:19:27 +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
Hao
2678654820 fix: Illegal instruction display message
When encountering certain illegal compressed instructions, incorrect instruction information was displayed. Now, illegal instructions can be printed correctly.
2025-03-26 15:46:21 +00:00
Marno van der Maas
6e466c1504 Verification should be done with ibex_cosim branch
This resolves comment: https://github.com/lowRISC/riscv-isa-sim/pull/25#issuecomment-2655147799
2025-02-26 11:05:04 +00:00
Gary Guo
9e99ec79e2 [ci] switch CI runner from Ubuntu 20.04 to 22.04
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-02-19 17:15:26 +00:00
Gary Guo
eba210965a [ci] update verible version to match OT
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-02-19 17:15:26 +00:00
Gary Guo
fa40368300 [ci] remove Azure Pipelines magic commands
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-02-19 17:15:26 +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
Greg Chadwick
d53035bf64 [rtl] Remove low utility assertions
This removes several assertions from `ibex_controller`. They aimed to
ensure that controller behaviour was correct on exception behaviour
(e.g. ensuring that a pending interrupt will actually trigger an
interrupt). However they've proved to be flaky and hard to maintain with
multiple edge cases needing to be accounted for.

The co-simulation checking in functional verification will catch the
same issues these assertions catch. The assertions (when working
correctly) would cause a failure directly when the bug happens which
makes debugging easier. However they've added significant effort in
regression triage due to their many false failures so it's not worth the
maintenance burden.

Within formal they don't really add any value now we have the full
end-to-end formal flow.
2025-02-18 16:49:01 +00:00
Greg Chadwick
0f27580cf6 [rtl] Flush pipe on all CSR modifications
This fixes #2193, an issue that meant bit clears in PMP related CSRs
didn't immediately apply to an instruction already in the fetch stage
due to a lack of a pipeline flush.

With this change the pipeline will flush in that scenario, fixing the
issue. It now flushes the pipeline on all CSR modifications as this
makes the pipeline more resliant against similar issues in the future
(where the list of CSRs to flush on should have been updated but
wasn't).
2025-02-17 14:47:28 +00:00
Greg Chadwick
e66df4d49a [rtl] Read csr_addr direct from instruction
Previously the ibex_cs_registers module received the CSR address via the
operand muxes. This has been observed to cause timing issues in some
cases. The CSR address is always read from the same bits of the
instruction so there's no need to go via the operand muxes. With this
change the relevant instruction bits are fed straight out of the decoder
and into the ibex_cs_registers module.
2025-02-17 14:47:28 +00:00
Rupert Swarbrick
78739562ce [ibex_core] Fix assertion when SecureIbex is false
This assertion wasn't quite correct if SecureIbex is false because it
was checking for the magic IbexMuBiOn value instead of just looking at
the bottom bit.

Fixes #2249.
2025-01-24 12:49:45 +00:00
Rupert Swarbrick
cecf4fd2df [ibex_register_file_fpga] Drop two confusing comments
These were noticed by someone responding to issue #2230. I think the
author's original logic was to point out that there's a path from e.g.
raddr_a_i to rdata_a_o which doesn't depend on any clock, so is
"asynchronous".

But that's the same in the other modes and also for the other register
file implementations, which don't have analogous comments.

Drop these ones.
2025-01-23 19:27:35 +00:00
Katharina
591c3812f9 Fix typo in comment in ibex_id_stage.sv 2025-01-16 19:17:50 +00:00
Robert Schilling
5da1679f36 [ibex_tracer] Use static variables in always/final blocks
Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
2025-01-10 13:17:17 +00:00
Rupert Swarbrick
4d722d3308 [rtl] Drive oh_raddr_*_err if RdataMuxCheck=0
These errors aren't detected or reported if the mux is disabled, but
the RTL didn't actually drive them at all.
2025-01-07 09:38:11 +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
Andreas Kurth
8b82e89719 [controller] Add assertion on pipeline flush when entering debug mode
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