1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
module Counter ( input CLK, input RESET, output reg [3:0] OUT, output TC ); assign TC = OUT == 9; always @(posedge CLK) begin if (RESET == 1 || OUT == 9) OUT <= 0; else OUT <= OUT + 1; end initial begin OUT <= 11; end endmodule