Skip to content

[Fix] Fix underflow in OBI typedefs#39

Merged
micprog merged 1 commit into
pulp-platform:mainfrom
mosaic-soc:pr/typedef-min-width
Jul 10, 2026
Merged

[Fix] Fix underflow in OBI typedefs#39
micprog merged 1 commit into
pulp-platform:mainfrom
mosaic-soc:pr/typedef-min-width

Conversation

@LucaRufer

Copy link
Copy Markdown

Fix underflow in OBI type definitions.

Probem Description

Many default configs and testbenches set the signal widths of unused optional signals to 0. For some simulators (like VCS), this leads to the following problem:
Because the widths are unsigned fields in the obi_optional_cfg_t/obi_cfg_t structs, the [x_WIDTH-1:0] in the type definition results in an underflow due to the unsigned 0-1 and the simulator tries to create a [2**32-1:0] sized vector.

Proposed Solution

There are multiple ways to solve this problem:

  • Convert the width fields in the obi_optional_cfg_t/obi_cfg_t structs to int instead of int unsigned types, resulting in logic [-1:0] vectors when a signal is not used. However, this does not solve the problem if some of the the typedef macros are called directly and not generated from the config.
  • Using logic [$signed(x_WIDTH)-1:0] to cast the width inside the typedefs, resulting in logic [-1:0] vectors when a signal is not used.
  • Checking if the width is 0 and computing logic [(x_WIDTH > 0 ? x_WIDTH : 1)-1:0], resulting in logic [0:0] vectors when a signal is not used.

For this PR, the last of these solution was implemented, using new macro OBI_TYPEDEF_MIN_WIDTH.

@micprog micprog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@micprog micprog merged commit e218a00 into pulp-platform:main Jul 10, 2026
3 checks passed
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.

2 participants