Procedure

LRM §2.1, §2.2.

A procedure is a subprogram to group sequential statements.

Syntax:

procedure procedure_name [ ( parameter_declaration; ) ] ;      -- declaration
procedure procedure_name [ ( parameter_declaration; ) ] is
  [ procedure_declarations ]
begin
  sequential_statements
end [ procedure ] [ procedure_name ];                          -- body

Description:

The procedure is used to group together executable, sequential statements. A procedure has a name and a set of parameters. Procedure can be called in any place of the architecture. The procedure definition consists of a procedure declaration and a procedure body. 

The procedure declaration consists of the procedure name and parameter list required when the procedure is called.

The procedure body defines the procedure's algorithm composed of sequential statements. Declarations in a procedure are local to this declaration.

The procedure declaration is optional. The procedure body can exist without a declaration. If, however, a procedure declaration is used, then a procedure body must accompany it.

The overloaded procedures are procedures with the same name but with different number or different types of formal parameters. The actual parameters decide which overloaded procedure will be called.

Example:

procedure Proc1 (signal Clk: in std_logic; 
                 Values: std_logic_vector; 
                 signal S1, S2: out std_logic;
                 variable V1, V2: out std_logic;
                 WaitTime: time := 10 ns) is
begin
  if rising_edge(Clk) then 
    S1 <= Values(0); 
    S2 <= Values(1); 
    V1 <= Values(2); 
    V2 <= Values(3);
    wait for WaitTime; 
  end if;
end Proc1;

Notes:

See also:

Function, Procedure call