?? paobiao.v.bak
字號:
/*信號定義:
CLK: CLK 為時鐘信號;
CLR: 為異步復位信號;
PAUSE: 為暫停信號;
MSH,MSL: 百分秒的高位和低位;
SH,SL: 秒信號的高位和低位;
MH,ML: 分鐘信號的高位和低位。 */
module paobiao(clk_odd,pause,clk_odd10,reset_n,dataout,comout);
input clk_odd,clk_odd10,reset_n;
input pause;
output [7:0]dataout;
output [5:0]comout;
reg[3:0] MSH,MSL,SH,SL,MH,ML;
reg[7:0]dataout;
reg[3:0]datac;
reg[5:0]comout;
reg cn1,cn2;
reg[2:0] count1;
//cn1 為百分秒向秒的進位,cn2 為秒向分的進位
//百分秒計數進程,每計滿100,cn1 產生一個進位
always @(posedge clk_odd or negedge reset_n)
begin
if(!reset_n) begin //異步復位
{MSH,MSL}<=8'h00;
cn1<=0;
pause=0;
end
else if(pause) //PAUSE 為1 時正常計數,為0 時暫停計數
begin
if(MSL==9) begin
MSL<=0;
if(MSH==9)
begin MSH<=0; cn1<=1; end
else MSH<=MSH+1;
end
else begin
MSL<=MSL+1; cn1<=0;
end
end
end
//秒計數進程,每計滿60,cn2 產生一個進位
always @(posedge cn1 or negedge reset_n)
begin
if(!reset_n) begin //異步復位
{SH,SL}<=8'h00;
cn2<=0;
end
else if(SL==9) //低位是否為9
begin
SL<=0;
if(SH==5) begin SH<=0; cn2<=1; end
else SH<=SH+1;
end
else
begin SL<=SL+1; cn2<=0; end
end
//分鐘計數進程,每計滿60,系統自動清零
always @(posedge cn2 or negedge reset_n)
begin
if(!reset_n)
begin {MH,ML}<=8'h00; end //異步復位
else if(ML==9) begin
ML<=0;
if(MH==5) MH<=0;
else MH<=MH+1;
end
else ML<=ML+1;
end
always@(posedge clk_odd10 or negedge reset_n)
if(!reset_n)
begin
count1=0;
end
else
begin
count1=count1+1;
end
always@(count1)
begin
case(count1)
3'd0:begin comout=6'b111110;datac=MSL;end
3'd1:begin comout=6'b111101;datac=MSH;end
3'd2:begin comout=6'b111011;datac=SL; end
3'd3:begin comout=6'b110111;datac=SH; end
3'd4:begin comout=6'b101111;datac=ML; end
3'd5:begin comout=6'b011111;datac=MH; end
default begin comout=6'b111110;datac=MSL;end
endcase
end
always@(datac)
case(datac)
4'h0:dataout=8'hc0;
4'h1:dataout=8'hf9;
4'h2:dataout=8'ha4;
4'h3:dataout=8'hb0;
4'h4:dataout=8'h99;
4'h5:dataout=8'h92;
4'h6:dataout=8'h82;
4'h7:dataout=8'hf8;
4'h8:dataout=8'h80;
4'h9:dataout=8'h90;
default:dataout=8'hc0;
endcase
endmodule
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -