EDA設(shè)計(jì)課程設(shè)計(jì)出租車計(jì)費(fèi)系統(tǒng)的VHDL設(shè)計(jì)_第1頁
EDA設(shè)計(jì)課程設(shè)計(jì)出租車計(jì)費(fèi)系統(tǒng)的VHDL設(shè)計(jì)_第2頁
EDA設(shè)計(jì)課程設(shè)計(jì)出租車計(jì)費(fèi)系統(tǒng)的VHDL設(shè)計(jì)_第3頁
EDA設(shè)計(jì)課程設(shè)計(jì)出租車計(jì)費(fèi)系統(tǒng)的VHDL設(shè)計(jì)_第4頁
EDA設(shè)計(jì)課程設(shè)計(jì)出租車計(jì)費(fèi)系統(tǒng)的VHDL設(shè)計(jì)_第5頁
已閱讀5頁,還剩6頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、武漢工業(yè)學(xué)院計(jì)算機(jī)系出租車計(jì)費(fèi)系統(tǒng)的vhdl設(shè)計(jì)課程:eda設(shè)計(jì)班級(jí):網(wǎng)絡(luò)工程081姓名:學(xué)號(hào):080510122日期:2011-11-28一、設(shè)計(jì)任務(wù)與要求(1)、能夠?qū)崿F(xiàn)計(jì)費(fèi)功能費(fèi)用的計(jì)算是按行駛里程收費(fèi),設(shè)出租車的起步價(jià)是5.00元,當(dāng)里程小于3km里時(shí),按起步價(jià)收費(fèi);當(dāng)里程大于3km時(shí)每公里按1.3元計(jì)費(fèi)。等待累計(jì)時(shí)間超過2min,按每分鐘1.5元計(jì)費(fèi)。所以總費(fèi)用按下式計(jì)算:總費(fèi)用=起步價(jià)+(里程-3km)*里程單價(jià)+等候時(shí)間*等候單價(jià)(2)、能夠?qū)崿F(xiàn)顯示功能l 顯示汽車行駛里程:用四位數(shù)字顯示,顯示方式為“xxxx”,單價(jià)為km。計(jì)程范圍為099km,計(jì)程分辨率為1km。l 顯示等候

2、時(shí)間:用兩位數(shù)字顯示分鐘,顯示方式為“xx”。計(jì)時(shí)范圍為059min,計(jì)時(shí)分辨率為1min。l 顯示總費(fèi)用:用四位數(shù)字顯示,顯示方式為“xxx.x”,單位為元。計(jì)價(jià)范圍為999.9元,計(jì)價(jià)分辨率為0.1元。二、設(shè)計(jì)原理根據(jù)設(shè)計(jì)要求,系統(tǒng)的輸入信號(hào)clk,計(jì)價(jià)開始信號(hào)start,等待信號(hào)stop,里程脈沖信號(hào)fin。系統(tǒng)得輸出信號(hào)有:總費(fèi)用數(shù)cha0 cha3,行駛距離km0 km1,等待時(shí)間min0 min1 等。系統(tǒng)的元件框圖如下:系統(tǒng)有兩個(gè)脈沖輸入信號(hào)clk_195、fin,兩個(gè)控制輸入開關(guān)start、stop;控制過程為:start作為計(jì)費(fèi)開始開關(guān),當(dāng)start為高電平時(shí),系統(tǒng)開始根據(jù)輸

3、入的情況計(jì)費(fèi)。當(dāng)有乘客上車并開始行駛時(shí),fin脈沖到來,進(jìn)行行駛計(jì)費(fèi),此時(shí)的stop需要置為0;如需停車等待,就把stop變?yōu)楦唠娖剑⑷コ齠in輸入脈沖,進(jìn)行等待計(jì)費(fèi);當(dāng)乘客下車且不等待時(shí),直接將start置為0,系統(tǒng)停止工作;系統(tǒng)由分頻模塊、控制模塊、計(jì)量模塊和計(jì)費(fèi)模塊四部分組成。計(jì)量模塊是整個(gè)系統(tǒng)實(shí)現(xiàn)里程計(jì)數(shù)和時(shí)間計(jì)數(shù)的重要部分;控制模塊是實(shí)現(xiàn)不同計(jì)費(fèi)方式的選擇部分;設(shè)計(jì)通過分頻模塊產(chǎn)生不同頻率的脈沖信號(hào)來實(shí)現(xiàn)系統(tǒng)的計(jì)費(fèi)。計(jì)量模塊采用1hz的驅(qū)動(dòng)信號(hào),計(jì)費(fèi)模塊采用13hz、15hz的驅(qū)動(dòng)信號(hào);計(jì)量模塊每計(jì)數(shù)一次,計(jì)費(fèi)模塊就實(shí)現(xiàn)13次或者15次計(jì)數(shù),即為實(shí)現(xiàn)計(jì)時(shí)時(shí)的1.5 元/min、計(jì)程

4、時(shí)的1.3元/km的收費(fèi);系統(tǒng)總體頂層框圖為:三、設(shè)計(jì)步驟 (一)、分頻模塊 分頻模塊是對(duì)系統(tǒng)時(shí)鐘頻率進(jìn)行分頻,分別得到15hz、13hz、1hz三種頻率;本設(shè)計(jì)中通過三種不同頻率的脈沖信號(hào)實(shí)現(xiàn)在計(jì)程車在行駛、等待兩種情況下的不同計(jì)費(fèi)。原理框圖如下: 源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity fenpin2 isport ( clk_195 :in std_logic; -頻率為195hz的時(shí)鐘 clk_13

5、: out std_logic; -頻率為13hz的時(shí)鐘 clk_15: out std_logic; -頻率為15hz的時(shí)鐘 clk_1: out std_logic); -頻率為1hz的時(shí)鐘end fenpin2;architecture rt1 of fenpin2 is signal q_13:integer range 0 to 12; -分頻器 signal q_15:integer range 0 to 14; -分頻器 signal q_1:integer range 0 to 194; -分頻器 begin process(clk_195) beginif (clk_195e

6、vent and clk_195=1 )then if q_13=12 then q_13=0;clk_13=1; -此處產(chǎn)生13hz頻率的信號(hào) else q_13=q_13+1;clk_13=0; end if;if q_15=14 then q_15=0;clk_15=1; -此處產(chǎn)生15hz頻率的信號(hào) else q_15=q_15+1;clk_15=0; end if;if q_1=194 then q_1=0;clk_1=1; -此處產(chǎn)生1hz頻率的信號(hào) else q_1=q_1+1;clk_1=0;end if; end if; end process;end rt1;分頻模塊的仿真

7、波形圖為:注:有圖中的周期時(shí)間可以看出,三種輸出的信號(hào)脈沖對(duì)應(yīng)的頻率比實(shí)現(xiàn)了1:13:15;(二)、計(jì)量模塊 本模塊實(shí)現(xiàn)對(duì)于出租車在行駛和等待過程中的繼承和計(jì)時(shí)功能;當(dāng)行駛里程大于3km時(shí),本模塊中en0信號(hào)變?yōu)?;當(dāng)?shù)却龝r(shí)間大于2min時(shí),本模塊中en1信號(hào)變?yōu)?;clk1每來一個(gè)上升沿,計(jì)量模塊實(shí)現(xiàn)一次計(jì)數(shù),里程數(shù)或者等待時(shí)間加1;元件框圖為:源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity jiliang is

8、port( s: in std_logic; -計(jì)量開始信號(hào) fin: in std_logic; -里程脈沖信號(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ì)數(shù) m1,m0: buffer std_logic_vector(3 downto 0); -時(shí)間計(jì)數(shù)end jiliang;architecture rt2 of jiliang issignal w:i

9、nteger range 0 to 59; -秒計(jì)數(shù)器beginprocess(clk1)begin if clk1event and clk1=1 then -本語句實(shí)現(xiàn)clk1對(duì)計(jì)量模塊的驅(qū)動(dòng) if s=0 then w=0;en1=0;en0=0;m1=0000;m0=0000;k1=0000;k0=0000; elsif stop=1 then -等待計(jì)時(shí)開始標(biāo)志 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 m000000001then en

10、1=1;-等待時(shí)間大于2min輸出使能信號(hào)en1 else en1=0; end if; else w=w+1;en1=0; end if; elsif fin=1 then -行駛計(jì)程開始 if k0=1001 then k0=0000; if k1=1001 then k1=0000; else k1=k1+1; end if; else k000000010 then en0=1; -行駛里程大于3km輸出使能信號(hào)en0 else en0=0; end if; else en1=0;en0=0; -clk1不驅(qū)動(dòng),使能信號(hào)為0 end if; end if;end process;end

11、 rt2;計(jì)量模塊的仿真波形圖為:注:由圖可以看出,在fin脈沖到來時(shí),k1、k0進(jìn)行計(jì)數(shù),en0在每進(jìn)行一次加法計(jì)數(shù)時(shí)就輸出一次高電平;當(dāng)stop為高電平時(shí),即為進(jìn)入等待計(jì)時(shí),m1、m0進(jìn)行計(jì)數(shù),en1在每進(jìn)行一次計(jì)時(shí)計(jì)數(shù)的時(shí)候輸出一個(gè)高電平;(三)、計(jì)費(fèi)模塊 本模塊根據(jù)輸入的clk2信號(hào)變化,調(diào)節(jié)費(fèi)用的計(jì)數(shù),c0、c1、c2、c3分別表示費(fèi)用的顯示。原理框圖為:源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity j

12、ifei isport(clk2:in std_logic; -計(jì)費(fèi)驅(qū)動(dòng)信號(hào) start: in std_logic; -計(jì)費(fèi)開始信號(hào) c0,c1,c2,c3: buffer std_logic_vector(3 downto 0);end jifei;architecture rt3 of jifei isbeginprocess(clk2,start)begin if start=0 then c3=0000;c2=0000;c1=0101;c0=0000; -對(duì)于起步價(jià)進(jìn)行了限定 elsif clk2event and clk2=1 then if c0=1001 then c0=000

13、0; if c1=1001 then c1=0000; if c2=1001 then c2=0000; if c3=1001 then c3=0000; else c3=c3+1; end if; else c2=c2+1; end if; else c1=c1+1; end if; else c0=c0+1; -完成計(jì)費(fèi)功能 end if; end if;end process;end rt3; 計(jì)費(fèi)模塊仿真波形圖為:注:由圖中可以看出,隨著clk2的高電平的到來,c3、c2、c1、c0逐級(jí)進(jìn)行加法計(jì)數(shù),當(dāng)c0計(jì)數(shù)到九時(shí),產(chǎn)生進(jìn)位,c1加一;當(dāng)c1計(jì)數(shù)到九時(shí),產(chǎn)生進(jìn)位,c2加一;當(dāng)c2計(jì)數(shù)

14、到九時(shí),產(chǎn)生進(jìn)位,c3加一; 起步價(jià)為5元;(四)、控制模塊 本模塊主要是通過兩個(gè)不同的輸入使能信號(hào),對(duì)兩個(gè)輸入脈沖進(jìn)行選擇輸出;使能信號(hào)是計(jì)量模塊中的輸出,兩個(gè)輸入脈沖是分頻模塊輸出的13hz、15hz的脈沖;本模塊實(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:

15、 in std_logic; -輸入脈沖 clk_in2: in std_logic; -輸入脈沖 clk_out: out std_logic); -輸出脈沖end kongzhi;architecture rt4 of kongzhi isbeginprocess(ent0,ent1)begin if ent0=1 then -本語句實(shí)現(xiàn)對(duì)雙脈沖的二選一 clk_out=clk_in1; elsif ent1=1 then clk_out=clk_in2; end if; end process;end rt4;控制模塊的仿真波形圖為:注:由圖中可以看出,當(dāng)ent0為高電平時(shí),輸出為這一時(shí)

16、段的clk_in1; 當(dāng)ent1為高電平時(shí),輸出為這一時(shí)段的clk_in2;(五)、原件例化(總模塊) 本模塊用例化語句實(shí)現(xiàn)出租車的計(jì)費(fèi)器系統(tǒng)設(shè)計(jì), 將各個(gè)模塊組合在一起;源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity taxi isport ( clk_195 :in std_logic; -195hz的輸入信號(hào) start :in std_logic; -計(jì)價(jià)開始信號(hào) stop:in std_logic; -等

17、待信號(hào) fin:in std_logic; -里程脈沖信號(hào) cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0); -計(jì)費(fèi)顯示輸出 km1,km0:out std_logic_vector(3 downto 0); -里程計(jì)數(shù)顯示 min1,min0: out std_logic_vector(3 downto 0); -等待時(shí)間計(jì)數(shù) end taxi;architecture behav of taxi is component fenpin2 -本語句實(shí)現(xiàn)對(duì)分頻模塊的例化 port(clk_195: in std_logic; clk_1

18、3: out std_logic; clk_15: out std_logic; clk_1 : 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 do

19、wnto 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 c

20、omponent;signal tmp1,tmp2,tmp3,tmp4,tmp5,tmp6: std_logic; -定義中間信號(hào)量begin u1: fenpin2 port map(clk_195,tmp1,tmp2,tmp3); u2: jiliang port map(start,fin,stop,tmp3,tmp4,tmp5,km1,km0,min1,min0); u3:kongzhi port map(tmp4,tmp5,tmp1,tmp2,tmp6); u4: jifei port map(tmp6,start,cha0,cha1,cha2,cha3);end behav;四、程序仿真波形注:由圖中可以看出,當(dāng)fin脈沖信號(hào)到來時(shí),實(shí)現(xiàn)了行駛計(jì)費(fèi),當(dāng)行駛里程超過三公里,則再按每公里1.3元計(jì)費(fèi);當(dāng)stop為高電平,即進(jìn)入等待計(jì)時(shí)收費(fèi);當(dāng)?shù)却龝r(shí)間超過2min時(shí),每過一分鐘加1.5元,即為實(shí)現(xiàn)每等一分鐘收費(fèi)1.5元。結(jié)果驗(yàn)證:出租車的起

溫馨提示

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