




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、基于vhdl的地鐵自動售票系統(tǒng)設計 班級:xxxxxxx姓名:xxxxxx 學號:xxxxxxxxx 班內序號:15 日期:2012.11.11 1、 實驗要求1.地鐵票價統(tǒng)一為每張兩元,可以投入幣值為1元、5元和10元三種幣種進行購票。2.能夠開機自檢,檢驗顯示器件正常。3.通過按鍵開關btn輸入購票張數(shù)和投入的人民幣張數(shù)并恰當顯示相應信息。4.設置適當?shù)穆曇籼崾净蝻@示提示表示取票和找零。5.一次購票成功后系統(tǒng)能夠恰當?shù)剞D入下一次購票等待狀態(tài)。6.系統(tǒng)能夠復位。二、系統(tǒng)設計3、 仿真波形及分析售票系統(tǒng)上電后首先進行復位(reset=1),然后等待乘客選擇票數(shù)(tn=0-7) 。在選票完成后,
2、 系統(tǒng)輸出報警信號 (moneyinputalarm=1), 提醒乘客進行投幣。之后系統(tǒng)對于乘客投入的紙幣進行識別,識別范圍是1元,5元,10元(money10,money5,money1),乘客可以連續(xù)多次投入錢幣,系統(tǒng)自動進行累加。當投入的錢幣未達到所需金額時,報警信號仍然繼續(xù)維持(moneyinputalarm=1),提醒錢不夠,需要繼續(xù)投入錢幣。當投入的錢幣達到所需金額時,報警信號取消(moneyinputalarm=0),售票機自動出票(tout=1) 。如果投入的錢幣有余, 系統(tǒng)自動計算余額 (rmoney) 。本次交易結束,系統(tǒng)自動進入選站狀態(tài)等待下一次的交易。在投幣期間,如果乘
3、客按復位鍵(reset=1)取消本次操作,錢幣自動退出。4、 源程序library ieee;use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity adddiv is port( bt:out std_logic_vector(5 downto 0); reset:in std_logic; - 系統(tǒng)復位信號 clk:in std_logic; - 系統(tǒng)時鐘 tn:in std_logic_vector(6 downto 0); - 所購票數(shù) money10:in std_logic; - 投幣10元 mone
4、y5:in std_logic; - 投幣5元 money1:in std_logic; -投幣1元 moneyinputalarm:out std_logic; - 投幣不足報警信號 tout : out std_logic;- 出票 led:out std_logic_vector(6 downto 0); state:out std_logic_vector(2 downto 0) - 系統(tǒng)狀態(tài)指示 ); end adddiv;architecture behave of adddiv iscomponent div_2k - 2000分頻器,用來使7段數(shù)碼管閃爍port(clk_in:
5、 in std_logic; clk_out: out std_logic);end component;component div_50m -50分頻器,用來處理投幣按鍵port(clk_in_50m: in std_logic; clk_out_50m: out std_logic);end component; signal cnt6:integer range 0 to 5; - 掃頻使6個七段數(shù)碼管輪流亮的信號 signal tmplight:integer range 0 to 9; - 控制所有數(shù)碼管顯示的信號 constant numh:integer:=0; - 票數(shù)顯示高位
6、 signal numl:integer range 0 to 9; - 票數(shù)顯示低位 signal pmoneyh:integer range 0 to 2; - 所付錢數(shù)顯示高位 signal pmoneyl:integer range 0 to 9; - 所付錢數(shù)顯示低位 constant rmoneyh:integer:=0; - 找錢顯示高位 signal rmoneyl:integer range 0 to 9; - 找錢顯示低位 signal clk_tmp: std_logic; 2000m分頻輸出 signal clk_money: std_logic;type ff is
7、(selticket,inputcoin,givechange) ; - 定義系統(tǒng)轉換狀態(tài) (選站, 選票, 投幣, 出票, 找零) begin u1:div_2k port map(clk_in=clk,clk_out=clk_tmp); u2:div_50m port map(clk_in_50m=clk,clk_out_50m=clk_money);main: process(reset,clk_money) variable next_state: ff:=selticket; variable tmoney,pmoney,rmoney,num: integer range 0 to
8、20; - 車票總額,投幣總額,找零總額 begin if clk_moneyevent and clk_money= 1 then case next_state is when selticket = - 選擇票數(shù) tout=0; moneyinputalarm=0; numl=0; pmoneyh=0; pmoneyl=0; rmoneyl=0; num:=0; tmoney:=0; pmoney:=0; rmoney:=0; - 初始化清零 state tmoney :=2; - 計算票價 num:=1; when 0100000 = tmoney :=4; - 計算票價 num:=2
9、; when 0010000 = tmoney :=6; - 計算票價 num:=3; when 0001000 = tmoney :=8; - 計算票價 num:=4; when 0000100 = tmoney :=10; - 計算票價 num:=5; when 0000010 = tmoney :=12; - 計算票價 num:=6; when 0000001 = tmoney :=14; - 計算票價 num:=7; when others =null; end case; numl0) then next_state := inputcoin; - 選票結束,進入投幣狀態(tài) else
10、next_state := selticket; - 未選票,停留在選票狀態(tài) end if ; end if; when inputcoin = - 進行投幣 state=010; if (money10=1) then pmoney:=pmoney+10; -計算已付的款 end if; if (money5=1) then pmoney:=pmoney+5; end if; if (money1=1) then pmoney:=pmoney+1; end if; if pmoney10 then -把已付的款轉換成七段數(shù)碼管顯示的高低位 pmoneyh = 0; pmoneyl =pmon
11、ey; elsif pmoney20 then pmoneyh = 1; pmoneyl =pmoney-10; else pmoneyh = 2; pmoneyl =pmoney-20; end if; if (pmoneytmoney)then - 比較投幣總額與車票總額 moneyinputalarm =1; -缺錢警告 next_state :=inputcoin; - 投幣不足,繼續(xù)進入投幣狀態(tài) else moneyinputalarm - 余額找出 state0)then tout=1; rmoney :=pmoney-tmoney; else tout=0; end if ; r
12、moneyl - 其他任何情況,均回到選站狀態(tài) next_state := selticket; end case ; end if; end process main; show: process(clk_tmp) begin if clk_tmpevent and clk_tmp= 1 then -實現(xiàn)模6計數(shù)器 if cnt6 = 5 thencnt6 = 0;elsecnt6 bt = 011111 ; tmplight bt = 101111 ; tmplight bt = 110111 ; tmplight bt = 111011 ; tmplight bt = 111101 ;
13、tmplight bt = 111110 ; tmplight null ; end case ; -用6個數(shù)碼管輪流輸出 case tmplight is when 0 = led led led led ledledledled led led= 1111011;end case; end if; end process show;end behave;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity div_2k isport(clk_in:in std_logic; clk_o
14、ut:out std_logic);end div_2k; architecture a of div_2k issignal temp:integer range 0 to 1999;begin p1:process(clk_in)begin if clk_inevent and clk_in=1 then if temp=999 then clk_out=1; temp=temp+1; elsif temp=1999 then temp=0; clk_out=0; else temp=temp+1; clk_out=0; end if;end if;end process p1;end a
15、;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity div_50m isport(clk_in_50m:in std_logic; clk_out_50m:out std_logic);end div_50m; architecture b of div_50m issignal temp:integer range 0 to 49999999;begin p1:process(clk_in_50m)begin if clk_in_50mevent and clk_in_50m=1 t
16、hen if temp=24999999 then clk_out_50m=1; temp=temp+1; elsif temp=49999999 then temp=0; clk_out_50m=0; else temp=temp+1; clk_out_50m=0; end if;end if;end process p1;end b;5、 功能說明 本自動售票機系統(tǒng)共分3個狀態(tài):選票狀態(tài),付款狀態(tài),出票找零狀態(tài)。在選票狀態(tài),用7個撥碼開關分別表示17張票,選中后自動進入付款狀態(tài);用3個按鍵分別控制投幣10元、5元、1元,且控制按鍵進程的時鐘為25m分頻,即每按鍵0.5s投入一張紙幣。當投幣
17、數(shù)小于應付票款數(shù)時,警報燈亮,當投幣數(shù)大于應付票款數(shù)時自動進入出票找零狀態(tài),燈亮顯示出票,系統(tǒng)自動計算找零數(shù)。當復位鍵按下時系統(tǒng)回到選票狀態(tài)。與此同時,六個七段數(shù)碼管分別顯示票數(shù)、付款數(shù)、找零數(shù)。6、 元器件清單硬件:max ii epm1270t144c5軟件:quartus ii 9.07、 故障及問題分析1.本實驗處理的最關鍵問題是如何使6個七段數(shù)碼管在同一掃頻周期里顯示不同狀態(tài)里的變量值。經(jīng)仔細研究七段數(shù)碼管掃描靜態(tài)顯示實驗發(fā)現(xiàn),可以把所有需要顯示的信號用一個中間變量tmplignt表示,并對掃描顯示的進程“show”中的每個掃頻脈沖分別把6個需要顯示的變量賦予tmplight。2.起初處理按鍵時由于main進程和show進程用同一個時鐘,造成當時鐘頻率過高是按鍵無法一次一次輸入;而當時鐘頻率過低時又不能是數(shù)碼管掃描顯示達到視覺殘留的效果。故最終分頻兩次,一個25m分頻用以處理按鍵,一個2000
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- TY/T 1108-2024體育賽事活動競賽規(guī)則編制規(guī)范
- 工程課題立項申報書
- 儲罐氣體銷售合同范本
- 代駕租賃合同范本
- Unit 3 Keep Fit section B 1a-1d 同步課時講練(含答案)七年級英語下冊(人教版2024)
- 原料購置合同范例
- 公司食堂 燃氣 合同范本
- 印刷紙箱合同范本
- 產(chǎn)品折扣合同范本
- 課題申報書怎么寫作
- 油漆使用登記記錄表
- 【知識點提綱】新教材-人教版高中化學必修第一冊全冊各章節(jié)知識點考點重點難點提煉匯總
- 高中語文基礎知識手冊薛金星
- 輪轂電機驅動電動車懸架和轉向系統(tǒng)設計與性能匹配
- 二年級第二學期體育知識結構圖
- CASS勘測定界操作指導方案
- 中國商品條碼系統(tǒng)注冊登記表規(guī)范填寫
- 湘科教版小學信息技術四年級下冊全冊教案.doc
- JJG 840-1993 函數(shù)信號發(fā)生器檢定規(guī)程
- 胃瘍(慢性消化性潰瘍)中醫(yī)護理方案
- 護理工作質量標準及考核細則
評論
0/150
提交評論