Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

Timescale: Printing Time: $time, $realtime and $timeformat

Verilog Examples

Runnable example from the Verilog Timescale tutorial (Printing Time: $time, $realtime and $timeformat)

Open in IDE
testbench.v
`timescale 1ns/1ps

module tb;
  initial begin
    #1.49;
    $display ("$time=%0d  $realtime=%0f", $time, $realtime);
    $display ("%%t of $time=%0t  %%t of $realtime=%0t", $time, $realtime);
  end
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.