數(shù)字電路(出租車計(jì)費(fèi)器)_第1頁
數(shù)字電路(出租車計(jì)費(fèi)器)_第2頁
數(shù)字電路(出租車計(jì)費(fèi)器)_第3頁
數(shù)字電路(出租車計(jì)費(fèi)器)_第4頁
數(shù)字電路(出租車計(jì)費(fèi)器)_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、一、 課題要求(1) 技術(shù)要求1.掌握較復(fù)雜邏輯的設(shè)計(jì)、調(diào)試。2. 進(jìn)一步掌握用VHDL語言設(shè)計(jì)數(shù)字邏輯電路。3.掌握用quartusII6.0軟件進(jìn)行編程設(shè)計(jì)。(2) 功能要求1.能實(shí)現(xiàn)計(jì)費(fèi)功能,計(jì)費(fèi)標(biāo)準(zhǔn)為:按行駛里程收費(fèi),起步費(fèi)為7.00元,并在車行3公里后再按2.2元/公里,當(dāng)計(jì)費(fèi)器達(dá)到或超過一定收費(fèi)(如20元)。每公里加收50%的車費(fèi),車停止不計(jì)費(fèi)2 .實(shí)現(xiàn)預(yù)置功能、每公里收費(fèi)、車行駛加費(fèi)里程。3.實(shí)現(xiàn)模擬功能:能模擬汽車啟動(dòng)、停止、暫停、車速等狀態(tài)。4. 設(shè)計(jì)動(dòng)態(tài)掃描電路將車費(fèi)顯示出來。有兩位小數(shù)。5. 用VHDL語言設(shè)計(jì)符合上述功能要求的出租車計(jì)費(fèi)器。并用層次化設(shè)計(jì)方法設(shè)計(jì)該電路。

2、6 .各計(jì)數(shù)器的技術(shù)狀態(tài)用功能的方法驗(yàn)證,并用有關(guān)波形確認(rèn)電路設(shè)計(jì)是否正確7. 完成電路全部設(shè)計(jì)后,通過系統(tǒng)試驗(yàn)箱下載驗(yàn)證設(shè)計(jì)課題的正確性。二 本人工作:本人主要負(fù)責(zé)軟件和硬件電路方面的設(shè)計(jì),并進(jìn)行引腳設(shè)定,以及與軟硬件之間的調(diào)試運(yùn)行,及時(shí)修改程序,幫助查找和分析問題,確保能夠成功完成出租車計(jì)費(fèi)器的設(shè)計(jì)。三 設(shè)計(jì)方案:3.1 主要中心組成顯示模塊FPGA按鍵模塊 3.2 FPGA芯片內(nèi)部主要程序:3.3 工作原理:基于CPLDFPGA的出租車計(jì)費(fèi)器的組成如圖1所示。各部分主要功能如下:(1)A計(jì)數(shù)器對(duì)車輪傳感器送來的脈沖信號(hào)進(jìn)行計(jì)數(shù)(每轉(zhuǎn)一圈送一個(gè)脈沖)。不同車型的車輪直徑可能不一樣,通過“設(shè)

3、置1”對(duì)車型做出選擇,以實(shí)現(xiàn)對(duì)不同車輪直徑的車進(jìn)行調(diào)整。(2)B計(jì)數(shù)器對(duì)百米脈沖進(jìn)行累加,并輸出實(shí)際公里數(shù)的BCD碼給譯碼動(dòng)態(tài)掃描模塊。每計(jì)滿500送出一個(gè)脈沖給C計(jì)數(shù)器。“設(shè)置2”實(shí)現(xiàn)起步公里數(shù)預(yù)制。(3)C計(jì)數(shù)器實(shí)現(xiàn)步長(zhǎng)可變(即單價(jià)可調(diào))的累加計(jì)數(shù),每500米計(jì)費(fèi)一次?!霸O(shè)置3”用來完成超價(jià)加費(fèi)、起步價(jià)預(yù)制等。(4)譯碼動(dòng)態(tài)掃描將路程與費(fèi)用的數(shù)值譯碼后用動(dòng)態(tài)掃描的方式驅(qū)動(dòng)數(shù)碼管。(5)數(shù)碼管顯示將公里數(shù)和計(jì)費(fèi)金額均用四位LED數(shù)碼管顯示(2位整數(shù),2位小數(shù))。3.4功能模塊設(shè)計(jì)出租車計(jì)費(fèi)器由車型調(diào)整模塊、計(jì)程模塊、計(jì)費(fèi)模塊、譯碼動(dòng)態(tài)及掃描等模塊組成,整個(gè)系統(tǒng)采用模塊化設(shè)計(jì),首先用VHDL編

4、寫功能模塊,然后用頂層原理圖將各功能模塊連接起來。四 單元模塊設(shè)計(jì):首先出租車計(jì)費(fèi)器的設(shè)計(jì)需要分頻,所以需要設(shè)計(jì)了兩個(gè)頻率:4.1 oneMHZ:由于給定的50MHZ太大,這個(gè)程序完成5000分頻,實(shí)現(xiàn)第一次分頻,確保實(shí)現(xiàn)動(dòng)態(tài)計(jì)數(shù),并且保證頻率在驅(qū)動(dòng)范圍之內(nèi)。library ieee;use ieee.std_logic_1164.all;entity oneMHZ is port( daclk:in std_logic; clkout:out std_logic); end oneMHZ;architecture one of oneMHZ issignal data:integer ran

5、ge 0 to 5000;signal Q:std_logic;beginprocess(daclk) begin if daclk'event and daclk='1' then if(data=5000) then data<=0; Q<=not Q; else data<=data+1; end if; end if;clkout<=Q;end process;end one;4.2 twoMHZ:這個(gè)程序完成2500分頻,實(shí)現(xiàn)第二次分頻,確保最后數(shù)碼管顯示頻率在合適范圍library ieee;use ieee.std_logic_11

6、64.all;entity twoMHZ is port( daclk:in std_logic; clkout:out std_logic); end twoMHZ;architecture one of twoMHZ issignal data:integer range 0 to 2500;signal Q:std_logic;beginprocess(daclk) begin if daclk'event and daclk='1' then if(data=2500) then data<=0; Q<=not Q; else data<=da

7、ta+1; end if; end if;clkout<=Q;end process;end one; 4.3 Charge:實(shí)現(xiàn)計(jì)費(fèi)功能,按行駛里程收費(fèi),起步費(fèi)為7.00元,并在車行3公里后再按2.2元/公里,當(dāng)計(jì)費(fèi)器達(dá)到或超過一定收費(fèi)(如20元)。每公里加收50%的車費(fèi),車停止不計(jì)費(fèi),實(shí)現(xiàn)預(yù)置功能、每公里收費(fèi)、車行駛加費(fèi)里程,實(shí)現(xiàn)模擬功能,能模擬汽車啟動(dòng)、停止、暫停、車速等狀態(tài),將車費(fèi)顯示出來。有兩位小數(shù)。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity charge is

8、port( cp,ks,tz,zt: in std_logic; dis,mon : out integer range 0 to 9999);end charge;architecture ch of charge isbegin process(cp,ks,tz,zt) variable dis1,mon1:integer range 0 to 9999; begin if(cp'event and cp='1') then if(tz='0')then dis1:=0;mon1:=0; elsif(ks='0') then dis1

9、:=0;mon1:=700; elsif(ks='1'and tz='1'and zt='1') then dis1:=dis1+10; elsif(ks='1'and tz='1'and zt='0') then dis1:=dis1;mon1:=mon1; end if; if(dis1<300) then null; elsif(dis1<600 and dis1>300) then mon1:=mon1+22; elsif(dis1>=600) then mon1:=

10、mon1+33; end if; mon<=mon1;dis<=dis1; end if; end process;end ch; 4.4 Transform 實(shí)現(xiàn)將電路計(jì)數(shù)分高低位顯示,將二進(jìn)制轉(zhuǎn)化為數(shù)碼管可識(shí)別的十進(jìn)制library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity transform isport( daclk : std_logic; dis,mon :integer range 0 to 9999; dg,ds,db,dq,mg,ms,mb,mq: out std

11、_logic_vector(3 downto 0);end transform;architecture tran of transform isbegin process(daclk,dis)variable d :integer range 0 to 9999;variable d1,d2,d3,d4 :std_logic_vector(3 downto 0);begin if(daclk'event and daclk='1') then if(d<dis) then if(d1=9 and d2=9 and d3=9) then d1:="000

12、0"d2:="0000"d3:="0000" d4:=d4+1;d:=d+1; elsif(d1=9 and d2=9) then d1:="0000"d2:="0000"d3:=d3+1;d:=d+1; elsif(d1=9) then d1:="0000"d2:=d2+1;d:=d+1; else d1:=d1+1;d:=d+1; end if; else d:=0;d1:="0000"d2:="0000"d3:="0000&quo

13、t;d4:="0000" end if;end if;dg<=d1;ds<=d2;db<=d3;dq<=d4;end process;process(daclk,mon)variable m :integer range 0 to 9999;variable m1,m2,m3,m4 :std_logic_vector(3 downto 0);begin if(daclk'event and daclk='1') then if(m<mon) then if(m1=9 and m2=9 and m3=9) then m1:

14、="0000"m2:="0000"m3:="0000"m4:=m4+1;m:=m+1; elsif(m1=9 and m2=9) then m1:="0000"m2:="0000"m3:=m3+1;m:=m+1; elsif(m1=9) then m1:="0000"m2:=m2+1;m:=m+1; else m1:=m1+1;m:=m+1; end if; else m:=0;m1:="0000"m2:="0000"m3:="

15、;0000"m4:="0000" end if;end if;mg<=m1;ms<=m2;mb<=m3;mq<=m4;end process;end tran;4.5 Sel 通過選擇器將路程和車費(fèi)每位分別輸出,送到數(shù)碼管library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity sel isport( c:in std_logic_vector(2 downto 0); dg,ds,db,dq,mg,ms,mb,mq:in std_log

16、ic_vector(3 downto 0); da:out std_logic_vector(3 downto 0) ); end sel;architecture se of sel isbegin process(c,dg,ds,db,dq,mg,ms,mb,mq) variable co :std_logic_vector(2 downto 0); begin co:=c; case co is when "000"=>da<=dg; when "001"=>da<=ds;when "010"=>d

17、a<=db; when "011"=>da<=dq;when "100"=>da<=mg; when "101"=>da<=ms;when "110"=>da<=mb; when "111"=>da<=mq;when others=>null;end case;end process;end se;4.6 W 用第一次分頻過的脈沖實(shí)現(xiàn)八進(jìn)制計(jì)數(shù),為下面實(shí)現(xiàn)動(dòng)態(tài)掃描做準(zhǔn)備library ieee;use ieee.std_lo

18、gic_1164.all;use ieee.std_logic_unsigned.all;entity w isport( clk:in std_logic; a:out std_logic_vector(2 downto 0);end w;architecture ch1 of w isbegin process(clk) variable b:std_logic_vector(2 downto 0); begin if(clk'event and clk='1') then if(b="111") then b:="000"

19、else b:=b+1; end if; end if; a<=b; end process;end ch1;4.7 38譯碼器:通過八進(jìn)制計(jì)數(shù)實(shí)現(xiàn)動(dòng)態(tài)掃描library ieee;use ieee.std_logic_1164.all;entity mux38a isport(d:in std_logic_vector(2 downto 0);q:out std_logic_vector(7 downto 0);end mux38a;architecture one of mux38a isbeginprocess(d)begincase d iswhen "000"

20、;=>q<="11101111"when "001"=>q<="11011111"when "010"=>q<="10111111"when "011"=>q<="01111111"when "100"=>q<="11111110"when "101"=>q<="11111101"when "11

21、0"=>q<="11111011"when "111"=>q<="11110111"when others=>null;end case;end process;end one;4.8 數(shù)碼管顯示:顯示模塊由8個(gè)七段LED數(shù)碼管組成。各個(gè)模塊用四個(gè)數(shù)碼管,三個(gè)表示整數(shù)部分,一個(gè)表示小數(shù)部分。由于小數(shù)點(diǎn)的位置是固定的,因此可以將小數(shù)點(diǎn)接到一個(gè)固定的高電平上一直顯示。library ieee;use ieee.std-_logic_1164.all;entity led isport( a : in

22、 std_logic_vector(3 downto 0);L: out std_logic_vector(6 sownto 0) );end led;architecture one of led is beginprocess(a)begincase a iswhen "0000"=>L<="0111111"when "0001"=>L<="0000110"when "0010"=>L<="1011011"when "0011

23、"=>L<="1001111"when "0100"=>L<="1100110"when "0101"=>L<="1101101" when "0110"=>L<="1111101" when "0111"=>L<="0000111"when "1000"=>L<="1111111"when &q

24、uot;1001"=>L<="1101111"when other =>null;end case;end process; end one;五 頂層模塊設(shè)計(jì):將各個(gè)程序塊聯(lián)合起來,實(shí)現(xiàn)層次化設(shè)計(jì)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity taxi isport(cp,start,stop,pause:in std_logic; ss1:out std_logic_vector(7 downto 0); ss2:out std_lo

25、gic_vector(6 downto 0);end entity taxi;architecture ym of taxi iscomponent oneMHZport(daclk:in std_logic; clkout:out std_logic);end component;component twoMHZport(daclk:in std_logic;clkout:out std_logic);end component;component chargeport( cp,ks,tz,zt : in std_logic; dis,mon : out integer range 0 to

26、 9999);end component;component transformport(daclk : std_logic; dis,mon :integer range 0 to 9999; dg,ds,db,dq,mg,ms,mb,mq: out std_logic_vector(3 downto 0);end component;component wport(clk:in std_logic; a:out std_logic_vector(2 downto 0);end component;component selport(c:in std_logic_vector(2 downt

27、o 0); dg,ds,db,dq,mg,ms,mb,mq:in std_logic_vector(3 downto 0); da:out std_logic_vector(3 downto 0);end component;component mux38aport(d:in std_logic_vector(2 downto 0); q:out std_logic_vector(7 downto 0);end component;component ledport( a : in std_logic_vector(3 downto 0);L: out std_logic_vector(6 d

28、ownto 0);end component;signal aa0,aa1:std_logic;signal a0,b0:integer range 0 to 9999;signal b2,a1,b1,c1,d1,e1,f1,g1,h1:std_logic_vector(3 downto 0);signal y:std_logic_vector(2 downto 0);beginu0:oneMHZ port map(daclk=>cp,clkout=>aa0);u1:twoMHZ port map(daclk=>aa0,clkout=>aa1);u2:charge po

29、rt map(cp=>aa1,ks=>start,tz=>stop,zt=>pause,dis=>a0,mon=>b0);u3:transform port map(daclk=>aa0,dis=>a0,mon=>b0,dg=>a1,ds=>b1,db=>c1,dq=>d1,mg=>e1,ms=>f1,mb=>g1,mq=>h1);u4:w port map(clk=>aa0,a=>y);u5:sel port map(c=>y,dg=>a1,ds=>b1,db=

30、>c1,dq=>d1,mg=>e1,ms=>f1,mb=>g1,mq=>h1,da=>b2);u6:mux38a port map (d=>y,q=>ss1);u7:led port map(a=>b2,L=>ss2);end ym;六 調(diào)試結(jié)果:1、下載步驟:(1) 安裝驅(qū)動(dòng)插入U(xiǎn)SB下載線后,自動(dòng)跳出窗口,手動(dòng)設(shè)置 D:alteraquartus6.0driverusb_blaster(2)IDE環(huán)境設(shè)置Assigementsdeviceep2cst144c8 device&ping optionsconfigura

31、tionsuse configuration deviseEPCS1-編譯(3)programmer Toolshardware setupusbblasterModeSJTAG 選文件 xx.sof(4)下載成功后,先拔電源VCC再拔USB下載線。注意事項(xiàng):保證下載板載斷電情況下進(jìn)行ASP或JTAG借口的插拔。引腳安裝圖:出租車計(jì)費(fèi)器成功運(yùn)行,軟硬件之間銜接全無問題,我們成功調(diào)試出預(yù)想結(jié)果,并且增加一些附加功能,比如考慮出租車夜晚和白天計(jì)費(fèi)不一樣,設(shè)計(jì)了加速計(jì)費(fèi)功能,除了軟件方面,在硬件上設(shè)計(jì)了顯示燈,便于觀察哪個(gè)功能起作用。雖然再調(diào)試過程出現(xiàn)了一些問題,但經(jīng)過討論以及觀察擺出故障,測(cè)試完軟硬件的獨(dú)立運(yùn)行,我們的軟硬件之間的銜接運(yùn)行相當(dāng)順利。七 實(shí)驗(yàn)中出現(xiàn)問題在編寫程序時(shí)出現(xiàn)了一些問題,例如編譯錯(cuò)誤,仿真結(jié)果不正確,但經(jīng)過細(xì)心檢查和查找資料,及時(shí)改正,尤其在實(shí)際頂層文件時(shí)出現(xiàn)一系列問題,但很大部分是由于更部分引腳接錯(cuò)造成問題。這大多由于粗心和不熟練

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論