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

logic: Example 3: Driven Purely from a Continuous Assign

SystemVerilog Data Types

Runnable example from the SystemVerilog logic tutorial (Example 3: Driven Purely from a Continuous Assign)

Open in IDE
testbench.sv
module tb;
  logic a, b;
  logic y_and, y_or, y_xor;

  // All three outputs are driven only by continuous assigns
  assign y_and = a & b;
  assign y_or  = a | b;
  assign y_xor = a ^ b;

  initial begin
    a = 1'b0; b = 1'b0; #1;
    $display ("a=%0b b=%0b  and=%0b or=%0b xor=%0b", a, b, y_and, y_or, y_xor);

    a = 1'b1; b = 1'b0; #1;
    $display ("a=%0b b=%0b  and=%0b or=%0b xor=%0b", a, b, y_and, y_or, y_xor);

    a = 1'b1; b = 1'b1; #1;
    $display ("a=%0b b=%0b  and=%0b or=%0b xor=%0b", a, b, y_and, y_or, y_xor);
  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.