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

initial Block: Common Beginner Mistakes

Verilog Examples

Runnable example from the Verilog initial Block tutorial (Common Beginner Mistakes)

Open in IDE
testbench.v
module counter (input clk, output reg [3:0] count);
    initial count = 0; // WRONG: Not synthesizable!

    always @(posedge clk)
        count <= count + 1;
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.