概述
思路:是从秒的后四位开始推,知道时针的十位
module top_module(
input clk,
input reset,
input ena,
output pm,
output [7:0] hh,
output [7:0] mm,
output [7:0] ss);
reg pm_temp;
wire mmm;
always@(posedge clk)
if(reset)begin
ss[3:0]<=0;
//pm<=0;
end
else if(ena==0)
ss[3:0]<=ss[3:0];
else if(ss[3:0]==4'd9)
ss[3:0]<=0;
else
ss[3:0]<=ss[3:0]+1'd1;
always@(posedge clk)
if(reset)
ss[7:4]<=0;
else if(ss[3:0]==4'd9&&ss[7:4]<4'd5&&ena==1'd1)
ss[7:4]<=ss[7:4]+1'd1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5)
ss[7:4]<=0;
/*else if(ena==0)
ss[7:4]<=ss[7:4];*/
else
ss[7:4]<=ss[7:4];
always@(posedge clk)
if(reset)
mm[3:0]<=0;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]<4'd9)
mm[3:0]<=mm[3:0]+1'd1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9)
mm[3:0]<=0;
else
mm[3:0]<=mm[3:0];
always@(posedge clk)
if(reset)
mm[7:4]<=0;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]<4'd5)
mm[7:4]<=mm[7:4]+1'd1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5)
mm[7:4]<=0;
else
mm[7:4]<=mm[7:4];
always@(posedge clk)
if(reset)
hh[3:0]<=2;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[7:4]==4'd0&&hh[3:0]<4'd9)
hh[3:0]<=hh[3:0]+1'b1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[7:4]==1'd1&&hh[3:0]<4'd2)
hh[3:0]<=hh[3:0]+1'b1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[3:0]==4'd2&&hh[7:4]==4'd1)
hh[3:0]<=1'd1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[3:0]==4'd9)
hh[3:0]<=0;
else
hh[3:0]<=hh[3:0];
always@(posedge clk)
if(reset)
hh[7:4]<=1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[3:0]==4'd9&& hh[7:4]==4'd0)
hh[7:4]<=hh[7:4]+1'd1;
else if(ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[3:0]==4'd2&&hh[7:4]==4'd1)
hh[7:4]<=1'd0;
else
hh[7:4]<=hh[7:4];
always@(posedge clk)
if(reset)
pm_temp<=0;
else if(mmm)
pm_temp<=~pm_temp;
assign mmm = ss[3:0]==4'd9&&ss[7:4]==4'd5&&mm[3:0]==4'd9&&mm[7:4]==4'd5&&hh[3:0]==4'd1&&hh[7:4]==4'd1;
assign pm=pm_temp;
endmodule
最后
以上就是傲娇马里奥为你收集整理的hdlbits:Count clock-12_hour clock 答案参考的全部内容,希望文章能够帮你解决hdlbits:Count clock-12_hour clock 答案参考所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复