2.1 Subprogram declaration

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


subprogram_declaration ::=

        subprogram_specification ;

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

2.1.1 Further definitions

subprogram_specification ::=
    procedure designator [ ( formal_parameter_list ) ]
    | [ pure | impure ] function designator [ ( formal_parameter_list ) ]
        return type_mark

2.1.2 Comment

A pure function always returns the same value when called different times with the same actual parameters. Impure functions can return different values when called several times with the same actual parameters. This is the case when for example a impure function reads in a text file, which content changes during simulation.

2.1.3 Examples

PROCEDURE thank_you ;

Simple declaration of the procedure thank_you
without transfer values

PROCEDURE test( A : Bit ) ;

Declaration of the procedure test with the transfer
value A .

FUNCTION convert( B : Bit )
      RETURN fuzzy_bit ;

Declaration of the function convert with the transfer
value B and the result type fuzzy_bit .

PROCEDURE regist(
      SIGNAL D : IN Bit;
      SIGNAL CK : IN Bit;
      SIGNAL Q : OUT Bit ) ;

Declaration of the procedure regist with
the signals D , CK and Q being transferred.

PROCEDURE p(
      VARIABLE COL : INOUT color;
      CONSTANT C : IN choice ) ;

Declaration of the procedure p with the variable
COL and the constant C being transferred.