VHDL语言编写自动售货机

来源:百度知道 编辑:UC知道 时间:2024/06/06 06:32:45
设计并实现一个自动售货机控制电路
某自动售货机售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;