• 方案介紹
  • 附件下載
  • 相關(guān)推薦
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

簡(jiǎn)單秒表設(shè)計(jì)仿真verilog跑表

加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論

1-2310192311319E.doc

共1個(gè)文件

名稱:簡(jiǎn)單秒表設(shè)計(jì)仿真(代碼在文末付費(fèi)下載)

軟件:Quartus

語言:Verilog

代碼功能:

秒表顯示最低計(jì)時(shí)為10ms,最大為59:99,超出返回00:00,具有復(fù)位、啟動(dòng)、暫停三個(gè)按鍵,四個(gè)數(shù)碼管分別顯示4個(gè)時(shí)間數(shù)字。

演示視頻:

FPGA代碼資源下載網(wǎng):hdlcode.com

部分代碼展示

module?stopwatch(
input?clk,//100Hz--對(duì)應(yīng)10ms
input?start_key,//啟動(dòng)
input?stop_key,//暫停
input?reset_key,//復(fù)位
output?reg?[7:0]?display0,//輸出數(shù)碼管顯示
output?reg?[7:0]?display1,//輸出數(shù)碼管顯示
output?reg?[7:0]?display2,//輸出數(shù)碼管顯示
output?reg?[7:0]?display3//輸出數(shù)碼管顯示
);
parameter?idle_state=3'd0;
parameter?cnt_time_state=3'd1;
parameter?hold_time_state=3'd2;
parameter?reset_time_state=3'd3;
reg?[2:0]?state=3'd0;
//計(jì)時(shí)狀態(tài)機(jī)
always@(posedge?clk)
if(reset_key)
state<=reset_time_state;//復(fù)位狀態(tài)
else
case(state)
reset_time_state://復(fù)位狀態(tài)
state<=idle_state;
idle_state://空閑狀態(tài)
if(start_key)
state<=cnt_time_state;
else
state<=idle_state;
cnt_time_state://計(jì)時(shí)狀態(tài)
if(stop_key)
state<=hold_time_state;
else
state<=cnt_time_state;
hold_time_state://暫停狀態(tài)
if(start_key)
state<=cnt_time_state;
else
state<=hold_time_state;
default:;
endcase
reg?[7:0]?Millisecond_cnt=8'd0;//10毫秒
reg?[7:0]?second_cnt=8'd0;//秒
always@(posedge?clk)
if(state==reset_time_state)//復(fù)位狀態(tài)
second_cnt<=8'd0;
else
if(state==cnt_time_state)//計(jì)時(shí)狀態(tài)
if(Millisecond_cnt==8'd99)//990ms時(shí)向前記1秒
if(second_cnt<8'd59)
second_cnt<=second_cnt+8'd1;//計(jì)時(shí)到990ms,下一次就到1秒了

設(shè)計(jì)文檔:

1.工程文件

2.程序代碼

3.程序運(yùn)行

4.Testbench

5.仿真圖

秒表顯示最低計(jì)時(shí)為10ms,最大為59:99,超出返回00:00

具有復(fù)位、啟動(dòng)、暫停三個(gè)按鍵

四個(gè)數(shù)碼管分別顯示4個(gè)時(shí)間數(shù)字。

1、整體仿真圖

2、復(fù)位功能

3、啟動(dòng)按鍵

4、暫停按鍵

5、10ms毫秒計(jì)時(shí)

6、秒計(jì)時(shí)

點(diǎn)擊鏈接獲取代碼文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=200

  • 1-2310192311319E.doc
    下載

相關(guān)推薦