出租車計費器VHDL語言_第1頁
出租車計費器VHDL語言_第2頁
出租車計費器VHDL語言_第3頁
出租車計費器VHDL語言_第4頁
出租車計費器VHDL語言_第5頁
已閱讀5頁,還剩6頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、數字邏輯電路課程設計出租車計費器的設計計算機學院 軟件工程 1401趙雷 3140608027出租車計費器的設計一、系統設計任務及要求(1 )能實現計費功能,計費標準為:按行駛里程收費,起步價為7.00元,并在車行3千米后再按2元/千米,當總費用達到或超過 40元時,每千米收費4元,客戶端需要停車等待時 按時間收費,計費單價每 20秒1元。(2)設計動態掃描電路:以十進制顯示出租車行駛的里程與車費,在數碼管上顯示(前四 個顯示里程,后三個顯示車費)。(3) 用VHDL語言設計符合上述功能要求的出租車計費器,并用層次化設計方法設計該電 路。(4)完成電路全部設計后,通過系統試驗箱下載驗證設計的正

2、確性。二、系統設計方案根據系統設計設計要求不難得知,整個出租車計費系統按功能主要分為速度選擇模塊、計程模塊、計時模塊、計費模塊 4個模塊。車速控制模塊計數器模塊譯 碼模 塊動態掃描電路模塊10 / 11頂層原理圖1.速度模塊: 通過對速度信號 sp 的判斷,決定行使的路程,這里是通過速度信號來模擬一 個變量的取值。 如 kinside 變量, 其含義是行進 100m 所需的時鐘周期數, 然后每行進 100m, 則產生一個脈沖 clkout 來驅動計費模塊。VHDL 語言:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_un

3、signed.all;entity Taxi_part1 isport(clk,reset,start,stop:in std_logic;sp :in std_logic_vector(2 downto 0);clkout :out std_logic);end Taxi_part1;architecture behavior of Taxi_part1 isbeginprocess(clk,reset,stop,start,sp)type state_type is(s0,s1);variable s_state:state_type;variable cnt:integer range

4、0 to 1400;variable kinside:integer range 0 to 1400;begincase sp iswhen 000= kinside:=0;when 001= kinside:=1400;when 010= kinside:=1200;when 011= kinside:=1000;when 100= kinside:=800;when 101= kinside:=600;when 110= kinside:=400;when 111= kinside:=200;end case;if(reset=1) then s_state:=s0;elsif(clkev

5、ent and clk=1) thencase s_state iswhen s0=cnt:=0;clkoutclkout=0;if(stop=1) then s_state:=s0; - 相當于無客戶上車elsif(sp=000) then s_state:=s1; - 有客戶上車,但車速位 0,即客戶剛 上車還未起步elsif(cnt=kinside) then cnt:=0;clkout=1; s_state:=s1;else cn t:=c nt+1; s_state:=s1;end if;end case;end if;end process;end behavior;2計程模塊:由

6、于一個clkout信號代表行進100m,故通過對clkout計數,可以獲得共行進 的距離kmcount。VHDL語言:library ieee;use ieee.std _lo gic_1164.all;use ieee.std_logic_ un sig ned.all;en tity Taxi_part2 isport(clkout,reset:i n std_logic;kmc nt1:out std_logic_vector(3 dow nto 0);kmc nt2:out std_logic_vector(3 dow nto 0);kmc nt3:out std_logic_vect

7、or(3 dow nto 0);end Taxi_part2;architecture behavior of Taxi_part2 isbeginprocess(clkout,reset)variable km_reg:stdo gic_vector(11 dow nto 0);beginif(reset=1) then km_reg:=0;elsif(clkoutevent and clkout=1) then-km_reg(3 downto 0)對應里程十分位if(km_reg(3 downto 0)=1001)thenkm_reg:=km_reg+0111;-十分位向個位的進位處理el

8、se km_reg(3 dow nto 0):=km_reg(3 dow nto 0)+0001;end if;if(km_reg(7 downto 4)=1010)thenkm_reg:=km_reg+01100000;-個位向十位的進位處理end if;end if;kmc nt1=km_reg(3 dow nto 0);kmc nt2=km_reg(7 dow nto 4);kmc nt3waittime:=0;timeco un tif(sp=OOO) then t_state:=t2; else waittime:=0;t_state:=t1; end if;whe n t2 =wa

9、ittime:=waittime+1;timecoun t=0;if(waittime=1000) the ntimecount=1:-20s,即1000個clk,產生一個時間計費脈沖waittime:=0;elsif(stop=1) then t_state:=t0;elsif(sp=000) then t_state:=t2;else timeco un t=0) then price=0100; else Price=0011)or(kmcnt3=0001) then Enable=1;else Enable=0;end if;end process; kmmoney2:process(

10、reset,clkout,clk,Enable,Price,kmcnt2) variable reg2:std_logic_vector(11 downto 0); variable clkout_cnt:integer range 0 to 10;begin20s 加一元if(reset=1) then cash1001) thenreg2(7 downto 0):=reg2(7 downto 0)+00000111; if(reg2(7 downto 4)1001) then cash =reg2+0;else cash=reg2;end if;else cash00001001) the

11、n reg2(7 downto 0):=reg2(7 downto 0)+00000110+price; if(reg2(7 downto 4)1001) thencash=reg2+0;else cash=reg2;end if;else cash=reg2+price;end if;else clkout_c nt:=clkout_c nt+1;end if;end if;end if;end process;coun t1=cash(3 dow nto 0);-總費用的個位coun t2=cash(7 dow nto 4);-總費用的十位cou nt3=cash(11 dow nto 8

12、);-總費用的百位end behavior;5顯示模塊:時間的顯示需要用到全部8個數碼管,由于實驗板上的所有數碼管均對應同一組7段碼,因此,需要采用動態掃描的方式實現時間顯示。VHDL語言:library ieee;use ieee.std _lo gic_1164.all;use ieee.std_logic_ un sig ned.all;en tity display isport(clk:in std_logic;kmco un t1:i n std_logic_vector(3 dow nto 0);kmco un t2:i n std_logic_vector(3 dow nto

13、0);kmco un t3:i n std_logic_vector(3 dow nto 0);coun t1:i n stdo gic_vector(3 dow nto 0);coun t2:i n stdo gic_vector(3 dow nto 0);coun t3:i n std_logic_vector(3 dow nto 0);clkout:out std_logic_vector(6 downto 0); sel:buffer std_logic_vector(2 downto 0);end display;architecture dtsm of display issignal key:std_logic_vector(3 downto 0);beginprocess(clk)variable dount:std_logic_vector(2 downto 0):=000; beginif rising_edge(clk) thenif dount=111 thendount:=000;elsedount:=dount+1;end if;end if;selkeykeykeykeykeykeykeykeynull;end case;end process;process(key)begincase key iswhen 0000=

溫馨提示

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

評論

0/150

提交評論