• 方案介紹
  • 相關(guān)推薦
申請入駐 產(chǎn)業(yè)圖譜

VIVADO數(shù)字式秒表設計Basys3開發(fā)板Verilog代碼

7小時前
165
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點資訊討論

名稱: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ā)板可以修改管腳適配:

basys3開發(fā)板.png

演示視頻:

工程文件:

6ddfd95d-3032-4c7a-862c-0191ae09eff4.png

程序文件:

efc0aba8-80ef-4e39-8315-f229014fc770.png

程序編譯:

1e09ec6a-c052-41ee-9f1b-6e126593895e.png

RTL圖:

1e73c773-42e9-4dba-be95-2101dd4b715a.png

管腳分配:

0f97384f-4bff-4264-a90d-1a05847ddae3.png

部分代碼展示:

`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

相關(guān)推薦