?? zidongshouhuoji.txt
字號:
VHDL語言編寫自動售貨機
設計并實現一個自動售貨機控制電路
某自動售貨機售A,B,C3種商品,他們的價格分別為1,3,4。
售票機進接受一元硬幣。售貨機面板上設有投幣孔和退錢建,每種商品標識處有選擇按鍵,上有指示燈表明當前投幣說是否已經足夠選買該商品。
library ieee;
use ieee.std_logic_1164.all;
entity autosell is port(
A,B,C:in std_logic;--3種商品
in_money,out_money:in std_logic;--投幣,和退幣
out_m:out std_logic;--出幣開關
Ya,Yb,Yc:out std_logic;--指示燈
ya_out,yb_out,yc_out:out std_logic);--出貨信號
end;
architecture behaviol of autosell is
signal count:integer range 0 to 5;--技數
signal a1,b1,c1:std_logic;
begin
process(out_money,in_money,A,B,C)
begin
if in_money='1' then --投幣
count<=count+1;
end if;
if count>0 then a1<='1';else a1<='0';end if;
if count>2 then b1<='1';else b1<='0';end if;
if count>4 then c1<='1';else c1<='0';end if;
Ya<=a1;Yb<=b1;Yc<=c1; --指示燈亮
if (a1<='1' and A='1') then --按鍵選擇商品
ya_out<='1';count<=count-1;else ya_out<='0';
end if;
if (b1<='1' and B='1') then
yb_out<='1';count<=count-3;else yb_out<='0';
end if;
if (c1<='1' and C='1') then
yc_out<='1';count<=count-5; else yc_out<='0';
end if;
if out_money='1' then --退幣
count<=0;out_m<='1';
else out_m<='0';
end if;
end process;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -