• A procedure can return more than one value.
• Like a FUNCTION, two parts are necessary to construct and use a PROCEDURE:
– the procedure itself (procedure body)
– procedure call
Procedure Body
PROCEDURE procedure_name [
[declarations]
BEGIN
(sequential statements)
END procedure_name;
• A PROCEDURE can have any number of IN, OUT, or INOUT parameters, which can be SIGNALS, VARIABLES, or CONSTANTS. For input signals (mode IN), the default is CONSTANT, whereas for output signals (mode OUT or INOUT) the default is VARIABLE.
• WAIT, SIGNAL declarations, and COMPONENTS are not synthesizable when used in a FUNCTION. The same is true for a PROCEDURE, with the exception that a SIGNAL can be declared, but then the PROCEDURE must be declared in a PROCESS.
• Moreover, besides WAIT, any other edge detection is also not synthesizable with a PROCEDURE (that is, contrary to a function, a synthesizable procedure should not infer registers)
Example
PROCEDURE my_procedure ( a: IN BIT; SIGNAL b,
c: IN BIT;
SIGNAL x: OUT BIT_VECTOR(7 DOWNTO 0);
SIGNAL y: INOUT INTEGER RANGE 0 TO 99) IS
BEGIN
...
END my_procedure;
• The PROCEDURE has three inputs, a, b, and c (mode IN)
• a is a CONSTANT of type BIT, while b and c are SIGNALS, also of type BIT. Notice that the word CONSTANT can be omitted for input parameters, for it is the default object (recall, however, that for outputs the default object is VARIABLE).
• There are also two return signals, x (mode OUT, type BIT_VECTOR) and y (mode INOUT, type INTEGER).
Procedure Call
• Contrary to a FUNCTION, which is called as part of an expression, a PROCEDURE call is a statement on its own.
• It can appear by itself or associated to a statement (either concurrent or sequential).
Examples of procedure calls:
compute_min_max(in1, in2, 1n3, out1, out2);
-- statement by itself
divide (dividend, divisor, quotient, remainder);
-- statement by itself
IF (a>b) THEN compute_min_max(in1, in2, 1n3, out1, out2);
-- procedure call -- associated to another -- statement
information shared by www.irvs.info