Beruflich Dokumente
Kultur Dokumente
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY tragamonedas IS
PORT(
clk : IN std_logic;
m : IN std_logic;
test : inout std_logic;
estado : out std_logic_vector(2 downto 0);
moneda: in std_logic_vector(2 downto 0);
--entrada de mecanismo de m
onedas
ipdto: in std_logic_vector(2 downto 0);
--Seleccion de Producto
pdto: out std_logic_vector (2 downto 0);
-- Entrega de producto
cmbo: out std_logic_vector(2 downto 0));
-- Entrega de Cambio
END tragamonedas;
ARCHITECTURE circuito OF tragamonedas IS
TYPE estados IS (S1, S2, S3, S4, S5);
SIGNAL state : estados;
CONSTANT max: INTEGER := 30000000;
SIGNAL count: INTEGER RANGE 0 TO max;
SIGNAL sumatoria: INTEGER RANGE 0 TO 100;
SIGNAL diferencia: INTEGER RANGE 0 TO 100;
BEGIN
PROCESS (clk,m,ipdto)
BEGIN
--IF (start = '0') then
-state <= S1;
if (clk'event and clk = '1') then
IF (count < max) THEN
count <= count + 1;
ELSE
count <= 0;
test <= not test;
case state is
when S1 =>
pdto <= "000";
cmbo <= "000";
--Apagamos productos
--Apagamos salidas de cambio
del estado
state <= S1;
if m = '0' then
case moneda is
-- acumlamos mon
edas
when "110" =>
sumatoria <=
when "101" =>
sumatoria <=
when "100" =>
sumatoria <=
when "011" =>
sumatoria <=
when others
sumatoria <=
end case;
end if;
Sumatoria +1;
Sumatoria +2;
Sumatoria +5;
Sumatoria +10;
=>
Sumatoria +0;
case ipdto is
when "011" =>
if (sumatoria > 6) then
state <= S4;
else
state <= S1;
end if;
when "101" =>
if (sumatoria > 4) then
state <= S3;
else
state <= S1;
end if;
when "110" =>
if (sumatoria > 2)then
state <= S2;
else
state <= S1;
end if;
when others =>
state <= S1;
end case;
when S2 => estado <= "010";
o del estado
-- ha mas de 5 pesos
END IF;
END IF;
END PROCESS;
END circuito;