There are two alternate task declaration syntaxes.
a) The first syntax shall begin with the keyword task, followed by a name for the task and a semicolon, and ending with the keyword endtask. Task item declarations can specify the following:
— Input arguments
— Output arguments
— Inout arguments
— All data types that can be declared in a procedural block
Example 1—The following example illustrates the basic structure of a task definition with five arguments:
task my_task;
input a, b;
inout c;
output d, e;
begin
. . . // statements that perform the work of the task
. . .
c = foo1; // the assignments that initialize result regs
d = foo2;
e = foo3;
end
endtask
b) The second syntax shall begin with the keyword task, followed by a name for the task and a parenthesis-enclosed task_port_list. The task_port_list shall consist of zero or more comma separated task_port_items.
task my_task (input a, b, inout c, output d, e);
begin
. . . // statements that perform the work of the task
. . .
c = foo1; // the assignments that initialize result regs
d = foo2;
e = foo3;
end
endtask
Task memory usage and concurrent activation:
A task may be enabled more than once concurrently, variables declared in static tasks, including input, output, and inout type arguments, shall retain their values between invocations.
Variables declared in automatic tasks, including output type arguments, shall be initialized to the default
initialization value whenever execution enters their scope. input and inout type arguments shall be
initialized to the values passed from the expressions corresponding to these arguments listed in the taskenabling statements.
Disabling of named blocks and tasks:
The disable statement provides the ability to terminate the activity associated with concurrently active
procedures, while maintaining the structured nature of Verilog HDL procedural descriptions.
The disable statement can be used within blocks and tasks to disable the particular block or task containing the disable statement. The disable statement can be used to disable named blocks within a function, but cannot be used to disable functions.
Example 1—This example illustrates how a block disables itself.
begin : block_name
rega = regb;
disable block_name;
regc = rega; // this assignment will never execute
end