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

Display Tasks: Verilog Format Specifiers

Verilog Examples

Runnable example from the Verilog Display Tasks tutorial (Verilog Format Specifiers)

Open in IDE
testbench.v
module tb;
  reg [7:0]  a;
  reg [39:0] str = "Hello";
  time       cur_time;
  real       float_pt;

  initial begin
    a = 8'h0E;
    float_pt = 3.142;

    $display ("a = %h", a);
    $display ("a = %d", a);
    $display ("a = %b", a);

    $display ("str = %s", str);
    #200 cur_time = $time;
    $display ("time = %t", cur_time);
    $display ("float_pt = %f", float_pt);
    $display ("float_pt = %e", float_pt);
  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.