Procedures
Procedures differ from functions in that they do not have a return value, and their arguments may include both inputs and outputs to the subprogram. Because each argument to a procedure has a mode (in, out, or inout), they can be used very much like you would use an entity/architecture pair to help simplify and modularize a large and complex design description.
Procedures are used as independent statements, either within the concurrent area of an architecture or within the sequential statement area of a process or subprogram.
The following sample procedure defines the behavior of a clocked JK flip-flop with an asynchronous reset:
procedure jkff (signal Rst, Clk: in std_logic;
signal J, K: in std_logic;
signal Q,Qbar: inout std_logic) is
begin
if Rst = ‘1’ then
Q <= '0';
elsif Clk = ‘1’ and Clk’event then
if J = '1' and K = '1' then
Q <= Qbar;
elsif J = '1' and K = '0' then
Q <= '1';
elsif J = '0' and K = '1' then
Q <= '0';
end if;
end if;
Qbar <= not Q;
end jkff;
A procedure may include a wait statement, unless it has been called from within a process that has a sensitivity list.
Note that variables declared and used within a procedure are not preserved between different executions of the procedure. This is unlike a process, in which variables maintain their values between executions. Variables within a procedure therefore do not maintain their values over time, unless the procedure is suspended with a wait statement.
See also