4.9 Attribute 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 ;


attribute_declaration ::=

attribute
identifier : type_mark ;

...
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 ;

Attributes can be used to poll the characteristics of objects (e.g. signals). In many cases this allows a shorter and more elegant VHDL description to be created. The most important attributes are predefined ones.

In order to be able to use one`s own attributes one has to write a corresponding function which then provides the

attribute`s value at any given time. For further information go to: Attribute specification.

4.9.1 Further definitions

identifier ::=
    basic_identifier | extended_identifier

type_mark ::=
     type _name
    | subtype _name

4.9.2 Examples

ATTRIBUTE capacitance_value :
      capacitance ;

capacitance_value is declared as an attribute
of the type capacitance .

SUBTYPE pin_natural IS natural
      RANGE 1 TO 24 ;
ATTRIBUTE pin_number : pin_natural ;

The attribute pin_number declared here is
of the subtype pin_natural .

TYPE coordinate IS
   RECORD
      x, y : integer ;
   END RECORD ;
   TYPE positive IS integer
         RANGE 1 TO integer'high ;
   ATTRIBUTE location : coordinate ;
   ATTRIBUTE pin_no : positive ;

Two different attributes are declared.

location
is of the type coordinate which
is a Record type.

pin_no
is of the type positive which is

a subtype of integer .

SIGNAL a1: bit_vector(3 DOWNTO 0) ;
...
PROCESS (a)
   BEGIN
   z<= "0000";
   FOR i in 0 TO 3 LOOP
      IF (a = i) THEN
         z(i) <= '1' ;
      END IF ;
   END LOOP ;
END PROCESS ;
...

By using predefined attributes the loop-instruction
can be written in a different way as well:

FOR i IN a1'LOW TO a1'HIGH

FOR i IN a1'RIGHT TO a1'LEFT

FOR i IN a1'REVERSE_RANGE

FOR i IN a1'RANGE