vhdl_reference_93:alias_declarations

Alias declarations

alias alias_designator [ : subtype_indication ] is name [ signature ] ;
  • entity_declarative_part
  • architecture_declarative_part
  • package
  • package_body
  • block_declarative_part
  • function_declarative_part
  • procedure_declarative_part
  • process_declarative_part

[ resolution_function_ name ] type_mark [ constraint ]

[ [ type_mark { , type_mark } ] [ return type_mark ] ]

Alias can be used for all named entities except labels, loop parameters and generate parameters. An alias for an object (constant, variable, signal, file) is an object alias. All others are nonobject aliases.

The alias of an overloadable object is itself overloadable.

The following rules apply to object aliases:

  • Signatures are not allowed.
  • The name in an alias declaration has to be a static name (See Name). If the subtype indication is present it has to be match the basetype of the name in the alias declaration. This type must not be a multi-dimensional array type. The following rules apply:
    • If the subtype indication is absent or it denotes an unconstrained array type:
      • If the alias designator denotes a slice of an object, then the subtype of the object is viewed as if it were of the subtype specified by the slice.
      • Otherwise the object has the same type as implied by the name.
    • If the subtype indication denotes a constrained array type, then the object is of this subtype. Moreover the subtype must have matching elements for each element of the type denoted by the name.
    • If the subtype indication denotes a scalar type, then the object is of this subtype. Moreover the bounds and direction must be the same.
  • The same applies to attribute references where the prefix of the attribute name denotes the alias.
  • A reference of a object alias is automatically a reference to the original object (also applies to slices of arrays).

The following rules apply to nonobject aliases:

  • Subtype indications are not allowed.
  • If the name denotes a subprogram (including a operator) or a enumeration literal, then a signature is required. The signature has to match the parameter and result type profile (See Overloading) of exactly one subprogram or enumeration literals denoted by the name.
  • If the name denotes a enumeration type, then the alias declaration implies further aliases for every enumeration literal (alias_designator = enumeration_literal; name = enumeration_type.enumeration_literal).
  • The equivalent applies to an alias of an physical type.
  • If the name denotes a type, then the alias declaration implies further aliases for defined operators of this type and if needed for corresponding values and units. Every implicit operator alias declaration has a signature which matches exactly one of the parameter and result type profile (See Overloading) of the original operator.

Because of the alias declaration the constant tc can now also be addressed via the name delay .

CONSTANT tc : time := 2.5 ns ;
ALIAS delay : time IS tc ;

Through the alias the variable vector can now be addressed via the name reverse_vector with the indices ranging from 8 to 1.

VARIABLE vector : bit_vector(0 TO 7);
ALIAS reverse_vector : bit_vector
     ( vector'length DOWNTO 1 )
       IS vector ;

Here the variable real_number is aliased differently.

Via sign the MSB of real_number can be addressed.

With mantissa the elements 8 to 31 of real_number are addressed with the indices ranging from 0 to 23.

With exponent the elements 1 to 7 of real_number are addressed with the indices ranging from 1 to 7 as well.

VARIABLE real_number : bit_vector
      ( 0 TO 31 ) ;
ALIAS sign : bit IS real_number(0) ;
 
ALIAS mantissa : bit_vector( 0 TO 23 )
      IS real_number( 8 TO 31 ) ;
 
ALIAS exponent : bit_vector( 1 TO 7 )
      IS real_number( 1 TO 7 ) ;

The predefined type BIT of the automatically visible package STADARD of the library STD is aliased to std_bit .

With this further alias declarations for the values of the enumeration type and the predefined operators are implied.

ALIAS std_bit IS STD.STANDARD.BIT ;
 
-- ALIAS `0' IS STD.STANDARD .'0'
--        [ RETURN STD.STANDARD.BIT ] ;
-- ALIAS `1' IS STD.STANDARD .'1' ;
--        [ RETURN STD.STANDARD.BIT ] ;
 
-- ALIAS "and" IS STD.STANDARD ."and" ;
--[ STD.STANDARD.BIT , STD.STANDARD.BIT
--        RETURN STD.STANDARD.BIT ] ;
-- ALIAS "or" IS STD.STANDARD ."or" ;
--[ STD.STANDARD.BIT , STD.STANDARD.BIT
--        RETURN STD.STANDARD.BIT ] ;
-- ยทยทยท