module counter(input clk, input rst, output reg [3:0] q);
always @(posedge clk) begin
if (rst) q <= 4'd0;
else q <= q + 4'd1;
end
endmodule
Four flip-flops hold q. The + 1 becomes a few lookup tables (LUTs) feeding each flip-flop's input. Non-blocking <= means "all updates happen at the clock edge, together".
It wraps from 15 to 0 on its own: 4 bits, no extra code.