Task Statements

You can call a task simply by giving its name and its parameter list. For example:

checkValue(measured, expected, 10m, "V(out), tests, failures);

The task can either be a user-defined task like the one above, or it can be a system-defined task, such as $display(), $strobe() or $finish().

User Tasks

User tasks are explicitly defined by the user.

System Tasks

System tasks are predefined and provided by the simulator.

Write Output ($display, $strobe, $monitor, $write)

The $display() and $strobe() tasks takes a list of arguments and converts them into text that is written to the standard output. The first argument must be a string, and that string may include special character patterns that incorporate and format any remaining arguments. Those characters are given below. Once the arguments associated with the first string are exhausted, if there are any arguments remaining, the first must be a string, in which case the process repeats. Once the arguments have been printed, a newline is added. If there are no arguments, only the newline is printed.

Argument formatting codes for the display tasks.
Code Args Result
%b , %B 1 Interpolate integer argument with binary format.
%c , %C 1 Interpolate integer argument with ASCII character format.
%d , %D 1 Interpolate integer argument with decimal format.
%e , %E 1 Interpolate real argument with exponential format.
%f , %F 1 Interpolate real argument with decimal format.
%g , %G 1 Interpolate real argument with exponential or decimal format.
%h , %H 1 Interpolate integer argument with hexadecimal format.
%m , %M 0 Display hierarchical instance name.
%o , %O 1 Interpolate integer argument with octal format.
%r , %R 1 Interpolate real argument and display using SI scale factors.
%s , %S 1 Interpolate argument as a string.
%% 0 Display ‘%’ .


$strobe("Average period = %rs measured from %d periods.", period, total);

The format codes generally support C language style format specifications. Optional integers can be inserted into the format code to specify the field width, the precision, or both. For example, the format specification ‘%10.3g’ indicates the number should be formatted with a minimum field width of 10 and with 3 digits in the mantissa.


The Cadence AMS simulator only supports %r and %R codes from within analog processes.

Display statements are evaluated and print a result immediately upon being called. As such, if the process they are contained in experiences a delta cycle, they may generate multiple outputs at the same instant of time. In this situation, it may print values that have not been completely resolved.

The evaluation of any expressions contained within a strobe statement is deferred until the process they are contained within blocks. Thus the values printed are not the ones that existed when the strobe statement is encountered, they are the ones that exist as the processes encounters the next delay, event, or wait statement, or any blocking assignment statement that contains a delay.

For example:

always (posedge clk) begin
   a = 1;
   $display("display: a=%d", a);
   $strobe("strobe: a=%d", a);
   a = 42;

At every rising clock edge this process produces:

display: a=1
strobe: a=42

Monitor statements ($monitor) are similar to strobe statements, except they print a result whenever the expressions they contain change.

Write statements ($write) are identical to strobe statements, except newlines are not added unless explicitly specified in the format strings.

The $fdisplay, $fstrobe, $fmonitor, and $fwrite tasks are similar to the $display, $strobe, and $monitor tasks except they take a multichannel descriptor as the first argument and so can be used to write directly to files.

$finish, $stop

The $finish function terminates the simulation session. It takes an integer argument that indicates the message that should be printed. If 0, nothing is printed, if 1, the time and location are printed (the default behavior), and if 2, time and location are printed along with memory and CPU statistics:


The $stop function is similar to $finish, except that it causes the simulation to be suspended rather than terminated. The difference being that the user may resume simulation after it has been suspended, but cannot do so after it has been terminated: