名稱:VIVADO數(shù)字式秒表設計Basys3開發(fā)板Verilog代碼(代碼在文末下載)
軟件:VIVADO
語言:Verilog
代碼功能:
數(shù)字式秒表:
設計一個數(shù)字秒表電路。設計要求:
(1)計時范圍0:00.0~9:59.9″,分辨率為0.1s,用數(shù)碼管顯示計時值。
(2)秒表設有一個功能按鍵開關(guān) ButtonIn。
當電路處于“初始”狀態(tài)時,第一次按鍵,開始自動計時,再次按鍵,停止計時,第三次按鍵,計數(shù)器自動復位為0:00.0,即電路回到初始狀態(tài)。
FPGA代碼Verilog/VHDL代碼資源下載:www.hdlcode.com
本代碼已在Basys3開發(fā)板驗證,開發(fā)板如下,其他開發(fā)板可以修改管腳適配:
演示視頻:
工程文件:
程序文件:
程序編譯:
RTL圖:
管腳分配:
部分代碼展示:
`timescale?1ns?/?1ps //控制模塊 module?control(clk,in,reset,clr,count); //?Inputs input?clk; input?in;//按鍵輸入 input?reset;//復位輸入 //?Outputs output?clr; output?count; reg?clr=1; reg?count=0; reg?[1:0]?state=2'd0; parameter?s_RESET=2'd0; parameter?s_TIMING=2'd1; parameter?s_STOP=2'd2; always@(posedge?clk?or?posedge?reset) if(reset==1)//復位 state<=s_RESET; else case(state) s_RESET://初始狀態(tài) if(in==1)//按鍵輸入 state<=s_TIMING;//計時狀態(tài) else state<=s_RESET;//初始狀態(tài) s_TIMING://計時狀態(tài) if(in==1)//按鍵輸入 state<=s_STOP;//停止狀態(tài) else state<=s_TIMING;//計時狀態(tài) s_STOP://停止狀態(tài) if(in==1)//按鍵輸入 state<=s_RESET;//初始狀態(tài) else state<=s_STOP;//停止狀態(tài) default:; endcase always@(*) if(reset==1)//復位 begin clr=1; count=0; end else case(state) s_RESET://初始狀態(tài) begin clr=1; count=0; end s_TIMING://計時狀態(tài) begin clr=0; count=1; end s_STOP://停止狀態(tài) begin clr=0; count=0; end default:; endcase endmodule
點擊鏈接獲取代碼文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=298
閱讀全文