Skip to content

[rtl] Fix prim_generic mapping in ibex_top#2443

Open
SamuelRiedel wants to merge 2 commits into
lowRISC:masterfrom
SamuelRiedel:core-files
Open

[rtl] Fix prim_generic mapping in ibex_top#2443
SamuelRiedel wants to merge 2 commits into
lowRISC:masterfrom
SamuelRiedel:core-files

Conversation

@SamuelRiedel
Copy link
Copy Markdown
Contributor

This PR course-corrects #2397, where I mistakenly moved prim_generic into ibex_top.core. While that change fixed an immediate FuseSoC failure, it broke the core-file's technology-independent abstraction layer.

ibex_top is designed to rely strictly on virtual primitive dependencies (prim:*). It isn't meant to act as a final top-level module. Instead, wrappers like ibex_top_tracing are supposed to bind these abstract primitives to a concrete implementation, e.g., to prim_generic. This keeps ibex_top technology-independent and an FPGA wrapper can use prim_xilinx for example.

I previously treated the lowrisc:prim_generic:all dependency as a standard source file dependency. Because ibex_top is the module actually implementing Ibex, it felt logical to put the dependency there instead of the wrapper to make ibex_top's dependency list complete on its own. However, in my current understanding, this dependency actually serves to define the instantiation mapping. Because ibex_top already declares its source dependencies virtually, hardcoding prim_generic there stripped away the ability for wrappers to cleanly set their own primitives' implementation.

The original mistake stemmed from our documentation, which instructs users to run linting or generate filelists targeting ibex_top directly. Doing so bypasses the standard wrappers, leaving FuseSoC with no idea which implementation of the virtual prims to use, and to choose randomly, which then failed.

To fix this cleanly now, this PR:

  • Removes the global prim_generic dependency from ibex_top.core again and moves it back to ibex_top_tracing.core.
  • Explicitly maps the virtual prims to prim_generic only for the linter and Verilator targets within ibex_top.

This restores FPGA builds and ensures the documented linting/filelist workflows still work.

Explicitly include `lowrisc:prim_generic:all` in `ibex_top_tracing`
instead of `ibex_top` to bind abstract `prim` dependencies to a specific
implementation (generic, in this case). This is done to resolve the
primitive mappings rather than to fix missing source dependencies. The
dependencies are all listed as virtual `prim`s in `ibex_top`. Keeping
this mapping isolated ensures that other wrappers can cleanly bind
`ibex_top` to alternative backends, such as `prim_xilinx` for FPGA
targets.
Adding a dependency on a specific implementation (`prim_generic`) of the
virtual `prim` core for linter and Verilator targets forces FuseSoC to
use the correct instances, thereby allowing us to lint or export
filelists of `ibex_top` without a wrapper defining the virtual core's
implementation.
@SamuelRiedel
Copy link
Copy Markdown
Contributor Author

I created a quick OT draft PR to verify that the CI passes also in OT with those changes: lowRISC/opentitan#30265

Copy link
Copy Markdown
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

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

Thanks @SamuelRiedel for the PR and the detailed description, very nice work!

Copy link
Copy Markdown
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

This change looks good to me and better maps the expected behaviour.

Copy link
Copy Markdown
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

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

Looks good, and thanks for the careful explanation.

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.

5 participants