4.2 Subtype declarations

...
ENTITY e IS
    ...
BEGIN
    ...
END e ;

...
ARCHITECTURE a OF e IS
    ...
BEGIN
    ...
END a ;

...
CONFIGURATION c
        OF e IS
    ...
    ...
    ...
END


...
PACKAGE pkg IS
    ...
    ...
    ...
END pkg ;


subtype_declaration ::=

subtype
identifier is
        subtype_indication ;


..
PACKAGE BODY pck
        IS
    ...
    ...
    ...
END pck ;

...
b: BLOCK IS
    ...
BEGIN
    ...
END BLOCK b ;

FUNCTION f (...)
    RETURN r IS
    ...
BEGIN
    ...
END f ;

PROCEDURE p (...) IS
    ...
BEGIN
    ...
END p ;

p : PROCESS
    ...
BEGIN
    ...
END PROCESS p ;

4.2.1 Further definitions

identifier ::=
    basic_identifier | extended_identifier

subtype_indication ::=
    [ resolution_function_ name ] type_mark [ constraint ]

4.2.2 Examples

SUBTYPE natural IS integer
      RANGE 0 TO integer'high ;

SUBTYPE
positive IS integer
      RANGE 1 TO integer'high ;

These are standard predefined subtypes.
natural is an integer -type which is restricted to the
range of 0 to the maximum integer -value.
positive
is also an integer -type which is restricted
to the range of 1 to the maximum integer -value.

SUBTYPE primary_color IS
      color RANGE yellow TO blue ;
SUBTYPE same_color IS primary_color ;

SUBTYPE
address_integer IS
      integer RANGE 0 TO 127 ;
SUBTYPE human_size IS
      real RANGE 0.50 TO 2.50 ;

SUBTYPE
byte IS
      bit_vector (7 DOWNTO 0);
SUBTYPE name IS string ( 1 TO 31 );
SUBTYPE color_10 IS colors (1 TO 10);

These are common examples such as subtypes
which are created from basic types by
means of range-constraints.

The ranges of integer - and real subtypes are
declared with the keyword RANGE .



The ranges of character -, string - and enumeration
subtypes are declared by explicitly stating a certain
section.


SUBTYPE
sbit IS wiredX zbit ;
SUBTYPE xbit IS wiredX zbit
      RANGE 'X' TO '1' ;

The two subtypes sbit and xbit are declared as subtypes
of zbit and a resolution function is assigned to both of
them. The resolution function makes sure that in a
multiple assignment to a signal only definite values
are assigned.