Differences between Tasks and Functions Tasks and functions serve different purposes in Verilog. We discuss tasks and functions in greater detail in the following sections. However, first it is important to understand differences between tasks and functions, as outlined in Table 8-1. Table 8-1. Tasks and Functions Functions A function can enable another function but not another task. Functions always execute in 0 simulation time. Functions must not contain any delay, event, or timing control statements. Functions must have at least one input argument. They can have more than one input. Functions always return a single value. They cannot. | Differences between Tasks and Functions Tasks and functions serve different purposes in Verilog. We discuss tasks and functions in greater detail in the following sections. However first it is important to understand differences between tasks and functions as outlined in Table 8-1. Table 8-1. Tasks and Functions Functions Tasks A function can enable another function but not another task. A task can enable other tasks and functions. Functions always execute in 0 simulation time. Tasks may execute in non-zero simulation time. Functions must not contain any delay event or timing control statements. Tasks may contain delay event or timing control statements. Functions must have at least one input argument. They can have more than one input. Tasks may have zero or more arguments of type input output or inout. Functions always return a single value. They cannot have output or inout arguments. Tasks do not return with a value but can pass multiple values through output and inout arguments. Both tasks and functions must be defined in a module and are local to the module. Tasks are used for common Verilog code that contains delays timing event constructs or multiple output arguments. Functions are used when common Verilog code is purely combinational executes in zero simulation time and provides exactly one output. Functions are typically used for conversions and commonly used calculations. Tasks can have input output and inout arguments functions can have input arguments. In addition they can have local variables registers time variables integers real or events. Tasks or functions cannot have wires. Tasks and functions contain behavioral statements only. Tasks and functions do not contain always or initial statements but are called from always blocks initial blocks or other tasks and functions. Team LiB Team LiB Tasks Tasks are declared with the keywords task and endtask. Tasks must be used if any one of the following conditions is true for the procedure There are