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

Data Types: Floating Point/Exponential Numbers

SystemVerilog Data Types

Runnable example from the SystemVerilog Data Types tutorial (Floating Point/Exponential Numbers)

Open in IDE
testbench.sv
module tb;
  real  pi;        // Declared to be of type real
  real  freq;
  
  initial begin
    pi   = 3.14;    // Store floating point number
    freq = 1e6; 	// Store exponential number
  
    $display ("Value of pi = %f", pi);
    $display ("Value of pi = %0.3f", pi);
    $display ("Value of freq = %0d", freq);
  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.