module counter(clk,clr,out); input clk; input clr; output reg out; reg[11:0] cnt; always @(posedge clk or negedge clr) begin if(!clr) begin out <= 1'b0; cnt <= 12'b0; end else begin cnt <= cnt + 1'b1; if(cnt[11:0]==12'h9db) begin cnt <= 12'h0; out <= 1'b0; end else if(cnt[11:0]==12'h9db) begin out <= 1'b1; end end end endmodule