module counter #( parameter BITS = 8 )( input clk, input reset, output reg [BITS-1:0] y ); always @(posedge clk or posedge reset) begin if (reset) begin y <= 0; end else begin y <= y + 1; end end endmodule