reg[7:0] samp;//移位寄存器采集button键值
//移位寄存器采集button信息
always@(posedge clk or negedge rst)
begin
if(!rst)
samp<=8'b1111_1111;
else
samp<={samp[7:1],button};
end
//产生上升沿信息
always@(posedge clk or negedge rst)
begin
if(!rst)
rise<=1'b0;
else if(samp==8'b1111_1110)
rise<=1'b1;
else
rise<=1'b0;
end
//产生下降沿信息
always@(posedge clk or negedge rst)
begin
if(!rst)
fall<=1'b0;
else if(samp==8'b0111_1111)
fall<=1'b1;
else
fall<=1'b0;
end