module key(clk,key_in,key_out);
input clk;
input[3:0]key_in;//按键输入
output[3:0]key_out;
reg[3:0]dout1,dout2,dout3;
reg[3:0]a;
reg i;
//assign key_out=a;
always@(posedge clk)//按键消抖
begin
dout1<=key_in;
dout2<=dout1;
dout3<=dout2;
a<=(dout1|dout2|dout3);
end
always@(posedge clk)
begin
if(a[0]==0) i=i+1;//按键按下,计一次数
end
endmodule
怎么改,在每按一次键时,i只加1? |