Package and Sub-Programs

Updated on 2017/07/29 17:02


  • Packages, Sub programs


Package Declaration Format

package package_name is
... exported constant declarations
... exported type declarations
... exported subprogram declarations
end package_name;


Example 1

package ee530 is
constant maxint: integer := 16#ffff#;
type arith_mode_type is (signed, unsigned);
function minimum(constant a,b: in integer) return integer;
end ee530;
Package body format
package body package_name is
... exported subprogram bodies
... other internally-used declarations
end package_name;

Example 2

package body ee530 is
function minimum (constant a,b: integer) return integer is
variable c: integer; -- local variable
if a < b then
c := a;-- a is min
c := b;-- b is min
end if;
return c;-- return min value
end ee530;


A  subprogram defines a sequential algorithm that performs a certain computation. Subprograms can be overloaded.
There are two kinds of subprograms

  • Functions
  • Procedures


  • Function name can be an operator
  • Arbitrary number of input parameters
  • Exactly one return value
  • No WAIT statement allowed
  • Function call &hArr; VHDL expression
  • Computes a sinle value
  • Executes in zero simulation time


  • Arbitrary number of parameters of any possible direction (in/out/inout)
  • RETURN statement optional (no return value!)
  • Procedure call &hArr; VHDL statement
  • Can computes several values
  • May not execute in zero simulation time,depending on whether it has a wait statement or not


  • Edited and Created by Prof Hrishikesh Dhanwate, JSPM'S ICOER, Wagholi ,Pune
  • WikiNote Foundation
Created by HrishikeshDhanawate on 2017/07/28 19:07