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

Cast Static: Real-to-Integer Truncation

SystemVerilog Classes & OOP

Runnable example from the SystemVerilog Cast Static tutorial (Real-to-Integer Truncation)

Open in IDE
testbench.sv
  module tb;
  
	initial begin
    $display("data=%0.3f", int'(3.4 + 2 * 1.5));
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.