Skip to content

[multitop] Make the codebase more ready to support multiple tops - #31072

Open
mfnch wants to merge 7 commits into
lowRISC:masterfrom
mfnch:multitop
Open

[multitop] Make the codebase more ready to support multiple tops#31072
mfnch wants to merge 7 commits into
lowRISC:masterfrom
mfnch:multitop

Conversation

@mfnch

@mfnch mfnch commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

This PR includes changes that aim to make the OpenTitan codebase easier to work with when dealing with multiple tops:

NOTE: The first two commits ("Fix documentation" and "Add opentitan_for_ip") are expected to be merged as part of #31025. I am going to rebase this PR once the other PR gets merged.

@mfnch
mfnch requested review from a team and cfrantz as code owners August 20, 2026 16:15
@mfnch
mfnch requested review from timothytrippel and removed request for a team August 20, 2026 16:15
@mfnch
mfnch marked this pull request as draft August 20, 2026 16:16
},
[],
),
"flash_ctrl": ["//sw/device/lib/testing:nvm_testutils"],

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.

I need to have a look at how to handle nvm_testutils. I think this library should shield its users from having to check whether the hardware is supported... a bit like the ottf_console?

@mfnch mfnch Aug 21, 2026

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.

One option would be to change nvm_testutils so that it always compiles, even when there is no hardware (flash/rram). The library would then fail only when trying to write or read to NVM. In practice, however, there aren't many users of nvm_testutils - apart from this one - that would benefit from this change (most users want to to actually write from or read to NVM rather than optionally initialize it).

However, the problem of how we pull a NVM library in as a dependency is a real one. It'd be nice to have an "alias" IP that just tells us whether a NVM IP is present in the current top. That would make handling dependencies to this library nicer.

@mfnch
mfnch force-pushed the multitop branch 2 times, most recently from c66618b to 0be4fbe Compare August 21, 2026 09:53
@mfnch
mfnch marked this pull request as ready for review August 21, 2026 10:13
@mfnch
mfnch requested a review from engdoreis August 21, 2026 10:17
@mfnch
mfnch force-pushed the multitop branch 2 times, most recently from d79f37e to 60e96a4 Compare August 21, 2026 16:39
mfnch added 7 commits August 21, 2026 17:44
Remove spurious header inclusion and dependencies which accidentally
survived from previous refactorings.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
Some tests (aes_prng_reseed_test, aes_force_prng_reseed_test and
aes_stall_test) were including the simple_serial.h header and declaring
this library as a dependency, despite not using it. This had the effect
of excluding these tests for execution on Darjeeling, as simple_serial
was explicitly declared as requiring the Earlgrey top.

This commit removes the unnecessary dependency on the simple_serial
library and also removes these tests for execution on Darjeeling,
as they are not declared in any of its DV test plans.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
Make sure the ottf console is usable even when no backends are
available.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
Change functions that get/set whether a gateable/hintable clock
is enabled so that they gracefully handle the case where there are
no gateable/hintable clocks in the system.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
Improve the sanity checks (assertions) and make sure the right macros
are used to calculate the CTRL_N and REGWEN register offsets depending
on their multireg count. These changes make the code more suitable
to work with different tops.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
Sub-registers names have two different forms depending on their number:
This breaks uniformity between the tops and forces C code to remedy
using preprocessor directives.

For example, the following code would be necessary to support tops where
a multi-register MRNAME has 1 or more sub-registers:

  #if RSTMGR_SW_RST_REGWEN_MULTIREG_COUNT == 1
    offset = MRNAME_REG_OFFSET;
  #else
    offset = MRNAME_0_REG_OFFSET;
  #endif

This commit changes the register code generation to provide the _0
suffixed macros as well. This allows simplifying the C code while
keeping compatibility with the old behaviour of the tool.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
Refactor test_rom.c to enable code (via #ifdefs) based on the supported
IP (HAS_PINMUX, HAS_UART, ...) rather than on the active top
(OPENTITAN_IS_EARLGREY, OPENTITAN_IS_DARJEELING, ...). This makes
the implementation less likely to require changes when new tops
are added.

Group all code on the same #ifdef (the header inclusion as well
as all code that uses it) by defining static functions that are called
from the main initialization function, rom_test_main. This reduces the
amount of preprocessor code in this function and hopefully makes it
easier to read and maintain.

Use top-independent names (kDtPinmuxFirst rather than kDtPinmux) with
static assertions when we expect only one instance of the IP to exist.

Signed-off-by: Matteo Franchin <matteo.franchin@lowrisc.org>
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.

1 participant