Procedures
|
A procedure defines a group of sequential statements executed when the procedure is called. A procedure can return any number of values (or no values) via its parameter list. A procedure call invokes the execution of the procedure body. |
||
|
PROCEDURE procedure_name [(formal_parameters)] IS …declarations BEGIN …sequential statements END [PROCEDURE] [procedure_name]; … procedure_name[actual_parameters] -- procedure call |
||
|
formal_parameters |
Specifies a list of parameters (constants, signals, or variables with the mode in, out, or inout). |
|
|
declarations |
Declarations include data types, constants, signals, files, variables, attributes, and subprograms. |
|
|
sequential statements |
Statements that are executed in the order in which they appear, that define algorithms for the execution of a subprogram or process. |
|
|
-- declaration with formal parameters int and bin PROCEDURE int2bin (VARIABLE int: IN INTEGER; VARIABLE bin: OUT BIT_VECTOR) IS VARIABLE temp: INTEGER; BEGIN -- start of sequential procedure statements temp := int; FOR i IN 0 TO (bin'LENGTH -1) LOOP IF (temp mod 2 = 1) THEN bin(i) := '1'; ELSE bin(i) := '0'; END IF; temp := temp/2; END LOOP; END int2bin; -- end of sequential procedure statements … PROCESS -- continued model description VARIABLE in_var: INTEGER:=10; VARIABLE out_vec: BIT_VECTOR (1 to 8); BEGIN -- procedure call with actual parameters int_var and out_vec int2bin (in_var, out_vec); WAIT; END PROCESS; |
||