【正文】
。 elsif(but1=39。ableOk:=39。unablebut0:=39。039。139。039。 end if。) then unablebut4:=39。 and unablebut4=39。 if(but4=39。039。139。039。 end if。) then unablebut2:=39。 and unablebut2=39。 if(but2=39。039。139。039。 end if。) then unablebut0:=39。 and unablebut0=39。 第二個(gè)商品種類選擇 when schoGoods21= if(but0=39。) then state=sstart。 if(rst=39。 state=schoNum1。 lout1=39。 lout2=39。 end if。 sneedMoney=needMoney。139。) then choGoods2:=10。 and but1=39。 and unablebut1=39。 elsif(but0=39。 sneedMoney=needMoney。139。) then choGoods2:=0。 and unablebut0=39。 and but0=39。 if(but1=39。039。139。039。 end if。) then unablebut0:=39。 and unablebut0=39。 第二個(gè)商品的種類選擇 when schoGoods20 = if(but0=39。) then state=sstart。 if(rst=39。 15 state=schoGoods10。 lout1=39。 lout2=39。 end if。 sneedMoney=needMoney。039。139。039。) then lastOk:=ok。 if(ok/=lastOk and ableOk=39。139。139。) then choNum1:=3。 and unablebut3=39。 elsif(but3=39。ableOk:=39。unablebut2:=39。039。139。139。139。) then choNum1:=1。 and unablebut1=39。 elsif(but1=39。ableOk:=39。unablebut0:=39。039。139。 end if。) then unablebut3:=39。 and unablebut3=39。 if(but3=39。039。139。039。 end if。) then unablebut1:=39。 and unablebut1=39。 if(but1=39。039。139。039。 end if。139。 end if。039。139。039。) then lastOk:=ok。 if(ok/=lastOk and ableOk=39。 needMoney:=choGoods1。 end if。 ableOk:=39。unablebut1:=39。039。139。139。139。) then choGoods1:=15。 and unablebut0=39。 and choGoods1=10) then if(but0=39。 elsif(shift=39。139。139。) then choGoods1:=14。 and unablebut4=39。 elsif(but4=39。 ableOk:=39。unablebut3:=39。039。139。139。139。) then choGoods1:=12。 and unablebut2=39。 elsif(but2=39。 ableOk:=39。unablebut1:=39。039。139。139。139。) then choGoods1:=10。 and unablebut0=39。 and choGoods1=10) then if(but0=39。 elsif(shift=39。139。139。 and choGoods1=0) then choGoods1:=9。 and unablebut4=39。 elsif(but4=39。ableOk:=39。 unablebut3:=39。039。139。139。139。 and choGoods1=0) then choGoods1:=7。 and unablebut2=39。 elsif(but2=39。ableOk:=39。 unablebut1:=39。039。139。139。139。) then choGoods1:=5。 and unablebut0=39。 and choGoods1=0) then if(but0=39。 elsif(shift=39。139。139。) then choGoods1:=4。 and unablebut4=39。 elsif(but4=39。 ableOk:=39。unablebut3:=39。039。139。139。139。) then choGoods1:=2。 and unablebut2=39。 elsif(but2=39。 ableOk:=39。unablebut1:=39。039。139。139。139。) then choGoods1:=0。 and unablebut0=39。 and choGoods1=0) then if(but0=39。 if(shift=39。039。139。039。 end if。) then unablebut3:=39。 and unablebut3=39。 if(but3=39。039。139。039。 end if。) then unablebut1:=39。 and unablebut1=39。 if(but1=39。039。139。039。 end if。139。 end if。 13 sneedMoney=needMoney。139。) then choGoods1:=10。 and but1=39。 and unablebut1=39。 elsif(but0=39。 sneedMoney=needMoney。139。) then choGoods1:=0。 and unablebut0=39。 and but0=39。 if(but1=39。039。139。039。 end if。) then unablebut0:=39。 and unablebut0=39。 第一個(gè)商品的種類選擇 when schoGoods10 = if(but0=39。039。 unablebut4:=but4。 unablebut2:=but2。 unablebut0:=but0。 unablec10:=c10。 unablec1:=c1。 lout1=39。 co10=0。 co1=0。 lout4=39。 lout3=39。 lout2=39。039。 lastOk:=ok。 j:=0。 choNum1:=0。 tempCo10:=0。 12 tempCo1:=0。 needMoney:=0。) then case state is when sstart = totMoney:=0。event and clk1=39。 variable unablebut0,unablebut1,unablebut2,unablebut3,unablebut4:std_logic。 判斷是否已經(jīng)計(jì)算 過所需金額 variable ableOk: std_logic。 確認(rèn)開關(guān)的上一個(gè)狀態(tài) variable lastcancel: std_logic。 variable i : integer range 0 to 10。 選擇的商品 variable choNum1,choNum2: integer range 0 to 3。 需要的錢,個(gè)位十位 ,最多 16*3+16*3=96 variable tempCo1,tempCo5,tempCo10,tempCo20: integer range 0 to 5。 begin main:process(state,clk1,c1,c5,c10,c20,shift,but0,but1,but2,but3,but4,ok,cancel) variable totMoney: integer range 0 to 100。 type typestate is (sstart,schoGoods10,schoGoods11,schoGoods20,schoGoods21,schoNum1,schoNum2,spayment, srefund)。 signal sneedMoney: integer range 0 to 96。 architecture Behavioral of automarket is signal clk1: std_logic。 led 燈,顯示是否處在付款狀態(tài) lout4: out std_logic led 燈,顯示是否處在找零狀態(tài) )。 led 燈,顯示是否處在選擇商品狀態(tài) lout2: out std_logic。 11 choOut3:out std_logic。 顯示數(shù)碼管片選輸出口 choOut1:out std_logic。 outMoney:out std_logic_vector(7 downto 0)。 輸出價(jià)格 clk: in std_logic。 按鈕輸入 c1,c5,c10,c20: in std_logic。 取消及返回開關(guān) ok: in std_logic。 enti