module timer(clk_1k,reset,run,cnte0,cnte1,cnte2,cnte3,cnte4,cnte5);
input clk_1k,reset,run;
output reg [3:0] cnte0,cnte1,cnte2,cnte3,cnte4,cnte5;
reg clk_100;
reg [31:0] cnt;
always@(posedge clk_1k) begin
if(cnt==5) begin
cnt<=0;clk_100<=~clk_100;end
else cnt<=cnt+1;
end
always @(posedge clk_100 or negedge reset) begin
if(!reset) begin cnte0<=0;cnte1<=0;cnte2<=0;
cnte3<=0;cnte4<=0;cnte5<=0;end
else begin
if(run) begin
if((cnte5==5)&&(cnte4==9)&&(cnte3==5)&&(cnte2==9)&&(cnte1==9)&&(cnte0==9))
begin cnte0<=0;cnte1<=0;cnte2<=0;cnte3<=0; cnte4<=0;cnte5<=0;end
else begin
if((cnte4==9)&&(cnte3==5)&&(cnte2==9)&&(cnte1==9)&&(cnte0==9))
begin cnte0<=0; cnte1<=0; cnte2<=0; cnte3<=0;cnte4<=0; cnte5<=1+cnte5; end
else begin
if((cnte3==5)&&(cnte2==9)&&(cnte1==9)&&(cnte0==9))
begin cnte0<=0; cnte1<=0; cnte2<=0; cnte3<=0;cnte4<=1+cnte4; cnte5<=cnte5;end
else begin
if((cnte2==9)&&(cnte1==9)&&(cnte0==9))
begin cnte0<=0; cnte1<=0; cnte2<=0; cnte3<=1+cnte3;cnte4<=cnte4;cnte5<=cnte5;end
else begin
if((cnte1==9)&&(cnte0==9))
begin cnte0<=0; cnte1<=0; cnte2<=1+cnte2; cnte3<=cnte3;cnte4<=cnte4;cnte5<=cnte5; end
else begin
if((cnte0==9))
begin cnte0<=0; cnte1<=1+cnte1; cnte2<=cnte2; cnte3<=cnte3;cnte4<=cnte4;cnte5<=cnte5; end
else begin cnte0<=1+cnte0; cnte1<=cnte1; cnte2<=cnte2; cnte3<=cnte3;cnte4<=cnte4;cnte5<=cnte5;end
end
end
end
end
end
end
end
end
endmodule
4位全加器 计数器等程序.rar_12分频器_EDA_EDA篮球计数器_分频器EDA
版权申诉
5星 · 超过95%的资源 61 浏览量
2022-09-23
03:09:55
上传
评论 1
收藏 2KB RAR 举报
刘良运
- 粉丝: 66
- 资源: 1万+