[Fix] Fix underflow in OBI typedefs#39
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
unsignedfields in theobi_optional_cfg_t/obi_cfg_tstructs, the[x_WIDTH-1:0]in the type definition results in an underflow due to the unsigned0-1and the simulator tries to create a[2**32-1:0]sized vector.Proposed Solution
There are multiple ways to solve this problem:
obi_optional_cfg_t/obi_cfg_tstructs tointinstead ofint unsignedtypes, resulting inlogic [-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.logic [$signed(x_WIDTH)-1:0]to cast the width inside the typedefs, resulting inlogic [-1:0]vectors when a signal is not used.logic [(x_WIDTH > 0 ? x_WIDTH : 1)-1:0], resulting inlogic [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.