In the previous examples component declaration always took place within an architecture. It could easily become tedious to repeat declarations of frequently used components in various architectures of a design. This unnecessary work can be avoided by the use of packages. Semiconductor vendors often provide packages containing complete cell libraries which could be conveniently accessed from different design entities within a design.
The desired package could be referenced with the use statement. A package itself may contain only component declarations; declarations of entities and belonging architectures may be placed in other design units.
Example:
architecture S of COMPARE is
component XR2
port (X, Y: in bit; Z: out bit);
end component;
component INV
port (X: in bit; Z: out bit);
end component;
signal I: bit;
begin
U0: XR2 port map (A, B, I);
U1: INV port map (I, C);
end S;
-- is equivalent to --
package XYZ_GATES package with declarations of components
component XR2
port (X, Y: in bit; Z: out bit);
end component;
component INV
port (X: in bit; Z: out bit);
end component;
end XYZ_GATES;
use WORK.XYZ_GATES.ALL; use the XYZ_GATES package
architecture T of COMPARE is
signal I: bit;
begin
U0: XR2 port map (A, B, I);
U1: INV port map (I, C);
end T;