Package Body

LRM §2.6.

A package body defines the bodies of subprograms and the values of deferred constants defined in the package.

Syntax:

package body package_name is 
  package_body_declarations 
end [ package body ] [ package_name ]; 

Description:

The package body includes complete definitions of subprogram body declarations as well as values of deferred constants declared in the corresponding package declarations. Other declarations (similar to those of package declaration) are also allowed here, but are visible only inside the package body.

The deferred constant, which has been declared in a package declaration, may be used before its full declaration only in a default expression for a local generic parameter, local port or formal parameter of subprogram.

Example:

package body Utils is 
  constant Size: positive := 16; 
  function Parity (V: Vec8) return std_logic is 
    variable B: std_logic := '0'; 
  begin 
    for I in V'Range loop 
      B:= B xor V(I); 
    end loop; 
    return B; 
  end Parity; 
end Utils; 

Notes:

See also:

Function, Package, Procedure, Type, Use