Difference between $display, $monitor, $write and $strobe in Verilog

Although all $display, $monitor, $write and $strobe in System Verilog seem to be similar, there is a slight difference.

$display is the normal display, which executes its parameters wherever it is present in the code.

$write is similar to $display except that $display displays the contents in the next line (cursor moves to the next line before displaying), unlike $write in which the contents are displayed in the same line.

$strobe executes only once in a time instant, when all processes in that time instant have executed.

$monitor executes only if any of its parameters change (in one time instant).

Example:

Verilog Program:

module d11; 
bit a=0, b=0; 
initial 
begin 
a=0; 
b=1; 
$display(a,b); 
$strobe(a,b); 
b=0; 
a=1; 
$display(a,b); 
$write(a,b); 
$display(a,b); 
#1 b=1; 
end 
initial 
$monitor($time"ns: %b%b",a,b); 
Endmodule

Output:

01

10

1010

10

0ns: 10

1ns: 11

Leave a Reply

Your email address will not be published. Required fields are marked *