Skip to content
UPEEC

Verilog

A C-like HDL for modelling and synthesising digital logic.

Advanced
Comments 0
module counter (
    input  wire       clk,
    input  wire       rst,
    output reg  [3:0] count
);
    always @(posedge clk) begin
        if (rst) count <= 4'd0;
        else     count <= count + 1;
    end
endmodule

Key ideas: modules with ports, wire (connections) and reg (stored values), assign for combinational logic and always @(posedge clk) for sequential logic. Test with a testbench in a simulator such as Icarus Verilog or ModelSim.

Sub-topics (1)

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.