Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDs - add _UNINITIALISED constant and add is_initialised functions for IDs #86

Open
SkydiverTricky opened this issue Oct 16, 2023 · 0 comments

Comments

@SkydiverTricky
Copy link

SkydiverTricky commented Oct 16, 2023

In Some usecases, it may be useful to test whether a given ID is initialised or not. For example, I have data generators that can be driven by random distributions or a coverage ID. Currently I have a separate "coverage enable" signal to determine whether the coverage is used over the distribution. Instead of having this enable, it could be easier to test whether it is initialised:

--In CoveragePkg
constant COVERAGE_ID_UNINITIALISED : CoverageIdType := (ID := integer'left);

if some_cov_id = COVERAGE_ID_UNINITIALISED then
  -- do something using the coverage id
else
  -- do not use coverage ID
end if;

In addition, it would be useful to have an is_initialised function, in case the base types of the IDs ever change, and is more readable for the user and would be common accross packages:

if is_initialised(some_id ) then
  -- continue with the ID
else
  -- continue without the ID

Having the constant would also allow variables/signals that are record types that contain IDs to be initialised by name and not have to use integer'left, when the type declaration of the IDs themselves may change in future revisions:

current implementation:

record data_cfg_t is
  --some controls here

  cov_id : CoverageIdType;
end record;

constant data_cfg_default : data_cfg_type := (cov_id => (ID => integer'left));  -- CoverageID format may change in future OSVVM revisions

future proofing could be obtained via

constant data_cfg_default : data_cfg_type := (cov_id => COVERAGE_ID_UNINITIALISED); 
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

No branches or pull requests

1 participant