EDA課程設(shè)計(jì)-出租車自動(dòng)計(jì)費(fèi)器_第1頁
EDA課程設(shè)計(jì)-出租車自動(dòng)計(jì)費(fèi)器_第2頁
EDA課程設(shè)計(jì)-出租車自動(dòng)計(jì)費(fèi)器_第3頁
EDA課程設(shè)計(jì)-出租車自動(dòng)計(jì)費(fèi)器_第4頁
EDA課程設(shè)計(jì)-出租車自動(dòng)計(jì)費(fèi)器_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、1課題的主要功能設(shè)計(jì)一個(gè)出租車自動(dòng)計(jì)費(fèi)器,計(jì)費(fèi)包括起步價(jià)、行車?yán)锍逃?jì)費(fèi)、等待時(shí)間計(jì)費(fèi)三部分,用四位數(shù)碼管顯示金額,最大值為999.9元,最小計(jì)價(jià)單元為 0.1元,行程 3公里內(nèi),且等待累計(jì)時(shí)間3分鐘內(nèi),起步費(fèi)為8元,超過3公里,以每公里1.6元計(jì)費(fèi),等待時(shí)間單價(jià)為每分鐘1元。用兩位數(shù)碼管顯示總里程,最大為99公里。用兩位數(shù)碼管顯示等待時(shí)間,最大值為59min。2課題的功能的劃分2.1課題系統(tǒng)功能模塊圖出租車自動(dòng)計(jì)費(fèi)器計(jì)費(fèi)模塊計(jì)量模塊把握模塊譯碼模塊分頻模塊 圖2-1系統(tǒng)功能原理圖2.2功能模塊的算法分析由圖2-1系統(tǒng)功能原理圖可知:該設(shè)計(jì)問題自頂向下可分為分頻模塊、計(jì)量模塊、計(jì)費(fèi)模塊、把握模塊

2、、譯碼和動(dòng)態(tài)掃描顯示模塊。2.2.1分頻模塊分頻模塊對(duì)頻率為240Hz的輸入脈沖進(jìn)行分頻,得到的頻率為16Hz,10Hz和1Hz的三種頻率。該模塊產(chǎn)生頻率信號(hào)用于計(jì)費(fèi),每個(gè)1HZ脈沖為0.1元計(jì)費(fèi)把握,10HZ信號(hào)為1元的計(jì)費(fèi)把握,16Hz信號(hào)為1.6元計(jì)費(fèi)把握。2.2.2計(jì)量把握模塊計(jì)量把握模塊是出租車自動(dòng)計(jì)費(fèi)器系統(tǒng)的主體部分,該模塊主要完成等待計(jì)時(shí)功能、計(jì)價(jià)功能、計(jì)程功能,同時(shí)產(chǎn)生3分種的等待計(jì)時(shí)使能把握信號(hào)en1,行程 3公里外的使能把握信號(hào)en0。其中計(jì)價(jià)功能主要完成的任務(wù)是:行程 3公里內(nèi),且等待累計(jì)時(shí)間3分鐘內(nèi),起步費(fèi)為8元;3公里外以每公里1.6元計(jì)費(fèi),等待累計(jì)時(shí)間3分鐘外以每分

3、鐘1元計(jì)費(fèi);計(jì)時(shí)功能主要完成的任務(wù)是:計(jì)算乘客的等待累計(jì)時(shí)間,計(jì)時(shí)器的量程為59分,滿量程自動(dòng)歸零;計(jì)程功能主要完成的任務(wù)是:計(jì)算乘客所行駛的公里數(shù)。計(jì)程器的量程為99公里,滿量程自動(dòng)歸零。2.2.3譯碼顯示模塊該模塊經(jīng)過8選1選擇器將計(jì)費(fèi)數(shù)據(jù)(4位BCD碼)、計(jì)時(shí)數(shù)據(jù)(2位BCD碼)、計(jì)程數(shù)據(jù)(2位BCD碼)動(dòng)態(tài)選擇輸出。其中計(jì)費(fèi)數(shù)據(jù)送入顯示譯碼模塊進(jìn)行譯碼,最終送至百元、十元、元、角為單位對(duì)應(yīng)的數(shù)碼管上顯示,最大顯示為999.9元;計(jì)時(shí)數(shù)據(jù)送入顯示譯碼模塊進(jìn)行譯碼,最終送至分為單位對(duì)應(yīng)的數(shù)碼管上顯示,最大顯示為59秒;計(jì)程數(shù)據(jù)送入顯示譯碼模塊進(jìn)行譯碼,最終送至以公里為單位的數(shù)碼管上顯示,最

4、大顯示為99公里。3主要功能的實(shí)現(xiàn)3.1分頻模塊的實(shí)現(xiàn)由圖3-1分頻模塊封裝圖可知:系統(tǒng)是對(duì)240HZ時(shí)鐘脈沖信號(hào)進(jìn)行分頻,分別得到16HZ、10HZ、1HZ三種頻率;本設(shè)計(jì)中通過三種不同頻率的脈沖信號(hào)實(shí)現(xiàn)在計(jì)程車在行駛、等待兩種狀況下的不同計(jì)費(fèi)。 圖3-1分頻模塊封裝圖3.2計(jì)量模塊的實(shí)現(xiàn)由圖3-2可知:本模塊實(shí)現(xiàn)對(duì)于出租車在行駛和等待過程中的繼承和計(jì)時(shí)功能;當(dāng)行駛里程大于3KM時(shí),本模塊中en0信號(hào)變?yōu)?;當(dāng)?shù)却龝r(shí)間大于3min時(shí),本模塊中en1信號(hào)變?yōu)?;clk1每來一個(gè)上升沿,計(jì)量模塊實(shí)現(xiàn)一次計(jì)數(shù),里程數(shù)或者等待時(shí)間加1。圖3-2計(jì)量模塊封裝圖3.3計(jì)費(fèi)功能的實(shí)現(xiàn)由圖3-3可知:輸入一

5、個(gè)脈沖信號(hào),同時(shí)當(dāng)start為時(shí)開頭計(jì)價(jià);c0、c1、c2、c3為價(jià)格的顯示信號(hào)。 圖3-3計(jì)費(fèi)模塊封裝圖3.4把握功能的實(shí)現(xiàn)由圖3-4可知:本模塊主要是通過兩個(gè)不同的輸入使能信號(hào),對(duì)兩個(gè)輸入脈沖進(jìn)行選擇輸出,使能信號(hào)是計(jì)量模塊中的輸出,兩個(gè)輸入脈沖是分頻模塊輸出的16HZ、10HZ的脈沖。圖3-4把握模塊封裝圖3.5譯碼和動(dòng)態(tài)掃描功能實(shí)現(xiàn)由圖3-5可知:該模塊首先以一個(gè)case語句進(jìn)行通道的選擇,接著有以一個(gè)case語句對(duì)所選的通道進(jìn)行動(dòng)態(tài)掃描,由于時(shí)間微小,因此我們?nèi)庋鄹杏X數(shù)字是同時(shí)顯示出來的。 圖3-5譯碼模塊封裝圖3.6總體功能原理圖圖3-6總體功能原理圖4程序調(diào)試4.1分頻模塊波形仿

6、真圖圖4-1分頻模塊仿真波形圖由圖4-1可知:當(dāng)輸入240HZ的clk脈沖信號(hào)時(shí),clk每消滅240個(gè)脈沖時(shí)q1、q10、q16分別消滅1、24、15個(gè),相當(dāng)于計(jì)費(fèi)0.01元、1元、1.6元,掛念計(jì)費(fèi)。4.2計(jì)量模塊波形仿真圖圖4-2計(jì)量模塊波形仿真圖由圖4-2可知:由于講輸入?yún)?shù)fin始終設(shè)為高,將stop始終設(shè)為低。所以k1、k0記錄路程的輸出量有值,而m1、m0記錄等待時(shí)間的輸出量沒有值。4.3計(jì)費(fèi)模塊波形仿真圖圖4-3計(jì)費(fèi)模塊波形仿真圖由圖4-3可知:輸入一個(gè)脈沖信號(hào),同時(shí)當(dāng)start為高時(shí)開頭計(jì)價(jià);c0、c1、c2、c3為價(jià)格的顯示信號(hào),逢9后一位將進(jìn)1。4.4把握模塊波形仿真圖圖4

7、-4把握模塊波形仿真圖由圖4-4可知:本模塊主要是通過兩個(gè)不同的輸入使能信號(hào),對(duì)兩個(gè)輸入脈沖進(jìn)行選擇輸出,使能信號(hào)是計(jì)量模塊中的輸出,兩個(gè)輸入脈沖是分頻模塊輸出的16HZ、10HZ的脈沖。4.5譯碼顯示模塊波形仿真圖圖4-5譯碼模塊波形仿真圖由圖4-5可知:首先以一個(gè)case語句進(jìn)行通道的選擇,以8為二進(jìn)制表示。當(dāng)某一位為1時(shí),表示選擇該通道接著。接著又以一個(gè)case語句對(duì)所選的通道進(jìn)行動(dòng)態(tài)掃描,由于時(shí)間微小,因此在我們用肉眼感覺是同時(shí)顯示出來的。4.6總模塊的波形仿真圖圖4-6總模塊的波形仿真圖5總結(jié)6附件6.1分頻功能實(shí)現(xiàn)的源代碼如下:library IEEE;use IEEE.STD_L

8、OGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity fp isport ( clk :in std_logic; q16: out std_logic; -頻率為16的時(shí)鐘 q10: out std_logic; -頻率為10的時(shí)鐘 q1: out std_logic); -頻率為1的時(shí)鐘end fp;architecture qq of fp is begin process(clk) variable cout16:integer range 0 to 14; variable

9、 cout10:integer range 0 to 23; variable cout1:integer range 0 to 239; beginif clk'event and clk='1' then if cout16=14 -240hz分頻為16hzthen cout16:=0;q16<='1' else cout16:=cout16+1;q16<='0'end if;if cout10=23 -240hz分頻為10hzthen cout10:=0;q10<='1' else cout10:=

10、cout10+1;q10<='0'end if;if cout1=239 -240hz分頻為1hzthen cout16:=0;q1<='1' else cout1:=cout1+1;q1<='0'end if;end if;end process;end qq;6.2計(jì)量功能模塊實(shí)現(xiàn)的源代碼library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity jiliang isp

11、ort( s: in std_logic; -計(jì)量開頭信號(hào) fin: in std_logic; - 計(jì)量路程的信號(hào) stop: in std_logic; -等待信號(hào) clk1: in std_logic; -計(jì)量驅(qū)動(dòng)信號(hào) en1,en0:buffer std_logic; -計(jì)量把握信號(hào) k1,k0: buffer std_logic_vector(3 downto 0); -路程的計(jì)量 m1,m0: buffer std_logic_vector(3 downto 0); -時(shí)間的計(jì)量end jiliang;architecture rt2 of jiliang issignal w:i

12、nteger range 0 to 59; beginprocess(clk1)begin if clk1'event and clk1='1' then -驅(qū)動(dòng)信號(hào)發(fā)揮作用 if s='0' then w<=0;en1<='0'en0<='0'm1<="0000"m0<="0000"-初始化值k1<="0000"k0<="0000"elsif stop='1' then -等待信號(hào)為高

13、,時(shí)間把握信號(hào)開頭計(jì)時(shí)if w=59 then w<=0; if m0="1001" then m0<="0000" if m1="0101" then m1<="0000"else m1<=m1+1;end if;else m0<=m0+1;end if; if m1&m0>"00000010"then en1<='1' -當(dāng)時(shí)間大于3min時(shí)使能信號(hào)en1開頭使能 else en1<='0' end if

14、; else w<=w+1;en1<='0' end if; elsif fin='1' then if k0="1001" then k0<="0000" if k1="1001" then k1<="0000" else k1<=k1+1; end if; else k0<=k0+1; end if; if k1&k0>"00000010" then en0<='1' -當(dāng)路程大于3km時(shí)

15、 ,使能信號(hào)en0開頭發(fā)揮作用 else en0<='0' end if; else en1<='0'en0<='0' end if; end if;end process;end rt2;6.3計(jì)費(fèi)功能實(shí)現(xiàn)的源代碼library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity jifei isport(clk2:in std_logic; -計(jì)費(fèi)驅(qū)動(dòng)信號(hào) start: in

16、std_logic; -計(jì)費(fèi)開頭信號(hào) c0,c1,c2,c3: buffer std_logic_vector(3 downto 0);-費(fèi)用顯示信號(hào)end jifei;architecture rt3 of jifei isbeginprocess(clk2,start)begin if start='0' then c3<="0000"c2<="0000"c1<="1000"c0<="0000" elsif clk2'event and clk2='1&#

17、39; then if c0="1001" then c0<="0000" if c1="1001" then c1<="0000" if c2="1001" then c2<="0000" if c3="1001" then c3<="0000"-計(jì)費(fèi)功能 else c3<=c3+1; end if; else c2<=c2+1; end if; else c1<=c1+1; end if;

18、else c0<=c0+1; end if; end if;end process;end rt3;6.4實(shí)現(xiàn)把握功能源代碼如下:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity kongzhi isport(ent0,ent1:in std_logic; -輸入的使能選擇信號(hào) clk_in1:in std_logic; -輸入脈沖 clk_in2:in std_logic; -輸入脈沖 clk_out:out std_l

19、ogic); -輸出脈沖end kongzhi;architecture rt4 of kongzhi isbeginprocess(ent0,ent1)begin if ent0='1' then -依據(jù)條件選擇所需的通道 clk_out<=clk_in1;elsif ent1='1' then clk_out<=clk_in2; end if; end process;end rt4;6.5實(shí)現(xiàn)譯碼和動(dòng)態(tài)掃描功能源代碼如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_un

20、signed.all;entity yima isport( clk :in std_logic; m1,m0,k1,k0,c3,c2,c1,c0 : in std_logic_vector(3 downto 0); sg:out std_logic_vector(7 downto 0); bt: out std_logic_vector(7 downto 0);end ;architecture behav of yima is signal cnt8:std_logic_vector( 2 downto 0); -定義信號(hào) signal a :std_logic_vector(3 down

21、to 0); signal b :std_logic_vector(7 downto 0); signal c :std_logic_vector(7 downto 0); beginprocess(clk) beginif clk'event and clk='1'then cnt8<=cnt8+1;end if;end process;process(cnt8) begincase cnt8 iswhen "000" =>a<=k0;c<="00000001"b(7)<='0' -

22、依據(jù)cnt的條件選擇通道when "001" =>a<=k1;c<="00000010"b(7)<='0'when "010" =>a<=m0;c<="00000100"b(7)<='0'when "011" =>a<=m1;c<="00001000"b(7)<='0'when "100" =>a<=c0;c<=&quo

23、t;00010000"b(7)<='0'when "101" =>a<=c1;c<="00100000"b(7)<='1'when "110" =>a<=c2;c<="01000000"b(7)<='0'when "111" =>a<=c3;c<="10000000"b(7)<='0'when others=> null

24、;end case;end process;process(a) -譯碼 begincase a iswhen "0000"=>b(6 downto 0)<="0111111"when "0001"=>b(6 downto 0)<="0000110"when "0010"=>b(6 downto 0)<="1011011"when "0011"=>b(6 downto 0)<="1001111&qu

25、ot;when "0100"=>b(6 downto 0)<="1100110"when "0101"=>b(6 downto 0)<="1101101"when "0110"=>b(6 downto 0)<="1111101"when "0111"=>b(6 downto 0)<="0000111"when "1000"=>b(6 downto 0)<=&

26、quot;1111111"when "1001"=>b(6 downto 0)<="1101111"when others=> null;end case;end process;sg<=b;bt<=c;end;6.6頂層文件實(shí)現(xiàn)的源代碼如下:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity taxi isport ( clk240 :in std_

27、logic; start :in std_logic; stop:in std_logic; fin:in std_logic; cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0); km1,km0:out std_logic_vector(3 downto 0); min1,min0: out std_logic_vector(3 downto 0); end taxi;architecture behav of taxi is component fp -實(shí)現(xiàn)對(duì)分頻模塊的例化 port(clk: in std_logic; q16: o

28、ut std_logic; q10: out std_logic; q1 : out std_logic); end component; component jiliang -實(shí)現(xiàn)對(duì)計(jì)量模塊的例化 port( s: in std_logic; fin: in std_logic; stop: in std_logic; clk1: in std_logic; en1,en0:buffer std_logic; k1,k0: buffer std_logic_vector(3 downto 0); m1,m0: buffer std_logic_vector(3 downto 0); end component;component jifei -實(shí)現(xiàn)對(duì)計(jì)費(fèi)模塊的例化 port(clk2:in std_logic; start: in std_logic; c0,c1,c2,c3: buffer std_logic_vector(3 downto 0); end component;component kongzhi -實(shí)現(xiàn)對(duì)把握模塊的例化 port(ent0,ent1:in std_logic; clk_in1:in std_logic; clk_in2:in std_logic; clk_out:out std_logic); end component;compo

溫馨提示

  • 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)論