Practica 4-Constraints y Codigo
Practica 4-Constraints y Codigo
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity cartel is
Port (clk,rst: in STD_LOGIC;
led: out std_logic;
anodos: out std_logic_vector (3 DOWNTO 0);
seg: out std_logic_vector (6 DOWNTO 0));
end cartel;
--Divisor de Frecuencia de 1 Hz
process(clk, rst)
variable cuenta1hz: integer range 1 to 500;
begin
if(rst='1')then
aux1hz<='0';
cuenta1hz:=1;
else
if rising_edge (clk) then
if (cuenta1hz=500) then
aux1hz<= not (aux1hz);
cuenta1hz:=1;
else
cuenta1hz:= cuenta1hz +1;
end if;
end if;
end if;
led<= aux1hz;
end process;
--Estado Futuro
process(edo_presente, rst)
begin
case edo_presente is
when s0 =>
edo_futuro <= s1;
catA<="110"; --espacio
catB<="110"; --espacio
catC<="110"; --espacio
catD<="110"; --espacio
when s1 =>
edo_futuro <= s2;
catA<="001"; --A
catB<="110"; --espacio
catC<="110"; --espacio
catD<="110"; --espacio
when s2 =>
edo_futuro <= s3;
catA<="010"; --r
catB<="001"; --A
catC<="110"; --espacio
catD<="110"; --espacio
when s3 =>
edo_futuro <= s4;
catA<="011"; --b
catB<="010"; --r
catC<="001"; --A
catD<="110"; --espacio
when s4 =>
edo_futuro <= s5;
catA<="100"; --o
catB<="011"; --b
catC<="010"; --r
catD<="001"; --A
when s5 =>
edo_futuro <= s6;
catA<="101"; --l
catB<="100"; --o
catC<="011"; --b
catD<="010"; --r
when s6 =>
edo_futuro <= s7;
catA<="110"; --espacio
catB<="101"; --l
catC<="100"; --o
catD<="011"; --b
when s7 =>
edo_futuro <= s8;
catA<="001"; --A
catB<="110"; --espacio
catC<="101"; --l
catD<="100"; --o
when s8 =>
edo_futuro <= s3;
catA<="010"; --r
catB<="001"; --A
catC<="110"; --espacio
catD<="101"; --l
when s9 =>
edo_futuro <= s1;
catA<="000"; --0
catB<="000"; --0
catC<="000"; --0
catD<="000"; --0
end case;
end process;
--Multiplexacion
process(aux250hz, anodo, catA, catB, catC, catD)
begin
if falling_edge (aux250hz) then
anodo <= anodo +1;
else
anodo<= anodo;
end if;
if(anodo="00")then
anodos<="1110";
segA<=catA;
elsif (anodo="01")then
anodos<="1101";
segA<=catB;
elsif (anodo="10")then
anodos<="1011";
segA<=catC;elsif (anodo="11")then
anodos<="0111";
else
anodos<="0000";
segA<=catB;
end if;
end process;
--Decodificador
process(segA)
begin
case segA is
when "000"=>seg<= "0000001"; --0
when "001"=>seg<= "1001000"; --H
when "010"=>seg<= "1100010"; --O
when "011"=>seg<= "1110001"; --L
when "100"=>seg<= "0001000"; --A
when others =>seg<="1111111";-- espacio
end case;
end process;
end funcional;
-------------------------------------------------
Anodos
--------------------------------------