138 Chapter Five
actual subprogram body specified yet. The subprogram body must exist
before the simulator is built, during elaboration.
Package Body
The main purpose of the package body is to define the values for deferred
constants and specify the subprogram bodies for any subprogram decla-
rations from the package declaration. However, the package body can also
contain the following declarations:
Subprogram declaration
Subprogram body
Type, subtype declaration
Constant declaration, which fills in the value for the deferred con-
stant
File declaration
Alias declaration
Use clause
All of the declarations in the package body, except for the constant
declaration that is specifying the value of a deferred constant and the sub-
program body declaration, are local to the package body.
Let’s examine a package body for the package declaration that was
discussed in the last section:
PACKAGE BODY cluspack IS
CONSTANT undriven : t_wclus :=
(ZX, ZX, ZX, ZX,
ZX, ZX, ZX, ZX,
ZX, ZX, ZX, ZX,
ZX, ZX, ZX, ZX);
FUNCTION resolve_cluster ( s: t_clus_vec )
return t_cluster IS
VARIABLE result : t_cluster;
VARIABLE drive_count : INTEGER;
BEGIN
IF s’LENGTH = 0 THEN RETURN undriven;
END IF;
FOR i in s’RANGE LOOP
IF s(i) /= undriven THEN
drive_count := drive_count + 1;
IF drive_count = 1 THEN