【正文】
stcancel:=cancel。039。 and unablebut1=39。139。) then unablebut3:=39。unablebut0:=39。) then choNum2:=1。039。 and unablebut3=39。 if(ok/=lastOk and ableOk=39。039。 state=schoGoods20。 unablebut1:=39。 if(c1=39。039。 and unablec10=39。139。 isAdd:=39。unablec1:=39。unablec5:=39。unablec10:=39。unablec20:=39。139。 state=srefund。 tempCo10:=tempCo10+1。 co10=tempCo10。 end if。event and clk=39。139。 else choClk=3。choOut3=39。choOut3=39。choOut3=39。choOut3=39。 variable j1:integer range 0 to 9。139。 when 2=outMoney=00100101。 when others=outMoney=00000011。 j0:=0。 when 2=outMoney=00100101。 when others=outMoney=00000011。 end if。 when 4=outMoney=10011001。 22 isneedDone0:=39。 if(needMoney1=10 and j1=9) then needMoney1:=needMoney110。 when 4=outMoney=10011001。 isneedDone1:=39。 end Behavioral。 when others=outMoney=00000011。 when 2=outMoney=00100101。 j1:=0。 when others=outMoney=00000011。 when 2=outMoney=00100101。139。 when 8=outMoney=00000001。 else case j0 is when 0=outMoney=00000011。139。 when 8=outMoney=00000001。 else case totMoney0 is when 0=outMoney=00000011。139。 variable j0:integer range 0 to 9。choOut2=39。choOut2=39。choOut2=39。choOut2=39。 elsif(j=100000 and j202000) then choClk=1。039。 variable j: integer range 0 to 400000。 ableOk:=39。 else co1=tempCo1。 tempCo20:=tempCo20+1。 lout4=39。039。039。039。039。039。) then needMoney:=choGoods1*choNum1+choGoods2*choNum2。039。 if(c10=39。 end if。 unablebut4:=39。 付款 when spayment = unablebut0:=39。 lout1=39。139。139。 elsif(but3=39。139。 and unablebut1=39。039。 and unablebut3=39。039。 if(but1=39。 end if。 state=schoNum2。139。 end if。 and unablebut1=39。039。 ableOk:=39。139。 elsif(but3=39。139。 and unablebut1=39。039。ableOk:=39。139。 elsif(but3=39。139。 and unablebut1=39。039。 16 ableOk:=39。139。 elsif(but3=39。139。 and unablebut1=39。039。) then unablebut4:=39。139。 and unablebut2=39。039。 第二個(gè)商品種類選擇 when schoGoods21= if(but0=39。 lout1=39。139。 elsif(but0=39。 and unablebut0=39。139。 and unablebut0=39。 15 state=schoGoods10。 sneedMoney=needMoney。) then lastOk:=ok。) then choNum1:=3。unablebut2:=39。139。ableOk:=39。 end if。039。) then unablebut1:=39。139。 end if。) then lastOk:=ok。 ableOk:=39。139。 and choGoods1=10) then if(but0=39。) then choGoods1:=14。unablebut3:=39。139。 ableOk:=39。139。 and choGoods1=10) then if(but0=39。 and choGoods1=0) then choGoods1:=9。 unablebut3:=39。139。ableOk:=39。139。 and choGoods1=0) then if(but0=39。) then choGoods1:=4。unablebut3:=39。139。 ableOk:=39。139。 and choGoods1=0) then if(but0=39。039。 if(but3=39。 end if。039。139。) then choGoods1:=10。 sneedMoney=needMoney。 and but0=39。039。 第一個(gè)商品的種類選擇 when schoGoods10 = if(but0=39。 unablebut0:=but0。 co10=0。 lout2=39。 choNum1:=0。) then case state is when sstart = totMoney:=0。 確認(rèn)開關(guān)的上一個(gè)狀態(tài) variable lastcancel: std_logic。 begin main:process(state,clk1,c1,c5,c10,c20,shift,but0,but1,but2,but3,but4,ok,cancel) variable totMoney: integer range 0 to 100。 led 燈,顯示是否處在付款狀態(tài) lout4: out std_logic led 燈,顯示是否處在找零狀態(tài) )。 outMoney:out std_logic_vector(7 downto 0)。 entity automarket is port( shift: in std_logic。 其中, 主要負(fù)責(zé)主程序段中商品種類及數(shù)量選擇代碼編寫以及最終設(shè)計(jì)報(bào)告的撰寫, 主要負(fù)責(zé)主程序段中商品付款及找零代碼編寫以及波形仿真任務(wù), 主要負(fù)責(zé)分頻任務(wù)以及數(shù)碼管顯示,并對整個(gè)程序進(jìn)行梳理調(diào)通。 9 小結(jié) 由以上波形仿真可作如下小結(jié)。 ( 3) 在 ”ok”、 ”cancel”兩個(gè)開關(guān)的設(shè)置時(shí) ,考慮到如果檢測開關(guān)為是否值為 ’1’,用戶在每次使用這兩個(gè)開關(guān)時(shí),都必須先撥上,再回 7 撥以方便下次使用,極不方便,因而將思路改為通過判斷這兩個(gè)開關(guān)的當(dāng)前狀態(tài)是否與上一個(gè)狀態(tài)不同來確定用戶是否確認(rèn)或取消。 設(shè)計(jì)中遇到的問題及解 決 ( 1) 在商品種類選擇狀態(tài)中,涉及用戶按鍵輸入部分。投幣過程中,數(shù)碼管右側(cè)兩位將實(shí)時(shí)顯示已投入的金額。每次輸入,改變信號 sneedMoney 的值,并分個(gè)位十位輸出到左側(cè)兩個(gè)數(shù)碼管上。當(dāng)投幣值達(dá)到或超過所需幣值后 ,售貨機(jī)出貨,并扣除所需金額,并找出多余金額。 ( 2)顧客可以選擇的商品種類有 16 種,價(jià)格分別為 116 元,顧客可以通過輸入 商品的編號來實(shí)現(xiàn)商品的選擇。乘客可以連續(xù)多次投入錢幣。顧客此時(shí)可以投幣,并且顯示已經(jīng)投幣的總幣值。在十位選擇時(shí),如果用戶按下 0、1 以外的按鍵 (在十位選擇過程中 shift 開關(guān)不會影響按鍵代表的值),則系統(tǒng)不會響應(yīng)按鍵,而是繼續(xù)等待輸入;在個(gè)位輸入時(shí),當(dāng)shift 開關(guān)值為 1,則 5 個(gè)鍵代表的值將由 01234 變?yōu)?56789,達(dá)到了題目要求。 ⑤付款狀態(tài)( spayment)中付款由開關(guān)模擬,用四個(gè)開關(guān)分別代表 20四種幣額的投入(可多次投入)。 ( 3) 譯碼顯示進(jìn)程( translate) 本 進(jìn) 程 通 過 電 路 的 多 次 循 環(huán) 將 兩 個(gè) 整 型 信 號 所 需 金 額( sneedMoney)、用戶余額( stotMoney)拆分成個(gè)位及十位并譯碼顯示。查閱資料得知,也可以利用 but’last_value 獲得按鈕上一個(gè)時(shí)鐘的值,聯(lián)合當(dāng)前值來獲得上升沿。 選 15 號,確定后按取消,重選 05 號商品 2 個(gè), 16 號商品 2個(gè),投入 50元( c20*2+c10*1),則退回金額為 8 元( co5*1+co1*3),并非余額不足持續(xù)等待,邏輯 正確,驗(yàn)證了返回上一層功能。 10 四、人員 及任務(wù) 分工 此次設(shè)計(jì)任務(wù)由信息科學(xué)與工程學(xué)院學(xué)生 共同完成。 use 。