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

Operators: Verilog Arithmetic Operators

Verilog Examples

Runnable example from the Verilog Operators tutorial (Verilog Arithmetic Operators)

Open in IDE
testbench.v
module des;
 reg [7:0] data1;
 reg [7:0] data2;

 initial begin
 data1 = 45;
 data2 = 9;
 $display ("Result for data1 >= data2 : %0d", data1 >= data2); // 45 >= 9 -> 1 (true)

 data1 = 45;
 data2 = 45;
 $display ("Result for data1 <= data2 : %0d", data1 <= data2); // 45 <= 45 -> 1 (true)

 data1 = 9;
 data2 = 8;
 $display ("Result for data1 > data2 : %0d", data1 > data2); // 9 > 8 -> 1 (true)

 data1 = 22;
 data2 = 22;
 $display ("Result for data1 < data2 : %0d", data1 < data2); // 22 < 22 -> 0 (false)
 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.