源程序再发一次:
module counter(clk,clr,out);
input clk;
input clr;
output out;
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’h456)
begin
out<=1’b1;
end
end
end
endmodule