Skip to content

Allow alias to anything in a protected type declaration

Is your capability/feature request related to a problem?

VHDL LRM 2019 5.6.2 Says this:

A private variable declaration denotes that it is only visible within the scope of the protected type. An alias declared within a protected type declaration may make a method of the private variable visible. It is an error if an alias declared within a protected type declaration denotes anything other than a method of a protected type

Unfortunately, it makes the following illegal.

type some_PT is protected
    generic (
      type element_array_ptr_t is access
        type is array(natural range <>) of 
          type is private;      
    );

    alias array_t         is element_array_ptr_t'DESIGNATED_SUBTYPE;
    alias array_element_t is element_array_ptr_t'DESIGNATED_SUBTYPE'element;

This will lead to some rather wordy APIs:

  impure function get_array return element_array_ptr_t'DESIGNATED_SUBTYPE;
  impure function get(i : integer) return element_array_ptr_t'DESIGNATED_SUBTYPE'ELEMENT;

Examples like this are given already in 6.5.3.2 for packages - why cant they be done with protected types?

Describe the solution you'd like

Remove the restriction on alias declarations in protected type declarations, so a protected type API can be more concise:

  impure function get_array return array_t;
  impure function get(i : integer) return array_element_t;
Edited by Patrick Lehmann
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information