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

'if' without 'else' synthesis

Verilog Conditional Statements

Example shows how 'if' block without 'else' can form a latch

Open in IDE
design.v
module des (  input en,
              input d,
              output reg q);

    always @ (en or d)
        if (en)
            q = d;

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