OSVVM icon indicating copy to clipboard operation
OSVVM copied to clipboard

[Feature] Make libraries such as NamePkg generic

Open nselvara opened this issue 8 months ago • 4 comments

Hey there, I really like the OSVVM library. As a feature enhancement, I'd like to suggest making the NamePkg to a generic array package. This would allow to be easily instantiated/overloaded with custom types.

Suggested code/package:

generic (
    type array_elem_t; --! Set the type of the array elements
    REALLOC_CHUNK_BITS: natural := 8 --! Set the chunk size for reallocating the array
);

type dynamic_array_t is protected
    procedure append(value: array_elem_t);
    procedure set(value: array_elem_t; index: positive);
    impure function get(index: positive) return array_elem_t;
    impure function get_count return natural;
    impure function remove(index: positive) return integer; -- 0 = OK, -1 = failure
    impure function is_set return boolean;
    procedure clear_array;
    procedure deallocate_array;
end protected;

nselvara avatar Jun 18 '24 08:06 nselvara