名稱:出租車自動計費器設(shè)計Verilog代碼vivado? Nexys4開發(fā)板
軟件:vivado
語言:Verilog
代碼功能:
出租車自動計費器設(shè)計要求
設(shè)計一個出租車自動計費器,具有行車?yán)锍逃嬞M等候時間計費及起價三部分,用四位數(shù)碼管顯示總金額,最大值為999.9元。
行車?yán)锍虇蝺r2元/公里,等候時間單價0.5元/10秒,起價10元(1公里起價)。
行車?yán)锍痰挠嬞M電路將汽車行駛的里程數(shù)轉(zhuǎn)換成與之成正比的脈沖數(shù),然后由計數(shù)譯碼電路轉(zhuǎn)換成收費金額,實驗中以一個脈沖模擬汽車前進100米,收費0.2元;用兩個數(shù)碼管顯示行駛公里數(shù)。
FPGA代碼Verilog/VHDL代碼資源下載:www.hdlcode.com
本代碼已在Nexys4開發(fā)板驗證,Nexys4開發(fā)板如下,其他開發(fā)板可以修改管腳適配:
演示視頻:
設(shè)計文檔:
1. 工程文件
2. 程序文件
3. 程序編譯
4. 程序RTL圖
5. 管腳約束
6. Testbench
7. 仿真圖
整體仿真
wheel_second_pluse模塊
taxi_state模塊
Display模塊
部分代碼展示:
module?taxi_fee( input?clk,//標(biāo)準(zhǔn)時鐘,100M input?reset,//復(fù)位信號,低有效? input?stop,//本次行程結(jié)束,停止計費,高有效--按鍵 input?start,//啟動信號,行程開始,高有效?--按鍵 input?Speed,//0:等待??1:行駛--開關(guān) output?led_wheel,//車輪脈沖指示燈 output?[7:0]?bit_select,//數(shù)碼管位選 output?[7:0]?seg_select//數(shù)碼管段選 ); wire?wheel_pulse; wire?second_pulse; wire?one_kilometre;//0.1公里產(chǎn)生一次 wire?[15:0]?totel_money; wire?[15:0]?mileage; wire?[2:0]?state; //模塊例化 //車輪脈沖產(chǎn)生及秒脈沖產(chǎn)生模塊 wheel_second_pluse?U_wheel_second_pluse( .?clk(clk),//標(biāo)準(zhǔn)時鐘,100MHz .?reset(reset),//復(fù)位信號,低有效? .?Speed(Speed),//0:等待??1:行駛 .?state(state), .?led_wheel(led_wheel), .?wheel_pulse(wheel_pulse),?//?車輪脈沖,10個1公里,100米一次 .?second_pulse(second_pulse)?////10秒脈沖 ); taxi_state?U_taxi_state( .?clk(clk),//標(biāo)準(zhǔn)時鐘,100M? .?reset(reset),//復(fù)位信號,低有效? .?stop(stop),//本次行程結(jié)束,停止計費,高有效 .?start(start),//啟動信號,行程開始,高有效? .?Speed(Speed),//0:等待??1:行駛 .?one_kilometre(wheel_pulse),//0.1公里產(chǎn)生一次 .?second_pulse(second_pulse),////10秒脈沖 .?state_out(state), .?mileage_out(mileage), .?totel_money_out(totel_money)//合計費用 ); display?U_display( .?clk(clk),//標(biāo)準(zhǔn)時鐘,100M? .?totel_money(totel_money),//費用 .?mileage(mileage),//里程 .?bit_select(bit_select),//數(shù)碼管位選 .?seg_select(seg_select)//數(shù)碼管段選 ); endmodule
點擊鏈接獲取代碼文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=469