//产生秒钟计数
module miaojishi(clks,clr,cpm,s_high,s_low,cm);
input clks;
input clr;
input cpm;
output s_high;
output s_low;
output cm;
reg[3:0] s_high;
reg[3:0] s_low;
reg[3:0] cm;
always@(posedge clks or negedge clr)
begin
if(!clr) //清零信号,将计数清零
begin
s_high<=4'd0;
s_low<=4'd0;
cm<=4'd0;
end
else
begin
if(s_low==4'd9&&s_high<4'd5) //如果分秒低位等于9时
begin
s_high<=s_high+1;
s_low<=4'd0;
cm<=4'd0;
end
else if(s_low<4'd9&&s_high<=4'd5) //如果分秒低位小于9时
begin
s_high<=s_high;
s_low<=s_low+1;
cm<=4'd0;
end
else if(s_low==4'd9&&s_high==4'd5) //如果为59时,产生进位
begin
s_high<=4'd0;
s_low<=4'd0;
cm<=4'd1;
end
end
end
endmodule
就是如何加一个电平触发。使他可以调时间
此帖出自
小平头技术问答
if(电平)
如果是按一下起一次作用就采沿,采个上升沿或者下降沿,要去抖
就是要按下一直有效的,这样就可以少一个去抖了。谢谢
一周热门 更多>