1 2 3 4 5 6 7 8 9 10 11 12
module top ( input clk, output reg [7:0] cnt ); initial cnt = 0; always @(posedge clk) begin if (cnt < 20) cnt <= cnt + 1; else cnt <= 0; end endmodule