Skip to content

[doc] Update documentation to align with recent RTL changes - #2484

Open
SamuelRiedel wants to merge 2 commits into
lowRISC:masterfrom
SamuelRiedel:doc
Open

[doc] Update documentation to align with recent RTL changes#2484
SamuelRiedel wants to merge 2 commits into
lowRISC:masterfrom
SamuelRiedel:doc

Conversation

@SamuelRiedel

@SamuelRiedel SamuelRiedel commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Some new changes to Ibex were not reflected in the documentation. This PR updates it:

  • add new ibex_top parameters
  • add cross-refs throughout the parameter list to explain what they do without duplication
  • add missing ports and their description
  • udpate instantiation snippet updated to match current RTL
  • add missing CSRs
  • add pipeline details for pipeline flush on CSR writes
  • expand explanation on Zcmp behavior concerning interrupts

The CHERIoT documentation is deferred to a separate PR

@SamuelRiedel
SamuelRiedel marked this pull request as ready for review August 28, 2026 14:39

@nasahlpa nasahlpa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from one question.

Comment thread doc/02_user/integration.rst Outdated
| | | | (only relevant when ICacheScramble == 1) |
+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``ICacheTweakInfection`` | bit | SecureIbex | Enable :ref:`icache-tweak-infection` |
| | | | (only relevant when ICacheScramble == 1) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that correct? As far as I remember, it is only useful when having SecureIbex enabled (because then ECC errors are flagged by a wrong un-XOR operation) and when we have an icache available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. That was a copy-paste error.

Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
We check all incoming valid responses, not just load data

Fixes lowRISC#2200

Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
@andreaskurth andreaskurth changed the title [doc] Update documentation to align with recent RTL chagnes [doc] Update documentation to align with recent RTL changes Aug 31, 2026

@andreaskurth andreaskurth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @SamuelRiedel for updating the Ibex documentation with many recent RTL changes (not just CHERIoT)!

This mostly LGTM, but I have see a few points that should be changed: one factual mix-up on ICacheScrNumPrinceRoundsHalf, a few over- or under-stated qualifiers, and some stale text sitting at the far end of the new cross-references.

+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``PMPNumRegions`` | int (1..16) | 4 | Number implemented PMP regions (ignored if PMPEnable == 0) |
+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``MHPMCounterNum`` | int (0..10) | 0 | Number of :ref:`performance-counters` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this new :ref: lands on performance_counters.rst:85-90, which uses WidthMHPMCounters/NumMHPMCounters (RTL names them MHPMCounterWidth/MHPMCounterNum) and caps the useful count at 8 (mhpmcounter3 - mhpmcounter10). The RTL defines events up to mhpmcounter12 (ibex_cs_registers.sv:1583-1597), i.e. 10, which matches this row and that page's own event table. Worth fixing there too while we're at it?

+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``ICacheECC`` | bit | 0 | Enable :ref:`icache-ecc` (if ICache == 1) |
+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``BranchPredictor`` | bit | 0 | *EXPERIMENTAL* Enable :ref:`branch-prediction` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :ref: target still calls the parameter BranchPrediction (instruction_fetch.rst:34). Rename it there too so the cross-reference doesn't contradict the name in this row?

| ``SecureIbex`` | bit | 0 | Enable various :ref:`security`. Note: SecureIbex == 1'b1 and |
| | | | RV32M == ibex_pkg::RV32MNone is an illegal combination. |
+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``LockstepOffset`` | int (>= 1) | 1 | Number of cycles to delay the :ref:`lockstep` shadow core |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "(only relevant when SecureIbex == 1)" here, like the neighbouring rows carry? Lockstep = SecureIbex, so the offset has no effect otherwise.

+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``LockstepOffset`` | int (>= 1) | 1 | Number of cycles to delay the :ref:`lockstep` shadow core |
+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``MemECC`` | bit | SecureIbex | Enable SECDED ECC for :ref:`bus-integrity` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this new :ref: lands on security.rst:93, which still says "When the SecureIbex parameter is set, incoming data will be checked ..." (same in load_store_unit.rst:68). Now that MemECC is documented as an independent parameter, should those two name MemECC instead?

+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``MemECC`` | bit | SecureIbex | Enable SECDED ECC for :ref:`bus-integrity` |
+----------------------------------+---------------------+-------------------------+----------------------------------------------------------------------------------------------+
| ``MemDataWidth`` | int (>= 32) | MemECC ? 32 + 7 : 32 | Data width of memory interface including integrity bits |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int (>= 32) reads as if this were freely choosable, but it is derived from MemECC and effectively fixed at 32 or 39: ibex_top.sv:864 slices data_wdata_core[MemDataWidth-1:32] into a prim_buf #(.Width(7)), so any other value breaks elaboration. Say "derived" or "32 or 39" in the range column?

| 0 | RW | **CY:** Enable U-mode access to ``cycle`` / ``cycleh``. |
+--------+------+-------------------------------------------------------------------------------------+

Writes to ``mcounteren`` are only accepted when the ``mcounteren_writable_i`` input is set to ``IbexMuBiOn``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performance_counters.rst:77 describes the same mechanism but calls the signal mcounteren_writeable. Fix the name there and cross-reference here, so the behaviour is only spelled out once?

+-----------------------+--------------------------------------+-------------------------------------------------------------+
| CSR Access | 0 | CSR Access Instruction are defined in 'Zicsr' of the |
| | | RISC-V specification. |
| | | RISC-V specification. Note that any CSR *write* flushes the |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"any CSR write" is slightly too strong: mscratch and mepc are exempt via no_flush_csr_addr (ibex_id_stage.sv:593), and the RTL comment says "on most CSR modification". Mention the two exceptions?


.. note::

**Zcmp interrupt and exception behaviour**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the note also cover debug-mode entry? It is blocked over a wider window than interrupts: INSTR_EXPANDED and INSTR_EXPANDED_COMMIT (ibex_controller.sv:474-477), versus INSTR_EXPANDED_COMMIT only for handle_irq (ibex_controller.sv:499).


**Zcmp interrupt and exception behaviour**

* **Interrupt masking:** Interrupts are suppressed for the duration of a Zcmp push/pop commit sequence.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cm.push never reaches INSTR_EXPANDED_COMMIT (it goes INSTR_EXPANDED -> INSTR_EXPANDED_LAST), so interrupts are not suppressed during it. The sentence two lines down already says as much, so dropping "push/" here would remove the contradiction.

* **minstret counting:** An entire Zcmp push/pop sequence (regardless of how many register load/store micro-operations it expands to) is counted as a single retired instruction in ``minstret``.

* **Exception/interrupt during expansion:** If an exception or interrupt is signalled before the commit sequence has started, the Zcmp state machine is flushed and the partial sequence is abandoned.
The core takes the trap as if the Zcmp instruction had not yet started, so software can safely restart it on return from the handler.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as if the Zcmp instruction had not yet started" seems a bit strong: a partial cm.push has already written stack memory (negative offsets from sp, see cm_push_store_reg) and a partial cm.pop has already overwritten registers. The reason restarting is safe is that sp is adjusted last, so the micro-ops are idempotent. Say that instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants