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: Bitwise OR (|) Truth Table

Verilog Examples

Runnable example from the Verilog Operators tutorial (Bitwise OR (|) Truth Table)

Open in IDE
testbench.v
module des;
 reg data1 [0:3];
 reg data2 [0:3];
 integer i, j;

 initial begin
 // Initialize test values: 0, 1, x, z
 data1[0] = 0; data2[0] = 0;
 data1[1] = 1; data2[1] = 1;
 data1[2] = 'x; data2[2] = 'x;
 data1[3] = 'z; data2[3] = 'z;

 // Test bitwise AND across all combinations
 for (i = 0; i < 4; i = i + 1) begin
 for (j = 0; j < 4; j = j + 1) begin
 $display ("data1(%0d) & data2(%0d) = %0d", data1[i], data2[j], data1[i] & data2[j]);
 end
 end
 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.