System display tasks

LRM §14.1.

System display tasks write text to the standard output or a file.

Syntax:

$display([ mcd, ] "text", signal, signal, ...);
$write( [ mcd, ] "text", signal, signal, ...);
$strobe( [ mcd, ] "text", signal, signal, ...);
$monitor( [ mcd, ] "text", signal, signal, ...);

mcd = expression       // multi-channel descriptor

Description:

$display and $write prints the text when the statement is executed during simulation. The only difference between the two is that $display writes out a newline character at the end of the text, whereas $write does not.

$strobe prints the text when all simulation events in the current time step have executed. A newline is automatically added to the text.

$monitor prints the text whenever one of the signals in the signal list changes. A newline is automatically added to the text.

The text may contain format specifiers. If so, each text must be followed by enough signals to provide values for all the format specifiers. The following format specifiers are allowed in the text:

%b or %B

Binary format

%d or %D

Decimal format (default)

%h or %H

Hexadecimal format

%o or %O

Octal format

%e or %E

Real in exponential format

%f or %F

Real in decimal format

%g or %G

Real in decimal or exponential format (shortest result)

%c or %C

Character

%s or %S

String

%t or %T

Time format

%m or %M

Hierarchical name

%v or %V

Net signal strength

After the % character a minimum field width value may be include (e.g. %6d). A minimum field width of zero means that the field will always be just big enough to display the value. The %e and %f may specify the field width for both sides of the decimal point (e.g. %6.2f).

The text may also include the following escaped characters:

\n

Newline

\t

Tab

\\

Backslash

\ddd

Octal code

%%

Percent sign

If the signal list contains two adjacent commas, a space is written out at that point.

Example:

$display("The binary value of A is: %b", A);
$write("The register values are: ", Reg1,, Reg2,, Reg3, "\n");

initial begin
  A = 0;
  $display(A);      // displays 0
  $strobe(A);       // displays 1
  A = 1;
end

Notes:

See also:

File I/O tasks