always @(posedge clk)
begin
clkcount=clkcount+1'b1;
end
always @ (clkcount[23])
begin
if(key==0) // //当按键按下时
begin
if(readkey>=2) //当检测到2次按键信号时
begin
if(keystate==KEYUP)
begin
keystate=2;
dbuf=dbuf+1;
odata=dbuf;
led1=~led1;
led2=1;
readkey=0;
end
end
else
begin
readkey=readkey+1;
if(keystate==KEYDOWN)
begin
keystate=KEYHOLD;
readkey=0;
end
end
end
else
begin
readkey=0;
keystate=KEYUP;