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

ifdef elsif Macro

Verilog Conditional Compilation

ifdef elsif Macro — a ready-to-run Verilog example.

Open in IDE
testbench.v
module tb;
  initial begin

`ifdef MACRO1
    $display ("This is MACRO1");

`elsif MACRO2
    $display ("This is MACRO2");

`endif
  end
endmodule
design.v
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.