Commit graph

617 commits

Author SHA1 Message Date
Elliot Baptist
bd2599387f [rtl, syn] Fix typos 2025-06-27 11:09:24 +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
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
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
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
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
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
Pascal Nasahl
667fd20d2e [rtl] Fix non-DSP reset in ibex_counter
When targeting Xilinx FPGAs, we utilize a DSP for counters
with a width of less than 49-bit. In this case, a sync. reset
is needed. However, currently, there is a bug in the RTL
where also a sync. reset is used for the non-DSP counters
on the FPGA.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-12-06 14:55:01 +00:00
Pascal Nasahl
0945aa84c6 Revert "[rtl] Fix counter reset value on FPGA"
This reverts commit 54985d21b0.
2024-12-04 00:06:01 +00:00
Pascal Nasahl
54985d21b0 [rtl] Fix counter reset value on FPGA
If the counter width is >= 49, we do not use a DSP on the FPGA.
Then, we should use an asynchronous reset to initialize the counter.

This bug was detected when enabling the lockstep for the CW340. A
lockstep mismatch happend as the mcycle counters of the main and
shadow core did not match due to this bug.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-11-29 10:43:32 +00:00
Pascal Nasahl
84232a5bfa [rtl] Fix zero value in FPGA RF
We should use `WordZeroVal` instead of `0` for reads from register `x0` in the
FPGA register file.

This bug was discovered when enabling the `RegFileECC` parameter. When this is
enabled, the core performs ECC checks, expecting that `WordZeroVal` is returned
for `x0`. Else, we get a major alert.

Fixes lowRISC/opentitan#25146

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-11-18 13:35:35 +00:00
Robert Schilling
f92d599e00 [pmp] Use top-level straps for PMP reset values
By using top-level straps for the PMP reset configuration its
easier to implement different reset configurations if there are
multiple Ibex cores in the system.

Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
2024-09-23 10:28:57 +00:00
Pascal Nasahl
2617c43c0a [rtl] Fix wrong address in latch RF
This commit fixes a typo that used the wrong read address (raddr_b
instead of raddr_a) for port A.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-09-17 14:25:27 +00:00
lingscale
53888bcdf4 [rtl] fix a typo. 2024-08-28 10:19:17 +00:00
Greg Chadwick
38c0709391 [rtl] Remove ECC related data_rdata_i -> instr_X_o feedthroughs
Prior to this commit an ECC failure on the incoming data memory response
factored directly into the outputs for the instruction memory
interfaces. This existed due to a desire to take an NMI on an ECC
failure as soon as possible but causes timing issues so it has been
altered.

Now rather than directly raise the NMI the same cycle the assertion of
'irq_nm_int' is delayed by a cycle which breaks the feedthrough path.
2024-08-23 20:31:14 +00:00
Greg Chadwick
9e4a950aa6 [rtl] Fix logic for generating ECC related alerts
Under certain circumstances Ibex ignored the ECC check from the register
file when it should not have. This fixes the issue.

Fixes #2188
2024-07-15 22:02:06 +01: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
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
Greg Chadwick
5977d4e3a0 [rtl] Guard against false memory responses for secure configurations
With this change all memory responses are only acted on if Ibex is
expecting them for all secure configurations. Previously an error
response that was injected onto the bus would trigger an exception that
shouldn't occur (in particular breaking the functioning of the multiply
state machine). In addition for configurations without the writeback
stage an injected load data response could trigger an incorrect write to
the register file.

This is only applied to the secure configurations, non-secure
configurations assume correct adherence to the bus protocol meaning a
response will only be seen if a request is outstanding.
2024-06-04 10:00:34 +00:00
Pirmin Vogel
eea2bf0c1c [rtl] Expose ICacheScrNumPrinceRoundsHalf parameter
This parameter allows integrators controlling the number of PRINCE
half rounds in the scrambled ICache SRAM primitives, e.g., to balance
timing impact and security guarantees.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2024-05-02 19:39:48 +00: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
Greg Chadwick
27dd6b2e06 [rtl] Update use of prim_count following port changes
The latest version of `prim_count` from OpenTitan introduces a
`commit_i` input. To retain the behaviour of the previous `prim_count`
this should be set to a constant 1.

The `cnt_next_o` output has been renamed to `cnt_after_commit_o`.
2024-03-01 10:18:25 +00:00
Adrian Lees
5a8a1a9993 [tracer] Fix reporting of load/store data
Modify tracer to use the appropriate read/write masks when logging
load/store traffic from the Load Store Unit.

Signed-off-by: Adrian Lees <a.lees@lowrisc.org>
2024-02-17 20:43:01 +00:00
Pascal Nasahl
8ec0c6f18e [rtl] Harden lockstep enable against FI
Currently, the dual-core lockstep FI mitigation is enabled/disabled
using a single bit.
For transient bit-flips, this is not problematic, as one bit-flip
into this signal and one bit into the Ibex is required to threaten
the security of the system.

However, a permanent stuck-at-0 fault could disable the lockstep
completely by targeting this signal. Then, only a single, additional
fault (transient or permanent) is required.

This PR enhances the FI resilience of the Ibex lockstep by encoding
this single bit into a ibex_mubi_t signal, i.e., a 4-bit multi-bit
signal.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-01-23 09:14:45 +00:00
Michael Schaffner
56413ecf10 [icache] Disable S&P diffusion layer in memory scrambling
Signed-off-by: Michael Schaffner <msf@opentitan.org>
2024-01-19 03:24:48 +00:00
Pascal Nasahl
35bbdb7be3 [rtl] Fix FI vulnerability in RF
As described in #20715, a single fault-induced bit-flip inside the
register file could change which of the register file value is
provided to Ibex.

This PR fixes this issue by (i) encoding raddr_a/b to one-hot
encoded signals, (ii) checking these signals for faults, and
(iii) using an one-hot encoded MUX to select which register file
value is forwarded to rdata_a/b.

Area increases by ~1% (Yosys + Nangate45 synthesis).

I conducted a formal fault injection verification at the Yosys
netlist to ensure that the issue really is fixed.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-01-04 15:26:32 +00:00
Rupert Swarbrick
d097c918f5 [rtl] Avoid name collision in ibex_pmp.sv
Recent versions of Verilator complain about the code that was there
because the csr_pmp_cfg argument clashes with a name in ibex_core.sv.

What's more, they mean different things! In ibex_core.sv, it was the
PMP configuration for the entire core. In the functions, it's the PMP
configuration for a single region. This patch adds a "region_" prefix
to the names, which fixes both the Verilator warning and my confusion!
2023-12-05 15:18:40 +00:00
Rupert Swarbrick
fe84d64d79 [verilator] Slight refactor in ibex_tracer to avoid BLKSEQ warning
The existing code wanted to open file_handle as a trace file if
necessary and then use it on that clock cycle. So it (sensibly) used a
blocking assignment.

Verilator now warns about blocking assignments to globals in
"sequential logic processes" (the always_ff that is driving
everything). This is sort of easy to fix: just use an "always" block!

This commit looks slightly more involved because I've changed things
to pass the file handle to printbuffer_dumpline as an argument. It
makes the state update (where we open the file handle) a little easier
to follow.
2023-11-22 09:46:03 +00:00
Michael Schaffner
bac72d96ec [ibex_pmp/lint] Declare functions before using them
Signed-off-by: Michael Schaffner <msf@opentitan.org>
2023-10-19 07:58:30 +00:00
Greg Chadwick
1084ac118e [dv] Add asserts to check alerts for memory integrity failures 2023-05-15 13:51:06 +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
5e3474c9da Remove TODOs
- rvfi_trap now correctly handled for writeback
 - issue created to track coverpoint for pmpcfg reserved bits writes.
 - flush pipe on debug CSR writes is reasonable
2023-04-25 14:23:34 +00:00
Saad Khalid
6e4352af10 Fixed capture info for spike cosim in case of multiple interrupts
Signed-off-by: Saad Khalid <saad.khalid@lowrisc.org>
2023-04-13 17:30:33 +00:00
Greg Chadwick
e58a9ff792 [rtl] Add missing `include to ibex_if_stage
The include is needed for a FCOV related macro. Lack of this include can
cause issues in some simulators.
2023-04-11 14:22:05 +00:00
Flavien Solt
43aeda171d Avoid explicit module names references to signals
This allows changing the module names without breaking the sim flow.
2023-03-10 14:47:17 +00:00
Greg Chadwick
381fc845ba [rtl] Fix MISA X bit for balanced bitmanip config
All RV32B configs include non-ratified sub-extensions so the 'X' bit
MISA must be set for all of them.
2023-03-02 10:15:34 +00:00
Andreas Kurth
911a6735b9 [rtl/dv] Add assertions for icache scramble keys
This commit adds two assertions in `ibex_top` to ensure that the
scramble key is correctly applied to the icache scrambled memory
primitives.  Those assertions previously existed in the module that
instantiated Ibex in OpenTitan, but the reference into the generate
loops was problematic for some EDA tools; see lowRISC/opentitan#17155.

Additionally, the assertions previously used the input scramble key
(`scramble_key_i`) even though they tolerated a delay after which the
input scramble key was not necessarily valid anymore (i.e.,
`scramble_key_valid_i` could go low and `scramble_key_i` could take any
value).  This mistake has been corrected by sampling the input scramble
key for the assertions when it is valid and using the sampled value in
the comparison of the assertions.  This problem surfaced in the DV
environment of Ibex (but not in OpenTitan), where multiple tests
(including `riscv_rand_instr_test`, `riscv_mem_error_test`, and
`riscv_multiple_interrupt_test`) failed; these tests now pass.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2023-01-31 17:59:50 +01:00
Pirmin Vogel
590d196e62 [rtl] Improve FI hardening around data_rvalid_i
Previously, it was possible to glitch data_rvalid_i at the interconnect
level and if the data integrity bits happened to be valid, Ibex would
write the current data_rdata_i into the register file even if it wasn't
doing a load. Since the glitch is inserted at the interconnect level,
both the main and the shadow core are affected equally.

This commit changes the WB stage to only forward the LSU write enable,
which is generated from data_rvalid_i, when Ibex is actually waiting for
an interconnect response for a load instruction. This substantially
narrows down the window for attacks at the interconnect level.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2023-01-16 18:53:17 +01:00
Guillermo Maturana
ec32fb1a64 [rtl] Change code to be more xprop-friendly
Xprop is a simulation feature that improves the SV semantics when
conditions contain 'X values. Change RTL or DV code to enable more xprop
instrumentation.

This addresses lowRISC/opentitan#16791 and some of
lowRISC/opentitan#16723.

Signed-off-by: Guillermo Maturana <maturana@google.com>
2022-12-22 10:09:06 +01:00