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

Timeformat: %t vs %0t and the Minimum Field Width

Verilog Examples

Runnable example from the Verilog Timeformat tutorial (%t vs %0t and the Minimum Field Width)

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

module tb;
  initial begin
    #10.512;
    $display("[T=%t]",  $realtime);    // Default width of 20
    $display("[T=%0t]", $realtime);    // No padding

    $timeformat(-9, 2, " ns", 10);
    $display("[T=%t]",  $realtime);    // Width of 10
  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.