Tema- Código VHDL para elevador.
Enviado por Mario Platte Monsivais • 20 de Noviembre de 2016 • Apuntes • 1.275 Palabras (6 Páginas) • 1.229 Visitas
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity Elevador is
port( p1,p2,p3,p4,s1,s2,s3,s4,s5 :IN BIT;
q :OUT INTEGER RANGE 0 TO 7;
csal :OUT BIT_VECTOR (3 downto 0));
end Elevador;
architecture eleva of Elevador is
begin
PROCESS (p1)
VARIABLE conteo :INTEGER RANGE 0 TO 7;
BEGIN
IF (p1'EVENT AND p1 ='1') THEN
IF (s1='0' AND s2='0') THEN conteo := 0;
ELSE conteo := conteo -1;
END IF;
q <= conteo;
END IF;
CASE conteo IS
WHEN 0 => csal <= "1010";
WHEN 1 => csal <= "1001";
WHEN 2 => csal <= "0101";
WHEN 3 => csal <= "0110";
WHEN 4 => csal <= "1010";
WHEN 5 => csal <= "1001";
WHEN 6 => csal <= "0101";
WHEN 7 => csal <= "0110";
END CASE;
END PROCESS piso1;
PROCESS (p2)
VARIABLE conteo :INTEGER RANGE 0 TO 7;
BEGIN
IF (p2'EVENT AND p2 ='1') THEN
IF (s1='0' AND s2='0') THEN conteo := conteo +1;
ELSIF (s2='0' AND s3='0') THEN conteo := 0;
ELSE conteo := conteo -1;
END IF;
q <= conteo;
END IF; --PASO COMPLET0
CASE conteo IS
WHEN 0 => csal <= "1010";
WHEN 1 => csal <= "1001";
WHEN 2 => csal <= "0101";
WHEN 3 => csal <= "0110";
WHEN 4 => csal <= "1010";
WHEN 5 => csal <= "1001";
WHEN 6 => csal <= "0101";
WHEN 7 => csal <= "0110";
END CASE;
END PROCESS piso2;
PROCESS (p3)
VARIABLE conteo :INTEGER RANGE 0 TO 7;
BEGIN
IF (p3'EVENT AND p3 ='1') THEN
IF (s1='0' AND s2='0') THEN conteo := conteo +1;
ELSIF (s2='0' AND s3='0') THEN conteo := conteo +1;
ELSIF (s3='0' AND s4='0') THEN conteo := 0;
ELSE
...