You are on page 1of 24

---------------------------------------------------------------------------------- Company:

-- Engineer:
--- Create Date:
17:14:33 11/09/2013
-- Design Name:
-- Module Name:
reloj - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
entity proyecto is
port(
enter : in STD_LOGIC;
down : in STD_LOGIC;
up : in STD_LOGIC;
right : in STD_LOGIC;
left : in STD_LOGIC;
clk : in std_logic;
anodos : out STD_LOGIC_VECTOR (3 downto 0):="0111";
segmentos : out STD_LOGIC_VECTOR (6 downto 0);
led1 : out std_logic_vector(1 downto 0) :="00";
led2 : out std_logic_vector(3 downto 0) :="0000";
led3 : out std_logic_vector(2 downto 0) :="000";
led4 : out std_logic_vector(3 downto 0) :="0000";
led5 : out std_logic_vector(2 downto 0) :="000";
led6 : out std_logic_vector(3 downto 0) :="0000";
-catodos : out std_logic_vector(6 downto 0) :="0111111";
anodo : out std_logic_vector(4 downto 0) :="00000";
alarma : out std_logic :='0');--------------------------------end proyecto;
architecture Behavioral of proyecto is
ATTRIBUTE LOC: STRING;
ATTRIBUTE LOC OF clk: SIGNAL IS "V10";
ATTRIBUTE LOC OF segmentos : SIGNAL IS "T17,T18,U17,U18,M14,N14,L14";
ATTRIBUTE LOC OF anodos: SIGNAL IS "P17,P18,N15,N16";
ATTRIBUTE LOC OF alarma:
--ATTRIBUTE LOC OF led1:
--ATTRIBUTE LOC OF led2:
--ATTRIBUTE LOC OF led3:
--ATTRIBUTE LOC OF led4:

SIGNAL
SIGNAL
SIGNAL
SIGNAL
SIGNAL

IS
IS
IS
IS
IS

"H3";
"T12,V12";
"M10,N9,U11,V11";
"K2,K1,L4";
"J3,J1,K3,K5";

--ATTRIBUTE LOC OF led5: SIGNAL IS "H3,L7,K6";


--ATTRIBUTE LOC OF led6: SIGNAL IS "G1,J7,J6,F2";
ATTRIBUTE LOC OF catodos: SIGNAL IS "N10,T12,P11,V12,M10,V11,N9";
ATTRIBUTE LOC OF anodo: SIGNAL IS "K2,J3,K1,L4,K3";
ATTRIBUTE LOC OF down : SIGNAL is "C9";
ATTRIBUTE LOC OF up : SIGNAL is "A8";
ATTRIBUTE LOC OF right : SIGNAL is "D9";
ATTRIBUTE LOC OF left : SIGNAL is "C4";
ATTRIBUTE LOC OF enter : SIGNAL is "B8";
signal count : natural range 0 to 100000000:=0;
signal count1 : natural range 0 to 100000:=0;---signal seg : natural range 0 to 60:=0;
signal min : natural range 0 to 60:=0;
signal hora : natural range 0 to 24:=0;
signal segala : natural range 0 to 60:=0;---hora de la alarma
signal minala : natural range 0 to 60:=0;
signal horaala : natural range 0 to 24:=0;
signal parp : natural range 0 to 25000000 :=0;---------signal edhora :natural range 0 to 10:=0;
signal edmin :natural range 0 to 10:=0;
signal matriz :natural range 0 to 20000000:=0;
signal pasomatriz :natural range 0 to 23:=1;
signal paso : natural range 0 to 3:=0;
signal d1 : std_logic_vector (6 downto 0) :="0000000";
signal d2 : std_logic_vector (6 downto 0) :="0000000";
signal d3 : std_logic_vector (6 downto 0) :="0000000";
signal d4 : std_logic_vector (6 downto 0) :="0000000";
----------signal anodoparp: std_logic:='0';
signal catodoparp: std_logic:='0';
signal alarmaparp: std_logic:='0';
--------------signal enter_anterior: std_logic:='0';
signal down_anterior: std_logic:='0';
signal up_anterior: std_logic:='0';
signal right_anterior: std_logic:='0';
signal left_anterior: std_logic:='0';
signal enterok: std_logic:='0';
signal downok: std_logic:='0';
signal upok: std_logic:='0';
signal rightok: std_logic:='0';
signal leftok: std_logic:='0';
signal edicion: std_logic:='0';
---------------------signal catodo: natural range 0 to 7 :=0;
----------------signal contador_rebote: natural range 0 to 4000000 :=1; --para dividir reloj y o
btener 40ms
signal contador_estado: natural range 0 to 50000000 :=1;
TYPE estado IS (edo1,edo2,edo3,edo4);--estados posibles---en el primer estado qu
e sea cuando an no se le da enter y trabaje normalmente, el segundo estado cuando
hay un enter y que sea donde podemos modificar la hora pudiendo movernos con ri
ght, left y sumando y restando con down y up
TYPE estado1 IS (edo11,edo21,edo31,edo41);
SIGNAL edoactual: estado:=edo1; -- estado actual iniciado en el estado "inicio"
SIGNAL edosiguiente: estado;--Seal que controla el estado siguiente
SIGNAL edoactual1: estado1:=edo11;

SIGNAL edosiguiente1: estado1;


alias an1 is anodo(4);
alias an2 is anodo(3);
alias an3 is anodo(2);
alias an4 is anodo(1);
alias an5 is anodo(0);
begin
reloj:process(clk)
begin
if (clk'event and clk='1') then
if (count<100000000) then
count<=count+1;
else
count<=0;
seg<=seg+1;
if (seg=59) then
seg<=0;
min<=min+1+edmin;
if(min=59) then
min<=0;
hora<=hora+1+edhora;
if (hora=23) then
hora<=0;
end if;
end if;
end if;
end if;
end if;
end process;
retardo:process(clk)
begin
if (clk'event and clk='1') then
if (count1<100000) then
count1<=count1+1;
else
count1<=1;
if(paso<3) then
paso<=paso+1;
else
paso<=0;
end if;
if(catodo<7) then
catodo<=catodo+1;
else
catodo<=1;
end if;
end if;
end if;
end process;
muestreo:process(paso,catodo,d1,d2,d3,d4,edicion,anodoparp,catodoparp)----------------------------------------------------------------------------begin
case (paso)is
when 0 =>

segmentos<=d1;
if (edicion='1') then
anodos<=anodoparp&"111";
else
anodos<="0111";
end if;
when 1 =>
segmentos<=d2;
if (edicion='1') then
anodos<='1'&anodoparp&"11";
else
anodos<="1011";
end if;
when 2 =>
segmentos<=d3;
if (edicion='1') then
anodos<="11"&anodoparp&'1';
else
anodos<="1101";
end if;
when 3 =>
segmentos<=d4;
if (edicion='1') then
anodos<="111"&anodoparp;
else
anodos<="1110";
end if;
end case;
case catodo is
when 1=>
if (edicion='1') then
catodos<=catodoparp&"111111";
else
catodos<="0111111";
end if;
when 2=>
if (edicion='1') then
catodos<='1'&catodoparp&"11111";
else
catodos<="1011111";
end if;
when 3=>
if (edicion='1') then
catodos<="11"&catodoparp&"1111";
else
catodos<="1101111";
end if;
when 4=>
if (edicion='1') then
catodos<="111"&catodoparp&"111";
else
catodos<="1110111";
end if;
when 5=>
if (edicion='1') then

catodos<="1111"&catodoparp&"11";
else
catodos<="1111011";
end if;
when 6=>
if (edicion='1') then
catodos<="11111"&catodoparp&'1';
else
catodos<="1111101";
end if;
when 7=>
if (edicion='1') then
catodos<="111111"&catodoparp;
else
catodos<="1111110";
end if;
when others =>
catodos<="0000000";
end case;
end process;
----quiz when aqui para que en casos de donde est catodos entonces asignar valores
a anodos--------------------------------------------------------------unidades:process(min,hora,seg,minala,horaala)
variable de: integer :=0;
variable u: integer :=0;
variable de1: integer :=0;
variable u1: integer :=0;
variable de2: integer :=0;
variable u2: integer :=0;
variable deala: integer :=0;
variable uala: integer :=0;
variable deala1: integer :=0;
variable uala1: integer :=0;
begin
de:=(hora/10);
u:=((hora/1)-(de*10));
de1:=(min/10);
u1:=((min/1)-(de1*10));
de2:=(seg/10);
u2:=((seg/1)-(de2*10));
deala:=(horaala/10);
uala:=((horaala/1)-(deala*10));
deala1:=(minala/10);
uala1:=((minala/1)-(deala1*10));
if( edoactual=edo1 or edoactual=edo2) then
case (de) is
when 0 =>
d1<="0000001";
led1<="00";--0
if (catodo=1) then
anodo<="00000";
end if;
when 1=>
d1<="1001111";
led1<="01";--1
if (catodo=1) then
anodo<="10000";
end if;
when 2 =>

d1<="0010010";
led1<="10";--2
if (catodo=1) then
anodo<="01000";
end if;
when others =>
d1<="1111111";
led1<="11";--e
end if;
end case;
case (u) is
when 0 =>
d2<="0000001";
led2<="0000";--0
if (catodo=2) then
anodo<="00000";
end if;
when 1 =>
d2<="1001111";
led2<="0001";--1
if (catodo=2) then
anodo<="10000";
end if;
when 2 =>
d2<="0010010";
led2<="0010";--2
if (catodo=2) then
anodo<="01000";
end if;
when 3 =>
d2<="0000110";
led2<="0011";--3
if (catodo=2) then
anodo<="11000";
end if;
when 4 =>
d2<="1001100";
led2<="0100";--4
if (catodo=2) then
anodo<="00100";
end if;
when 5 =>
d2<="0100100";
led2<="0101";--5
if (catodo=2) then
anodo<="10100";
end if;
when 6 =>
d2<="0100000";
led2<="0110";--6
if (catodo=2) then
anodo<="01100";
end if;
when 7 =>
d2<="0001111";
led2<="0111";--7
if (catodo=2) then
anodo<="11100";
end if;

when 8 =>
d2<="0000000";
led2<="1000";--8
if (catodo=2) then
anodo<="00010";
end if;
when 9 =>
d2<="0001100";
led2<="1001";--9
if (catodo=2) then
anodo<="10010";
end if;
when others =>
d2<="1111111";
led2<="1111";--e
end case;
case (de1) is
when 0 =>
d3<="0000001";
led3<="000";--0
if (catodo=3) then
anodo<="00000";
end if;
when 1 =>
d3<="1001111";
led3<="001";--1
if (catodo=3) then
anodo<="10000";
end if;
when 2 =>
d3<="0010010";
led3<="010";--2
if (catodo=3) then
anodo<="01000";
end if;
when 3 =>
d3<="0000110";
led3<="011";--3
if (catodo=3) then
anodo<="11000";
end if;
when 4 =>
d3<="1001100";
led3<="100";--4
if (catodo=3) then
anodo<="00100";
end if;
when 5 =>
d3<="0100100";
led3<="101";--5
if (catodo=3) then
anodo<="10100";
end if;
when 6 =>
d3<="0100000";
led3<="110";--6
if (catodo=3) then
anodo<="01100";
end if;

when others =>


d3<="1111111";
led3<="111";--e
end case;
case (u1) is
when 0 =>
d4<="0000001";
led4<="0000";--0
if (catodo=4) then
anodo<="00000";
end if;
when 1 =>
d4<="1001111";
led4<="0001";--1
if (catodo=4) then
anodo<="10000";
end if;
when 2 =>
d4<="0010010";
led4<="0010";--2
if (catodo=4) then
anodo<="01000";
end if;
when 3 =>
d4<="0000110";
led4<="0011";--3
if (catodo=4) then
anodo<="11000";
end if;
when 4 =>
d4<="1001100";
led4<="0100";--4
if (catodo=4) then
anodo<="00100";
end if;
when 5 =>
d4<="0100100";
led4<="0101";--5
if (catodo=4) then
anodo<="10100";
end if;
when 6 =>
d4<="0100000";
led4<="0110";--6
if (catodo=4) then
anodo<="01100";
end if;
when 7 =>
d4<="0001111";
led4<="0111";--7
if (catodo=4) then
anodo<="11100";
end if;
when 8 =>
d4<="0000000";
led4<="1000";--8
if (catodo=4) then
anodo<="00010";
end if;

when 9 =>
d4<="0001100";
led4<="1001";--9
if (catodo=4) then
anodo<="10010";
end if;
when others =>
d4<="1111111";
led4<="1111";--e
end case;
elsif (edoactual=edo3) then
-----------------------------------------------------------------------------------------case (deala) is
when 0 =>
d1<="0000001";
led1<="00";--0
if (catodo=1) then
anodo<="00000";
end if;
when 1=>
d1<="1001111";
led1<="01";--1
if (catodo=1) then
anodo<="10000";
end if;
when 2 =>
d1<="0010010";
led1<="10";--2
if (catodo=1) then
anodo<="01000";
end if;
when others =>
d1<="1111111";
led1<="11";--e
end if;
end case;
case (uala) is
when 0 =>
d2<="0000001";
led2<="0000";--0
if (catodo=2) then
anodo<="00000";
end if;
when 1 =>
d2<="1001111";
led2<="0001";--1
if (catodo=2) then
anodo<="10000";
end if;
when 2 =>
d2<="0010010";
led2<="0010";--2
if (catodo=2) then
anodo<="01000";
end if;
when 3 =>

d2<="0000110";
led2<="0011";--3
if (catodo=2) then
anodo<="11000";
end if;
when 4 =>
d2<="1001100";
led2<="0100";--4
if (catodo=2) then
anodo<="00100";
end if;
when 5 =>
d2<="0100100";
led2<="0101";--5
if (catodo=2) then
anodo<="10100";
end if;
when 6 =>
d2<="0100000";
led2<="0110";--6
if (catodo=2) then
anodo<="01100";
end if;
when 7 =>
d2<="0001111";
led2<="0111";--7
if (catodo=2) then
anodo<="11100";
end if;
when 8 =>
d2<="0000000";
led2<="1000";--8
if (catodo=2) then
anodo<="00010";
end if;
when 9 =>
d2<="0001100";
led2<="1001";--9
if (catodo=2) then
anodo<="10010";
end if;
when others =>
d2<="1111111";
led2<="1111";--e
end case;
case (deala1) is
when 0 =>
d3<="0000001";
led3<="000";--0
if (catodo=3) then
anodo<="00000";
end if;
when 1 =>
d3<="1001111";
led3<="001";--1
if (catodo=3) then
anodo<="10000";
end if;
when 2 =>

d3<="0010010";
led3<="010";--2
if (catodo=3) then
anodo<="01000";
end if;
when 3 =>
d3<="0000110";
led3<="011";--3
if (catodo=3) then
anodo<="11000";
end if;
when 4 =>
d3<="1001100";
led3<="100";--4
if (catodo=3) then
anodo<="00100";
end if;
when 5 =>
d3<="0100100";
led3<="101";--5
if (catodo=3) then
anodo<="10100";
end if;
when 6 =>
d3<="0100000";
led3<="110";--6
if (catodo=3) then
anodo<="01100";
end if;
when others =>
d3<="1111111";
led3<="111";--e
end case;
case (uala1) is
when 0 =>
d4<="0000001";
led4<="0000";--0
if (catodo=4) then
anodo<="00000";
end if;
when 1 =>
d4<="1001111";
led4<="0001";--1
if (catodo=4) then
anodo<="10000";
end if;
when 2 =>
d4<="0010010";
led4<="0010";--2
if (catodo=4) then
anodo<="01000";
end if;
when 3 =>
d4<="0000110";
led4<="0011";--3
if (catodo=4) then
anodo<="11000";
end if;
when 4 =>

d4<="1001100";
led4<="0100";--4
if (catodo=4) then
anodo<="00100";
end if;
when 5 =>
d4<="0100100";
led4<="0101";--5
if (catodo=4) then
anodo<="10100";
end if;
when 6 =>
d4<="0100000";
led4<="0110";--6
if (catodo=4) then
anodo<="01100";
end if;
when 7 =>
d4<="0001111";
led4<="0111";--7
if (catodo=4) then
anodo<="11100";
end if;
when 8 =>
d4<="0000000";
led4<="1000";--8
if (catodo=4) then
anodo<="00010";
end if;
when 9 =>
d4<="0001100";
led4<="1001";--9
if (catodo=4) then
anodo<="10010";
end if;
when others =>
d4<="1111111";
led4<="1111";--e
end case;
end if;
-------------------------------------------------------------------------------------------------------------------case (de2) is
when 0 =>
led5<="000";--0
if (catodo=5) then
anodo<="00000";
end if;
when 1 =>
led5<="001";--1
if (catodo=5) then
anodo<="10000";
end if;
when 2 =>
led5<="010";--2
if (catodo=5) then
anodo<="01000";
end if;
when 3 =>
led5<="011";--3

if (catodo=5) then
anodo<="11000";
end if;
when 4 =>
led5<="100";--4
if (catodo=5) then
anodo<="00100";
end if;
when 5 =>
led5<="101";--5
if (catodo=5) then
anodo<="10100";
end if;
when 6 =>
led5<="110";--6
if (catodo=5) then
anodo<="01100";
end if;
when others =>
led5<="111";--e
end case;
case (u2) is
when 0 =>
led6<="0000";--0
if (catodo=6) then
anodo<="00000";
end if;
when 1 =>
led6<="0001";--1
if (catodo=6) then
anodo<="10000";
end if;
when 2 =>
led6<="0010";--2
if (catodo=6) then
anodo<="01000";
end if;
when 3 =>
led6<="0011";--3
if (catodo=6) then
anodo<="11000";
end if;
when 4 =>
led6<="0100";--4
if (catodo=6) then
anodo<="00100";
end if;
when 5 =>
led6<="0101";--5
if (catodo=6) then
anodo<="10100";
end if;
when 6 =>
led6<="0110";--6
if (catodo=6) then
anodo<="01100";
end if;
when 7 =>
led6<="0111";--7

if (catodo=6) then
anodo<="11100";
end if;
when 8 =>
led6<="1000";--8
if (catodo=6) then
anodo<="00010";
end if;
when 9 =>
led6<="1001";--9
if (catodo=6) then
anodo<="10010";
end if;
when others =>
led6<="1111";--e
end case;
end process;
--------------------filtro_rebotes:process(clk,enter,down,up,right,left)
begin
if (clk'event and clk='1') then
if(contador_rebote < 4000000)then
contador_rebote<=contador_rebote+1;
else
contador_rebote<=1;
if (enter_anterior = enter) then
enterok<=enter;
end if;
enter_anterior<=enter;
if(down_anterior = down)then
downok<=down;
end if;
down_anterior<=down;
if(up_anterior<=up)then
upok<=up;
end if;
up_anterior<=up;
if(right_anterior<=right
)then
rightok<=right;
end if;
right_anterior<=right;
if(left_
anterior<=left)then
leftok<=left;
end if;
left_anterior<=left;
end if;
end if;
end process;
------------Memoria:PROCESS(clk)
BEGIN
if (clk'event and clk='1') then
if (downok='1' or upok='1' or leftok='1' or rightok='1') then

if (contador_estado< 50000000) then


contador_estado<=contador_estado+1;
else
edoactual<=edosiguiente;
contador_estado<=1;
end if;
else
contador_estado<=49900000;
end if;
end if;
END PROCESS;
Combinacional: PROCESS(edoactual,edoactual1,enterok,downok,upok,rightok,leftok,e
dmin,minala)
begin
case edoactual is
WHEN edo1 =>
if(enterok='1')then
edosiguiente<=edo2;
end if;
edicion<='0';
--------if (hora=horaala and min=minala) then
edosiguiente<=edo4;
end if;
WHEN edo2=>
edicion<='1';
edmin<=0;
edhora<=0;
if(enterok='1')then
edosiguiente<=edo3;
end if;
case edoactual1 is
-----ver si esta mamada no sobrepasa en minutos a 59 y en horas a 23
WHEN edo11=>
if (downok='1') then
edmin<=edmin-1;
elsif (upok='1') then
edmin<=edmin+1;
end if;
if (leftok='1') then
edosiguiente1<=edo21;
elsif (rightok='1') then
edosiguiente1<=edo41;
end if;
WHEN edo21=>
if (downok='1') then
edmin<=edmin-10;
elsif (upok='1') then
edmin<=edmin+10;

end if;
if (leftok='1') then
edosiguiente1<=edo31;
elsif (rightok='1') then
edosiguiente1<=edo11;
end if;
WHEN edo31=>
if (downok='1') then
edhora<=edhora-1;
elsif (upok='1') then
edhora<=edhora+1;
end if;
if (leftok='1') then
edosiguiente1<=edo41;
elsif (rightok='1') then
edosiguiente1<=edo21;
end if;
WHEN edo41=>
if (downok='1') then
edhora<=edhora-10;
elsif (upok='1') then
edhora<=edhora+10;
end if;
if (leftok='1') then
edosiguiente1<=edo11;
elsif (rightok='1') then
edosiguiente1<=edo31;
end if;
end case;
WHEN edo3=>
edicion<='1';
edosiguiente1<=edo11;
if(enterok='1')then
edosiguiente<=edo1;
end if;
case edoactual1 is
WHEN edo11=>
if (downok='1') then
minala<=minala-1;
elsif (upok='1') then
minala<=minala+1;
end if;
if (leftok='1') then
edosiguiente1<=edo21;
elsif (rightok='1') then
edosiguiente1<=edo41;
end if;

WHEN edo21=>
if (downok='1') then
minala<=minala-10;
elsif (upok='1') then
minala<=minala+10;
end if;
if (leftok='1') then
edosiguiente1<=edo31;
elsif (rightok='1') then
edosiguiente1<=edo11;
end if;
WHEN edo31=>
if (downok='1') then
horaala<=horaala-1;
elsif (upok='1') then
horaala<=horaala+1;
end if;
if (leftok='1') then
edosiguiente1<=edo41;
elsif (rightok='1')then
edosiguiente1<=edo21;
end if;
WHEN edo41=>
if (downok='1') then
horaala<=horaala-10;
elsif (upok='1') then
horaala<=horaala+10;
end if;
if (leftok='1') then
edosiguiente1<=edo11;
elsif (rightok='1') then
edosiguiente1<=edo31;
end if;
end case;
WHEN edo4=>
alarma<=alarmaparp;
if ((rightok or leftok or upok or downok or enterok )='1') then
edosiguiente<=edo1;
alarma<='0';
end if;
case pasomatriz is
when 1=>
case catodo is
when 1=>
anodo<="11111";
when 2=>
anodo<="10001";
when 3=>
anodo<="10001";
when 4=>

anodo<="01110";
when 6=>
anodo<="11111";
when 7=>
anodo<="10101";
when others =>
anodo<="00000";
end case;
when 2=>
case catodo is
when 1=>
anodo<="10001";
when 2=>
anodo<="01110";
when 4=>
anodo<="11111";
when 5=>
anodo<="10101";
when 6=>
anodo<="10101";
when 7=>
anodo<="10001";
when others =>
anodo<="00000";
end case;
when 3=>
case catodo is
when 2=>
anodo<="11111";
when 3=>
anodo<="10101"
when 4=>
anodo<="10101";
when 5=>
anodo<="10001";
when 7=>
anodo<="10111";
when others =>
anodo<="00000";
end case;
when 4=>
case catodo is
when 1=>
anodo<="10101";
when 2=>
anodo<="10101";
when 3=>
anodo<="10001";
when 5=>
anodo<="10111";
when 6=>
anodo<="10101";
when 7=>
anodo<="10101";
when others =>
anodo<="00000";
end case;

when 5=>
case catodo is
when 1=>
anodo<="10001";
when 3=>
anodo<="10111";
when 5=>
anodo<="10101";
when 6=>
anodo<="11101";
when 4=>
anodo<="10101";
when others =>
anodo<="00000";
end case;
when 6=>
case catodo is
when 1=>
anodo<="10111";
when 2=>
anodo<="10101";
when 3=>
anodo<="10101";
when 4=>
anodo<="11101";
when 6=>
anodo<="11111";
when 7=>
anodo<="00001";
when others =>
anodo<="00000";
end case;
when 7=>
case catodo is
when 1=>
anodo<="10101";
when 2=>
anodo<="11101";
when 4=>
anodo<="11111";
when 5=>
anodo<="00101";
when 6=>
anodo<="00101";
when 7=>
anodo<="00010";
when others =>
anodo<="00000";
end case;
when 8=>
case catodo is
when 4=>
anodo<="00101";
when 2=>
anodo<="11111";
when 3=>

anodo<="00101";
when 5=>
anodo<="00010";
when 7=>
anodo<="10001";
when others =>
anodo<="00000";
end case;
when 9=>
case catodo is
when 1=>
anodo<="00101";
when 2=>
anodo<="00101";
when 3=>
anodo<="00010";
when 5=>
anodo<="10001";
when 6=>
anodo<="11111";
when 7=>
anodo<="10001";
when others =>
anodo<="00000";
end case;
when 10=>
case catodo is
when 1=>
anodo<="00010";
when 4=>
anodo<="11111";
when 3=>
anodo<="10001";
when 5=>
anodo<="10001";
when 7=>
anodo<="11111";
when others =>
anodo<="00000";
end case;
when 11=>
case catodo is
when 1=>
anodo<="10001";
when 2=>
anodo<="11111";
when 3=>
anodo<="10001";
when 5=>
anodo<="11111";
when 6=>
anodo<="10101";
when 7=>
anodo<="10101";
when others =>
anodo<="00000";
end case;

when 12=>
case catodo is
when 1=>
anodo<="10001";
when 4=>
anodo<="10101";
when 3=>
anodo<="11111";
when 5=>
anodo<="10101";
when 6=>
anodo<="10001";
when others =>
anodo<="00000";
end case;
when 13=>
case catodo is
when 1=>
anodo<="11111";
when 2=>
anodo<="10101";
when 3=>
anodo<="10101";
when 4=>
anodo<="10001";
when 6=>
anodo<="11111";
when 7=>
anodo<="00101";
when others =>
anodo<="00000";
end case;
when 14=>
case catodo is
when 1=>
anodo<="10101";
when 2=>
anodo<="10001";
when 4=>
anodo<="11111";
when 5=>
anodo<="00101";
when 6=>
anodo<="01101";
when 7=>
anodo<="10010";
when others =>
anodo<="00000";
end case;
when 15=>
case catodo is
when 4=>
anodo<="01101";--when 2=>
anodo<="11111";
when 3=>

anodo<="00101";
when 5=>
anodo<="10010";
when 7=>
anodo<="00001";
when others =>
anodo<="00000";
end case;
when 16=>
case catodo is
when 1=>
anodo<="00101";
when 2=>
anodo<="01101";
when 3=>
anodo<="10010";
when 5=>
anodo<="00001";
when 6=>
anodo<="11111";
when 7=>
anodo<="00001";
when others =>
anodo<="00000";
end case;
when 17=>
case catodo is
when 1=>
anodo<="10010";
when 4=>
anodo<="11111";
when 3=>
anodo<="00001";
when 5=>
anodo<="00001";
when 7=>
anodo<="11110";
when others =>
anodo<="00000";
end case;
when 18=>
case catodo is
when 1=>
anodo<="00001";
when 2=>
anodo<="11111";
when 3=>
anodo<="00001";
when 5=>
anodo<="11110";
when 6=>
anodo<="00101";
when 7=>
anodo<="00101";
when others =>
anodo<="00000";
end case;

when 19=>
case catodo is
when 1=>
anodo<="00001";
when 4=>
anodo<="00101";
when 3=>
anodo<="11110";
when 5=>
anodo<="00101";
when 6=>
anodo<="11110";
when others =>
anodo<="00000";
end case;
when 20=>
case catodo is
when 1=>
anodo<="11110";
when 2=>
anodo<="00101";
when 3=>
anodo<="00101";
when 4=>
anodo<="11110";
when others =>
anodo<="00000";
end case;
when 21=>
case catodo is
when 1=>
anodo<="00101";
when 2=>
anodo<="11110";
when 7=>
anodo<="11111";
when others =>
anodo<="00000";
end case;
when 22=>
case catodo is
when 5=>
anodo<="11111";
when 6=>
anodo<="10001";
when 7=>
anodo<="10001";
when others =>
anodo<="00000";
end case;
when 23=>
case catodo is
when 3=>
anodo<="11111";
when 5=>

anodo<="10001";
when 6=>
anodo<="01110";
when 4=>
anodo<="10001";
when others =>
anodo<="00000";
end case;
end case;
end case;
end process;
parpadeo :process (clk)
begin
if (clk'event and clk='1') then
if (parp<25000000) then
parp<=parp+1; ----crear natural range parp
else
parp<=0;
anodoparp<= not(anodoparp);
catodoparp<= not(catodoparp);
alarmaparp<=not(alarmaparp);
end if;
end if;
end process;
alarma :process(clk)
begin
if (edoactual<=edo4) then
if(clk'event and clk='1') then
if (matriz<20000000) then
matriz<=matriz+1;
else
matriz<=1;
if (pasomatriz<23) then
pasomatriz<=pasomatriz+1;
else
pasomatriz<=1;
end if;
end if;
end if;
else
pasomatriz<=1;
end if;
end process;
--------------------------------end Behavioral;