數(shù)字鐘單元電路設計
Quartus Ⅱ安裝包
鏈接:https://pan.baidu.com/s/12NbAX8J6XBZ7SQAxSj4H_A
提取碼:cokm
主要內容:
1.數(shù)字鐘系統(tǒng)具有時鐘、清零和校準輸入信號;
2.在系統(tǒng)時鐘信號(1Hz)作用下,能顯示時、分、秒;
3.時/分/秒計數(shù)器為24進制/60進制/60進制;
4.系統(tǒng)可以對時、分校準。校準信號有兩個,一為校準時鐘輸入,一為校準控制輸入;
5.系統(tǒng)具有整點報時功能。當時間為59’58’‘、59’59’'時,系統(tǒng)報時各響一聲(低音),持續(xù)0.5秒;整點系統(tǒng)響一聲(高音),持續(xù)1秒;
6.采用原理圖輸入方式設計數(shù)字鐘單元電路頂層文件 ;下載測試。
分頻
module fenpin(CP,CPout);
input CP;
output CPout;
reg CPout;
reg [31:0]Cout;
reg CP_En;
always @(posedge CP)
begin
Cout<=(Cout == 32'd50000)?32'd0:(Cout+32'd1);
CP_En<=(Cout == 32'd50000)?1'd1:1'd0;
CPout<=CP_En;
end
endmodule
控制器
module kongzhiqi(CPout,CP,S1,S2,RET,Hour,Minute,Second,sound);
input CPout,CP,S1,S2,RET;
output [5:0] Hour;
output [5:0] Minute;
output [5:0] Second;
output sound;
reg [5:0] Hour;
reg [5:0] Minute;
reg [5:0] Second;
reg R1;
reg R2,R8,sound;
reg [10:0] Cout;
reg [31:0] C1;
reg Clk_En;
reg clk_2000;
reg cp_n;
reg c_1hz,c_2hz,c_1000hz;
reg i;
integer n2=25000000;
integer h2=25000000;
always@(posedge CP)
begin
C1<=(C1==32'd25000)?32'd0:(C1+32'd1);
cp_n<=(Cout==32'd25000)?1'd1:1'd0;
clk_2000<=cp_n;
end
always@(posedge CP)
if(h2<n2/2-1)h2=h2+1;
else
begin
c_2hz=~c_2hz;
h2=0;
end
always@(posedge c_2hz)
begin
if(!i)i=1;
else i=0;
end
always @(posedge CPout)
begin
if(S1==0)
begin
R1=1;
end
if(S2==0)
begin
R2=1;
end
if(RET==0)
begin
R8=1;
end
Cout=(Cout==32'd1000)?32'd0:(Cout + 32'd1);
Clk_En=(Cout==32'd1000)?1'd1:1'd0;
if(Clk_En)
begin
if(R1==1)
begin
if(Hour<24)
Hour=Hour+1;
if(Hour==24)
begin
Hour=0;
end
R1=0;
end
if(R2==1)
begin
if(Minute<60)
Minute=Minute+1;
if(Minute==60)
begin
Minute=0;
if(Hour<24)
Hour=Hour+1;
if(Hour==24)
begin
Hour=0;
end
end
R2=0;
end
if(Second<60)
Second= Second+1;
if(Second==60)
begin
Second=0;
if(Minute<60)
Minute= Minute+1;
if(Minute==60)
begin
Minute=0;
if(Hour<24)
Hour=Hour+1;
if(Hour==24)
begin
Hour=0;
end
end
end
if(R8==1)//清零
begin
Hour=0;
Minute=0;
Second=0;
R8=0;
end
end
end
always@(Minute,Second)
begin
if((Minute==59)&&(Second==58 )&& (i==1))
sound=c_2hz;
else if((Minute==59)&&(Second==58 )&&( i==0) )
sound=0;
else if((Minute==59)&&(Second==59 )&& (i==1) )
sound=c_2hz;
else if((Minute==59)&&(Second==59 )&& (i==0) )
sound=0;
//if((Minute==59)&&(Second>57))//整點倒計時
// sound=c_2hz;
else if((Minute==0)&&(Second==0))
sound=~clk_2000;
else sound=0;
end
endmodule
顯示文章來源:http://www.zghlxwxcb.cn/news/detail-504504.html
module xianshi(CPout,Hour,Minute,Second,SEL,LEDAG);
input CPout;
input [5:0] Hour,Minute,Second;
output SEL;
output [6:0]LEDAG;
reg [2:0] SEL;
reg [6:0] Led;
reg [3:0] shi1,ge1,shi2,ge2,shi3,ge3;
always @(posedge CPout )
begin
shi1=Hour/10;
ge1=Hour%10;
shi2=Minute/10;
ge2=Minute%10;
shi3=Second/10;
ge3=Second%10;
//if(SEL==3'b110)//8
if(SEL==3'b111)//1
//判斷位選SEL的值,并將此位,上的值輸出到數(shù)碼管
case(shi1)
4'b0000:Led=7'b0111_111;
4'b0001:Led=7'b0000_110;
4'b0010:Led=7'b1011_011;
4'b0011:Led=7'b1001_111;
4'b0100:Led=7'b1100_110;
4'b0101:Led=7'b1101_101;
4'b0110:Led=7'b1111_101;
4'b0111:Led=7'b0000_111;
4'b1000:Led=7'b1111_111;
4'b1001:Led=7'b1101_111;
default:Led=7'b0000_000;
endcase
//if(SEL==3'b101)//7
if(SEL==3'b000)//2
case(ge1)
4'b0000:Led=7'b0111_111;
4'b0001:Led=7'b0000_110;
4'b0010:Led=7'b1011_011;
4'b0011:Led=7'b1001_111;
4'b0100:Led=7'b1100_110;
4'b0101:Led=7'b1101_101;
4'b0110:Led=7'b1111_101;
4'b0111:Led=7'b0000_111;
4'b1000:Led=7'b1111_111;
4'b1001:Led=7'b1101_111;
default:Led=7'b0000_000;
endcase
if(SEL==3'b100) Led=7'b1000_000;
//if(SEL==3'b011)//5
if(SEL==3'b010)//4
case(shi2)
4'b0000:Led=7'b0111_111;
4'b0001:Led=7'b0000_110;
4'b0010:Led=7'b1011_011;
4'b0011:Led=7'b1001_111;
4'b0100:Led=7'b1100_110;
4'b0101:Led=7'b1101_101;
4'b0110:Led=7'b1111_101;
4'b0111:Led=7'b0000_111;
4'b1000:Led=7'b1111_111;
4'b1001:Led=7'b1101_111;
default:Led=7'b0000_000;
endcase
//if(SEL==3'b010)//4
if(SEL==3'b011)//5
case(ge2)
4'b0000:Led=7'b0111_111;
4'b0001:Led=7'b0000_110;
4'b0010:Led=7'b1011_011;
4'b0011:Led=7'b1001_111;
4'b0100:Led=7'b1100_110;
4'b0101:Led=7'b1101_101;
4'b0110:Led=7'b1111_101;
4'b0111:Led=7'b0000_111;
4'b1000:Led=7'b1111_111;
4'b1001:Led=7'b1101_111;
default:Led=7'b0000_000;
endcase
if(SEL==3'b001) Led=7'b1000_000;
//if(SEL==3'b000)//2
if(SEL==3'b101)//7
case(shi3)
4'b0000:Led=7'b0111_111;
4'b0001:Led=7'b0000_110;
4'b0010:Led=7'b1011_011;
4'b0011:Led=7'b1001_111;
4'b0100:Led=7'b1100_110;
4'b0101:Led=7'b1101_101;
4'b0110:Led=7'b1111_101;
4'b0111:Led=7'b0000_111;
4'b1000:Led=7'b1111_111;
4'b1001:Led=7'b1101_111;
default:Led=7'b0000_000;
endcase
//if(SEL==3'b111)//1
if(SEL==3'b110)//8
case(ge3)
4'b0000:Led=7'b0111_111;
4'b0001:Led=7'b0000_110;
4'b0010:Led=7'b1011_011;
4'b0011:Led=7'b1001_111;
4'b0100:Led=7'b1100_110;
4'b0101:Led=7'b1101_101;
4'b0110:Led=7'b1111_101;
4'b0111:Led=7'b0000_111;
4'b1000:Led=7'b1111_111;
4'b1001:Led=7'b1101_111;
default:Led=7'b0000_000;
endcase
SEL= SEL + 3'd1;
end
assign LEDAG=Led;
endmodule
頂層原理圖
管腳鎖定圖文章來源地址http://www.zghlxwxcb.cn/news/detail-504504.html
到了這里,關于EDA技術Verilog HDL語言完成數(shù)字鐘設計的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!