📄 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 + -