This chapter explains packages and how compiled design units are stored in design libraries. It explains how the
contents of design units stored in different libraries may be shared by several design units.
A package provides a convenient mechanism to store and share declarations that are common across
many design units. A package is represented by
a package declaration, and optionally,
a package body.
A package declaration contains a set of declarations that may possibly be shared by many design units. It defines
the interface to the package, that is, it defines items that can be made visible to other design units, for example, a
function declaration. A package body, in contrast, contains the hidden details of a package, for example, a function
The syntax of a package declaration is
"> These may be:
- subprogram declarations ~ type declarations
- subtype declarations
- constant declarations
- signal declarations
- file declarations
- alias declarations
- component declarations
- attribute declarations
- attribute specifications
- disconnection specifications
- use clauses
An example of a package declaration is given next.
LOW2HIGH: TIME := 20ns:
(ADD, SUB, MUL, DIV, EQL);
('U', '0', '1', 'Z');
<>) of MVL;
Items declared in a package declaration can be accessed by other design units by using the library and use context
clauses. The set of common declarations may also include function and procedure declarations and deferred
constant declarations. In this case, the behavior of the subprograms and the values of the deferred constants are
specified in a separate design unit called the package body. Since the previous package example did not contain
any subprogram declarations and deferred constant declarations, a package body was not necessary.
Consider the following package declaration.
-A deferred constant.
(L, R: MVL)
START_BIT, STOP_BIT, INT_VALUE:
In this case, a package body is required.