Mudanças entre as edições de "PROJETO FINAL - SST"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
(Criou página com 'Alunos: Leonardo, Nicole e Rogério')
 
 
(26 revisões intermediárias por 2 usuários não estão sendo mostradas)
Linha 1: Linha 1:
 
Alunos: Leonardo, Nicole e Rogério
 
Alunos: Leonardo, Nicole e Rogério
 +
 +
=Máquina de Estados=
 +
 +
[[Arquivo:maquinaestado2.jpg]]
 +
 +
=WaveForm=
 +
 +
[[Arquivo:waveform.jpg|980px|thumb|left]]
 +
 +
=Pinagem=
 +
 +
[[Arquivo:pinagem.jpg]]
 +
 +
=Código=
 +
 +
;Método adotado:
 +
 +
*A abordagem utilizada foi Behavioral. Modela como as saídas do sistema irão reagir às entradas do sistema.Dessa forma ficou mais simples e fácil de entender;
 +
*O relógio possui 2 estados: Estado = '0', significa que ele esta no processo de contagem. Estado = '1', ele esta no processo de ajuste;
 +
*Cada unidade e dezena de hora,minuto e segundo são atreladas a uma variável para uma eventual exibição no display de 7 segmentos;
 +
* Como a saída da máquina depende do estado presente e também das entradas, o sistema é uma máquina de Mealy;
 +
* Foram utilizados dois processos sendo o mesmo o coração da abordagem behavioral;
 +
* O primeiro processo define a troca dos estados, já o segundo realiza a seleção do estado para realização de suas atividades (Contagem ou ajuste).
 +
 +
 +
 +
{{collapse top | '''Código VHDL''' - Clicar no "+" para expandir }}
 +
 +
;:<syntaxhighlight lang=vhdl>
 +
 +
library ieee;
 +
use ieee.std_logic_1164.all;
 +
use ieee.std_logic_unsigned.all;
 +
use ieee.std_logic_arith.all;
 +
 +
entity timer is
 +
       
 +
        generic (FCLK: integer := 50000000); --Frequencia de operaçao do CLOCK da placa DE2-115
 +
        PORT (CLK, ESTADO,RESET, Ajuste_hora, Ajuste_minuto,cronometro,iniciar_cronometro : in std_logic; 
 +
              seg1, seg2, min1, min2, hora1, hora2 : out std_logic_vector (6 downto 0));
 +
--seg1 e a unidade do segundo e seg2 e a dezena
 +
      --hora e min seguem a mesma logica
 +
             
 +
end timer;
 +
 +
  --utilizamos a abordagem behavioral (comportamental)
 +
 +
architecture contador of timer is
 +
   
 +
--Criaçao dos dois estados(ajusta e conta)
 +
    type state_type is (ST0, ST1);
 +
    signal state: state_type;
 +
 +
 +
    begin
 +
 +
-- Formulando os estados do sistema
 +
process (ESTADO)
 +
begin 
 +
if (ESTADO ='0') then --Caso estado seja igual a zero o processo de contagem eh realizado
 +
state <= ST0; --Estado de contagem
 +
else
 +
state <= ST1; --Estado de ajuste
 +
end if; 
 +
end process;
 +
 +
  --Foi criado o processo com sensibilidade do CLOCK, RESET, Ajuste_hora e Ajuste_minuto, pois caso haja alteraçao em dessas variaveis
 +
  --o processo eh realizado
 +
   
 +
 
 +
    process(CLK, RESET, Ajuste_hora, Ajuste_minuto,cronometro,iniciar_cronometro)
 +
 +
  --Foram criadas variaveis auxiliares para armazenar os valores de hora, minuto e segundo para que eles sejam inseridos no display
 +
 
 +
          VARIABLE clock,clock_cronometro: INTEGER RANGE 0 TO FCLK; --A variaçao do CLK eh iniciado no zero e ateh a sua freq maxima
 +
          VARIABLE segundo1,segundo1_cronometro : INTEGER RANGE 0 TO 10; --Representa a unidade do segundo
 +
          VARIABLE segundo2,segundo2_cronometro : INTEGER RANGE 0 TO 6;  --Representa a dezena do segundo
 +
          VARIABLE minuto1, minuto11,minuto1_cronometro: INTEGER RANGE 0 TO 10;
 +
          VARIABLE minuto2, minuto22,minuto2_cronometro: INTEGER RANGE 0 TO 6;
 +
          VARIABLE horas1, horas11,horas1_cronometro: INTEGER RANGE 0 TO 10;
 +
          VARIABLE horas2, horas22,horas2_cronometro: INTEGER RANGE 0 TO 10;
 +
 
 +
  --Minuto11, Minuto22, Horas11 e Horas22 sao variaveis de ajuste. As demais variaveis sao auxiliares para contagem.   
 +
 +
    begin
 +
                                         
 +
 +
    case state is
 +
 +
when ST0 =>
 +
   
 +
    IF (RESET = '0' and cronometro = '0') THEN --Se o reset estiver ativo baixo todas as variaveis serao zeradas reiniciado
 +
      clock := 0;
 +
      segundo1 := 0;
 +
      segundo2 := 0;
 +
      minuto1  := 0;
 +
      minuto2  := 0;
 +
      horas1  := 0;
 +
      horas2  := 0;
 +
      minuto11 := 0;
 +
      minuto22 := 0;
 +
      horas11  := 0;
 +
      horas22  := 0;
 +
     
 +
  --A contagem do CLOCK ateh o seu valor maximo (o que corresponde a um segundo) eh verificada na borda de subida do CLOCK
 +
 
 +
        ELSIF (CLK'event AND CLK='1') then         
 +
              clock := clock + 1;
 +
         
 +
--Quando a frequencia do CLK chegar em seu valor maximo o mesmo sera zerado e inicia a contagem
 +
           
 +
        IF (clock = FCLK) then         
 +
            clock := 0;
 +
            segundo1 := segundo1 + 1;
 +
 +
--Realizaçao da contagem
 +
 +
                IF (segundo1 = 10) then 
 +
                    segundo1 := 0;
 +
                    segundo2 := segundo2 + 1;
 +
                    IF (segundo2 = 6) then
 +
                        segundo2 := 0;
 +
                        minuto1 := minuto1 + 1;
 +
                        IF (minuto1 = 10 ) then
 +
                            minuto1 := 0;
 +
                            minuto2 := minuto2 + 1;
 +
                            IF (minuto2 = 6) then
 +
                                minuto2 := 0;
 +
                                horas1 := horas1 + 1;
 +
                                IF (horas1 = 10) then
 +
                                    horas1 := 0;
 +
                                    horas2 := horas2 + 1;
 +
                                  IF (horas2 = 2) then
 +
                                      horas2 := 0;
 +
                                  END IF;
 +
                                END IF;
 +
                            END IF;
 +
                        END IF;
 +
                    END IF;
 +
                END IF;
 +
        END IF;
 +
    END IF;     
 +
 +
   
 +
---  ajustando cronometro
 +
 +
--IF (cronometro = '1') then
 +
--
 +
--
 +
--  IF (iniciar_cronometro = '1') then 
 +
--
 +
--        IF (CLK'event AND CLK='1') then           
 +
--            clock_cronometro := clock_cronometro + 1; 
 +
--             
 +
--              IF (clock_cronometro = FCLK) then         
 +
--                  clock_cronometro    := 0;
 +
--                  segundo1_cronometro := segundo1_cronometro + 1;
 +
--                  IF (segundo1_cronometro = 10) then
 +
--                      segundo1_cronometro := 0;
 +
--                      segundo2_cronometro := segundo2_cronometro + 1;
 +
--                    IF (segundo2_cronometro = 6) then
 +
--                        segundo2_cronometro := 0;
 +
--                        minuto1_cronometro := minuto1_cronometro + 1;
 +
--                        IF (minuto1_cronometro = 10 ) then
 +
--                            minuto1_cronometro := 0;
 +
--                            minuto2_cronometro := minuto2_cronometro + 1;
 +
--                            IF (minuto2_cronometro = 6) then
 +
--                                minuto2_cronometro := 0;
 +
--                                horas1_cronometro := horas1_cronometro + 1;
 +
--                                IF (horas1_cronometro = 10) then
 +
--                                    horas1_cronometro := 0;
 +
--                                    horas2_cronometro := horas2_cronometro + 1;
 +
--                                  IF (horas2_cronometro = 2) then
 +
--                                    horas2_cronometro := 0;
 +
--                                  END IF;
 +
--                                END IF;
 +
--                            END IF;
 +
--                          END IF;
 +
--                      END IF;
 +
--                END IF;
 +
--            END IF;
 +
--        END IF;
 +
--    END IF;
 +
--
 +
--
 +
--
 +
--    IF (RESET = '0' and cronometro = '1') THEN
 +
--        clock_cronometro    := 0;
 +
--        segundo1_cronometro := 0;
 +
--        segundo2_cronometro :=0;
 +
--        minuto1_cronometro := 0;
 +
--        minuto2_cronometro :=0;
 +
--        horas1_cronometro :=0;
 +
--        horas2_cronometro :=0;
 +
--    END IF;
 +
--END IF;
 +
 +
 +
 +
--Ajuste de horario--     
 +
                     
 +
      when ST1 =>  --Significa que estah no estado de ajuste
 +
 +
          if (falling_edge (Ajuste_minuto)) then --A identificaçao que o ajuste minuto foi alterado eh realizado na borda descida (pressionar botao)
 +
              minuto11 := minuto1 + 1;
 +
              if (minuto11 = 10) then
 +
                  minuto11 :=0;
 +
                  minuto22 := minuto2 + 1;
 +
                  if (minuto22 = 6) then
 +
                      minuto22 := 0;
 +
                  end if;
 +
                end if;
 +
            end if;
 +
                                 
 +
 +
    if (falling_edge (Ajuste_hora)) then    --Mesma logica do ajuste minuto       
 +
                horas11 := horas1 +1;
 +
                if (horas11 = 10) then
 +
                    horas11 :=0;                                                 
 +
                    horas22 := horas2 + 1;                                           
 +
                end if;
 +
                    if (horas22 = 2) then
 +
                                                             
 +
                        if (horas11  = 4) then
 +
                            horas11 := 0;
 +
                            horas22 := 0;                                   
 +
                        end if;
 +
                    end if;
 +
              end if; 
 +
                                             
 +
                                         
 +
--Atribuiçao da variavel de ajuste para a variavel de contagem que sera encaminhada para o display
 +
 +
clock :=0;
 +
minuto1 := minuto11;
 +
minuto2 := minuto22;
 +
horas1 := horas11;
 +
horas2 := horas22;
 +
 
 +
end case;
 +
             
 +
---------CONVERÇAO PARA DISPLAY 7 SEGMETOS---------
 +
 +
-- caso relogio normal
 +
-- if (cronometro = '0') then
 +
             
 +
case segundo1 is
 +
    when 0 => seg1 <= not("1111110"); --126
 +
    when 1 => seg1 <= not("0110000"); --48
 +
    when 2 => seg1 <= not("1101101"); --109
 +
    when 3 => seg1 <= not("1111001"); --121
 +
    when 4 => seg1 <= not("0110011"); --51
 +
    when 5 => seg1 <= not("1011011"); --91
 +
    when 6 => seg1 <= not("1011111"); --95
 +
    when 7 => seg1 <= not("1110000"); --112
 +
    when 8 => seg1 <= not("1111111"); --127 
 +
    when 9 => seg1 <= not("1111011"); --123
 +
    when others => seg1 <= not("1001111"); --79 (“E”)
 +
end case;
 +
case segundo2 is
 +
    when 0 => seg2 <= not("1111110"); --126
 +
    when 1 => seg2 <= not("0110000"); --48
 +
    when 2 => seg2 <= not("1101101"); --109
 +
    when 3 => seg2 <= not("1111001");  --121
 +
    when 4 => seg2 <= not("0110011"); --51
 +
    when 5 => seg2 <= not("1011011"); --91
 +
    when 6 => seg2 <= not("1011111"); --95
 +
    when others => seg2 <= not("1001111"); --79 (“E”)
 +
end case; 
 +
case minuto1 is
 +
    when 0 => min1 <= not("1111110"); --126
 +
    when 1 => min1 <= not("0110000"); --48
 +
    when 2 => min1 <= not("1101101"); --109
 +
    when 3 => min1 <= not("1111001");  --121
 +
    when 4 => min1 <= not("0110011"); --51
 +
    when 5 => min1 <= not("1011011"); --91
 +
    when 6 => min1 <= not("1011111"); --95
 +
    when 7 => min1 <= not("1110000");--112
 +
    when 8 => min1 <= not("1111111"); --127 
 +
    when 9 => min1 <= not("1111011");--123
 +
  when others => min1 <= not("1001111"); --79 (“E”)
 +
end case;
 +
case minuto2 is
 +
    when 0 => min2 <= not("1111110"); --126
 +
    when 1 => min2 <= not("0110000"); --48
 +
    when 2 => min2 <= not("1101101"); --109
 +
    when 3 => min2 <= not("1111001");  --121
 +
    when 4 => min2 <= not("0110011"); --51
 +
    when 5 => min2 <= not("1011011"); --91
 +
    when 6 => min2 <= not("1011111"); --95
 +
    when others => min2 <= not("1001111"); --79 (“E”)
 +
end case; 
 +
case horas1 is
 +
    when 0 => hora1 <= not("1111110"); --126
 +
    when 1 => hora1 <= not("0110000"); --48
 +
    when 2 => hora1 <= not("1101101"); --109
 +
    when 3 => hora1 <= not("1111001");  --121
 +
    when 4 => hora1 <= not("0110011"); --51
 +
    when 5 => hora1 <= not("1011011"); --91
 +
    when 6 => hora1 <= not("1011111"); --95
 +
    when 7 => hora1 <= not("1110000");--112
 +
    when 8 => hora1 <= not("1111111"); --127 
 +
    when 9 => hora1 <= not("1111011");--123
 +
  when others => hora1 <= not("1001111"); --79 (“E”)
 +
end case;
 +
case horas2 is
 +
    when 0 => hora2 <= not("1111110"); --126
 +
    when 1 => hora2 <= not("0110000"); --48
 +
    when 2 => hora2 <= not("1101101"); --109
 +
    when others => hora2 <= not("1001111"); --79 (“E”)   
 +
end case; 
 +
 +
-- caso relogio cronometando
 +
--else
 +
--case segundo1_cronometro is
 +
--    when 0 => seg1 <= not("1111110"); --126
 +
--    when 1 => seg1 <= not("0110000"); --48
 +
--    when 2 => seg1 <= not("1101101"); --109
 +
--    when 3 => seg1 <= not("1111001"); --121
 +
--    when 4 => seg1 <= not("0110011"); --51
 +
--    when 5 => seg1 <= not("1011011"); --91
 +
--    when 6 => seg1 <= not("1011111"); --95
 +
--    when 7 => seg1 <= not("1110000"); --112
 +
--    when 8 => seg1 <= not("1111111"); --127 
 +
--    when 9 => seg1 <= not("1111011"); --123
 +
--  when others => seg1 <= not("1001111"); --79 (“E”)
 +
--end case;
 +
--case segundo2_cronometro is
 +
--    when 0 => seg2 <= not("1111110"); --126
 +
--    when 1 => seg2 <= not("0110000"); --48
 +
--    when 2 => seg2 <= not("1101101"); --109
 +
--    when 3 => seg2 <= not("1111001");  --121
 +
--    when 4 => seg2 <= not("0110011"); --51
 +
--    when 5 => seg2 <= not("1011011"); --91
 +
--    when 6 => seg2 <= not("1011111"); --95
 +
--    when others => seg2 <= not("1001111"); --79 (“E”)
 +
--end case; 
 +
--case minuto1_cronometro is
 +
--    when 0 => min1 <= not("1111110"); --126
 +
--    when 1 => min1 <= not("0110000"); --48
 +
--    when 2 => min1 <= not("1101101"); --109
 +
--    when 3 => min1 <= not("1111001");  --121
 +
--    when 4 => min1 <= not("0110011"); --51
 +
--    when 5 => min1 <= not("1011011"); --91
 +
--    when 6 => min1 <= not("1011111"); --95
 +
--    when 7 => min1 <= not("1110000");--112
 +
--    when 8 => min1 <= not("1111111"); --127 
 +
--    when 9 => min1 <= not("1111011");--123
 +
--  when others => min1 <= not("1001111"); --79 (“E”)
 +
--end case;
 +
--case minuto2_cronometro is
 +
--    when 0 => min2 <= not("1111110"); --126
 +
--    when 1 => min2 <= not("0110000"); --48
 +
--    when 2 => min2 <= not("1101101"); --109
 +
--    when 3 => min2 <= not("1111001");  --121
 +
--    when 4 => min2 <= not("0110011"); --51
 +
--    when 5 => min2 <= not("1011011"); --91
 +
--    when 6 => min2 <= not("1011111"); --95
 +
--    when others => min2 <= not("1001111"); --79 (“E”)
 +
--end case; 
 +
--case horas1_cronometro is
 +
--    when 0 => hora1 <= not("1111110"); --126
 +
--    when 1 => hora1 <= not("0110000"); --48
 +
--    when 2 => hora1 <= not("1101101"); --109
 +
--    when 3 => hora1 <= not("1111001");  --121
 +
--    when 4 => hora1 <= not("0110011"); --51
 +
--    when 5 => hora1 <= not("1011011"); --91
 +
--    when 6 => hora1 <= not("1011111"); --95
 +
--    when 7 => hora1 <= not("1110000");--112
 +
--    when 8 => hora1 <= not("1111111"); --127 
 +
--    when 9 => hora1 <= not("1111011");--123
 +
--  when others => hora1 <= not("1001111"); --79 (“E”)
 +
--end case;
 +
--case horas2_cronometro is
 +
--    when 0 => hora2 <= not("1111110"); --126
 +
--    when 1 => hora2 <= not("0110000"); --48
 +
--    when 2 => hora2 <= not("1101101"); --109
 +
--    when others => hora2 <= not("1001111"); --79 (“E”)   
 +
--end case; 
 +
--
 +
--end if;
 +
 +
 +
 +
            end process;
 +
   
 +
END ARCHITECTURE;
 +
 +
 +
 +
 +
</syntaxhighlight>
 +
 +
 +
{{collapse bottom}}

Edição atual tal como às 10h27min de 23 de junho de 2015

Alunos: Leonardo, Nicole e Rogério

Máquina de Estados

Maquinaestado2.jpg

WaveForm

Waveform.jpg

Pinagem

Pinagem.jpg

Código

Método adotado
  • A abordagem utilizada foi Behavioral. Modela como as saídas do sistema irão reagir às entradas do sistema.Dessa forma ficou mais simples e fácil de entender;
  • O relógio possui 2 estados: Estado = '0', significa que ele esta no processo de contagem. Estado = '1', ele esta no processo de ajuste;
  • Cada unidade e dezena de hora,minuto e segundo são atreladas a uma variável para uma eventual exibição no display de 7 segmentos;
  • Como a saída da máquina depende do estado presente e também das entradas, o sistema é uma máquina de Mealy;
  • Foram utilizados dois processos sendo o mesmo o coração da abordagem behavioral;
  • O primeiro processo define a troca dos estados, já o segundo realiza a seleção do estado para realização de suas atividades (Contagem ou ajuste).


Código VHDL - Clicar no "+" para expandir
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity timer is
         
        generic (FCLK: integer := 50000000); --Frequencia de operaçao do CLOCK da placa DE2-115
        PORT (CLK, ESTADO,RESET, Ajuste_hora, Ajuste_minuto,cronometro,iniciar_cronometro : in std_logic;  
              seg1, seg2, min1, min2, hora1, hora2 : out std_logic_vector (6 downto 0));
		--seg1 e a unidade do segundo e seg2 e a dezena
      --hora e min seguem a mesma logica		
              
end timer;

	   --utilizamos a abordagem behavioral (comportamental)

architecture contador of timer is 
     
	--Criaçao dos dois estados(ajusta e conta)
     type state_type is (ST0, ST1); 
     signal state: state_type;


    begin

-- Formulando os estados do sistema
process (ESTADO)
begin   
if (ESTADO ='0') then --Caso estado seja igual a zero o processo de contagem eh realizado
state <= ST0; --Estado de contagem
else						
state <= ST1; --Estado de ajuste
end if;   
end process;

  --Foi criado o processo com sensibilidade do CLOCK, RESET, Ajuste_hora e Ajuste_minuto, pois caso haja alteraçao em dessas variaveis 
  --o processo eh realizado
    
  
    process(CLK, RESET, Ajuste_hora, Ajuste_minuto,cronometro,iniciar_cronometro) 
	 
  --Foram criadas variaveis auxiliares para armazenar os valores de hora, minuto e segundo para que eles sejam inseridos no display
  
          VARIABLE clock,clock_cronometro: INTEGER RANGE 0 TO FCLK; --A variaçao do CLK eh iniciado no zero e ateh a sua freq maxima 
          VARIABLE segundo1,segundo1_cronometro : INTEGER RANGE 0 TO 10; --Representa a unidade do segundo
          VARIABLE segundo2,segundo2_cronometro : INTEGER RANGE 0 TO 6;  --Representa a dezena do segundo
          VARIABLE minuto1, minuto11,minuto1_cronometro: INTEGER RANGE 0 TO 10; 
          VARIABLE minuto2, minuto22,minuto2_cronometro: INTEGER RANGE 0 TO 6;
          VARIABLE horas1, horas11,horas1_cronometro: INTEGER RANGE 0 TO 10;
          VARIABLE horas2, horas22,horas2_cronometro: INTEGER RANGE 0 TO 10;
  
  --Minuto11, Minuto22, Horas11 e Horas22 sao variaveis de ajuste. As demais variaveis sao auxiliares para contagem.    
	 
    begin
                                           

    case state is 

when ST0 =>
     
    IF (RESET = '0' and cronometro = '0') THEN --Se o reset estiver ativo baixo todas as variaveis serao zeradas reiniciado
       clock := 0;
       segundo1 := 0;
       segundo2 := 0;
       minuto1  := 0;
       minuto2  := 0;
       horas1   := 0;
       horas2   := 0;
       minuto11 := 0;
       minuto22 := 0;
       horas11  := 0;
       horas22   := 0;
      
	   --A contagem do CLOCK ateh o seu valor maximo (o que corresponde a um segundo) eh verificada na borda de subida do CLOCK 
	  
        ELSIF (CLK'event AND CLK='1') then           
               clock := clock + 1;
          
		--Quando a frequencia do CLK chegar em seu valor maximo o mesmo sera zerado e inicia a contagem
             		 
         IF (clock = FCLK) then          
             clock := 0;
             segundo1 := segundo1 + 1;
				
		--Realizaçao da contagem
		
                IF (segundo1 = 10) then   
                    segundo1 := 0;
                    segundo2 := segundo2 + 1;
                    IF (segundo2 = 6) then
                        segundo2 := 0;
                        minuto1 := minuto1 + 1;
                        IF (minuto1 = 10 ) then
                            minuto1 := 0;
                            minuto2 := minuto2 + 1;
                            IF (minuto2 = 6) then
                                minuto2 := 0;
                                horas1 := horas1 + 1;
                                IF (horas1 = 10) then
                                    horas1 := 0;
                                    horas2 := horas2 + 1;
                                  IF (horas2 = 2) then
                                      horas2 := 0;
                                  END IF;
                                END IF;
                            END IF;
                         END IF;
                     END IF;
                 END IF;
        END IF;
    END IF;       

    
---  ajustando cronometro

--IF (cronometro = '1') then
--
--
--   IF (iniciar_cronometro = '1') then   
--	 
--        IF (CLK'event AND CLK='1') then            
--            clock_cronometro := clock_cronometro + 1;   
--              
--              IF (clock_cronometro = FCLK) then           
--                  clock_cronometro    := 0; 
--                  segundo1_cronometro := segundo1_cronometro + 1;
--                  IF (segundo1_cronometro = 10) then
--                      segundo1_cronometro := 0;
--                      segundo2_cronometro := segundo2_cronometro + 1;
--                    IF (segundo2_cronometro = 6) then
--                        segundo2_cronometro := 0;
--                        minuto1_cronometro := minuto1_cronometro + 1;
--                        IF (minuto1_cronometro = 10 ) then
--                            minuto1_cronometro := 0;
--                            minuto2_cronometro := minuto2_cronometro + 1;
--                            IF (minuto2_cronometro = 6) then
--                                minuto2_cronometro := 0;
--                                horas1_cronometro := horas1_cronometro + 1;
--                                IF (horas1_cronometro = 10) then
--                                    horas1_cronometro := 0;
--                                    horas2_cronometro := horas2_cronometro + 1;
--                                  IF (horas2_cronometro = 2) then
--                                     horas2_cronometro := 0;
--                                  END IF;
--                                END IF;
--                             END IF;
--                          END IF;
--                      END IF;
--                 END IF;
--             END IF;
--        END IF;
--    END IF;
--
--
--
--     IF (RESET = '0' and cronometro = '1') THEN
--         clock_cronometro    := 0;
--         segundo1_cronometro := 0;
--         segundo2_cronometro :=0;
--         minuto1_cronometro := 0;
--         minuto2_cronometro :=0;
--         horas1_cronometro :=0;
--         horas2_cronometro :=0;
--     END IF;
--END IF;



--Ajuste de horario--      
                       
      when ST1 =>   --Significa que estah no estado de ajuste

           if (falling_edge (Ajuste_minuto)) then --A identificaçao que o ajuste minuto foi alterado eh realizado na borda descida (pressionar botao)
               minuto11 := minuto1 + 1;
               if (minuto11 = 10) then
                   minuto11 :=0;
                   minuto22 := minuto2 + 1;
                   if (minuto22 = 6) then
                       minuto22 := 0;
                   end if;
                end if;
            end if;
                                  
											
	    if (falling_edge (Ajuste_hora)) then    --Mesma logica do ajuste minuto         
                horas11 := horas1 +1;
                if (horas11 = 10) then
                    horas11 :=0;                                                   
                    horas22 := horas2 + 1;                                            
                end if;
                    if (horas22 = 2) then
                                                               
                        if (horas11  = 4) then
                            horas11 := 0;
                            horas22 := 0;                                    
                        end if;
                    end if;
              end if;   
                                               
                                           
--Atribuiçao da variavel de ajuste para a variavel de contagem que sera encaminhada para o display

clock :=0;
minuto1 := minuto11;
minuto2 := minuto22;
horas1 := horas11;
horas2 := horas22;
   
end case;
              
---------CONVERÇAO PARA DISPLAY 7 SEGMETOS---------

 -- caso relogio normal
-- if (cronometro = '0') then
               
case segundo1 is
    when 0 => seg1 <= not("1111110"); --126
    when 1 => seg1 <= not("0110000"); --48
    when 2 => seg1 <= not("1101101"); --109
    when 3 => seg1 <= not("1111001"); --121
    when 4 => seg1 <= not("0110011"); --51
    when 5 => seg1 <= not("1011011"); --91
    when 6 => seg1 <= not("1011111"); --95
    when 7 => seg1 <= not("1110000"); --112
    when 8 => seg1 <= not("1111111"); --127  
    when 9 => seg1 <= not("1111011"); --123
    when others => seg1 <= not("1001111"); --79 (“E”)
end case;
case segundo2 is
    when 0 => seg2 <= not("1111110"); --126
    when 1 => seg2 <= not("0110000"); --48
    when 2 => seg2 <= not("1101101"); --109
    when 3 => seg2 <= not("1111001");  --121
    when 4 => seg2 <= not("0110011"); --51
    when 5 => seg2 <= not("1011011"); --91
    when 6 => seg2 <= not("1011111"); --95
    when others => seg2 <= not("1001111"); --79 (“E”)
end case;   
case minuto1 is
    when 0 => min1 <= not("1111110"); --126
    when 1 => min1 <= not("0110000"); --48
    when 2 => min1 <= not("1101101"); --109
    when 3 => min1 <= not("1111001");  --121
    when 4 => min1 <= not("0110011"); --51
    when 5 => min1 <= not("1011011"); --91
    when 6 => min1 <= not("1011111"); --95
    when 7 => min1 <= not("1110000");--112
    when 8 => min1 <= not("1111111"); --127  
    when 9 => min1 <= not("1111011");--123
  when others => min1 <= not("1001111"); --79 (“E”)
end case;
case minuto2 is
    when 0 => min2 <= not("1111110"); --126
    when 1 => min2 <= not("0110000"); --48
    when 2 => min2 <= not("1101101"); --109
    when 3 => min2 <= not("1111001");  --121
    when 4 => min2 <= not("0110011"); --51
    when 5 => min2 <= not("1011011"); --91
    when 6 => min2 <= not("1011111"); --95
    when others => min2 <= not("1001111"); --79 (“E”)
end case;   
case horas1 is
    when 0 => hora1 <= not("1111110"); --126
    when 1 => hora1 <= not("0110000"); --48
    when 2 => hora1 <= not("1101101"); --109
    when 3 => hora1 <= not("1111001");  --121
    when 4 => hora1 <= not("0110011"); --51
    when 5 => hora1 <= not("1011011"); --91
    when 6 => hora1 <= not("1011111"); --95
    when 7 => hora1 <= not("1110000");--112
    when 8 => hora1 <= not("1111111"); --127  
    when 9 => hora1 <= not("1111011");--123
  when others => hora1 <= not("1001111"); --79 (“E”)
end case;
case horas2 is
    when 0 => hora2 <= not("1111110"); --126
    when 1 => hora2 <= not("0110000"); --48
    when 2 => hora2 <= not("1101101"); --109
    when others => hora2 <= not("1001111"); --79 (“E”)    
end case;  

 -- caso relogio cronometando
--else
--case segundo1_cronometro is
--    when 0 => seg1 <= not("1111110"); --126
--    when 1 => seg1 <= not("0110000"); --48
--    when 2 => seg1 <= not("1101101"); --109
--    when 3 => seg1 <= not("1111001"); --121
--    when 4 => seg1 <= not("0110011"); --51
--    when 5 => seg1 <= not("1011011"); --91
--    when 6 => seg1 <= not("1011111"); --95
--    when 7 => seg1 <= not("1110000"); --112
--    when 8 => seg1 <= not("1111111"); --127  
--    when 9 => seg1 <= not("1111011"); --123
--  when others => seg1 <= not("1001111"); --79 (“E”)
--end case;
--case segundo2_cronometro is
--    when 0 => seg2 <= not("1111110"); --126
--    when 1 => seg2 <= not("0110000"); --48
--    when 2 => seg2 <= not("1101101"); --109
--    when 3 => seg2 <= not("1111001");  --121
--    when 4 => seg2 <= not("0110011"); --51
--    when 5 => seg2 <= not("1011011"); --91
--    when 6 => seg2 <= not("1011111"); --95
--    when others => seg2 <= not("1001111"); --79 (“E”)
--end case;   
--case minuto1_cronometro is
--    when 0 => min1 <= not("1111110"); --126
--    when 1 => min1 <= not("0110000"); --48
--    when 2 => min1 <= not("1101101"); --109
--    when 3 => min1 <= not("1111001");  --121
--    when 4 => min1 <= not("0110011"); --51
--    when 5 => min1 <= not("1011011"); --91
--    when 6 => min1 <= not("1011111"); --95
--    when 7 => min1 <= not("1110000");--112
--    when 8 => min1 <= not("1111111"); --127  
--    when 9 => min1 <= not("1111011");--123
--  when others => min1 <= not("1001111"); --79 (“E”)
--end case;
--case minuto2_cronometro is
--    when 0 => min2 <= not("1111110"); --126
--    when 1 => min2 <= not("0110000"); --48
--    when 2 => min2 <= not("1101101"); --109
--    when 3 => min2 <= not("1111001");  --121
--    when 4 => min2 <= not("0110011"); --51
--    when 5 => min2 <= not("1011011"); --91
--    when 6 => min2 <= not("1011111"); --95
--    when others => min2 <= not("1001111"); --79 (“E”)
--end case;   
--case horas1_cronometro is
--    when 0 => hora1 <= not("1111110"); --126
--    when 1 => hora1 <= not("0110000"); --48
--    when 2 => hora1 <= not("1101101"); --109
--    when 3 => hora1 <= not("1111001");  --121
--    when 4 => hora1 <= not("0110011"); --51
--    when 5 => hora1 <= not("1011011"); --91
--    when 6 => hora1 <= not("1011111"); --95
--    when 7 => hora1 <= not("1110000");--112
--    when 8 => hora1 <= not("1111111"); --127  
--    when 9 => hora1 <= not("1111011");--123
--  when others => hora1 <= not("1001111"); --79 (“E”)
--end case;
--case horas2_cronometro is
--    when 0 => hora2 <= not("1111110"); --126
--    when 1 => hora2 <= not("0110000"); --48
--    when 2 => hora2 <= not("1101101"); --109
--    when others => hora2 <= not("1001111"); --79 (“E”)    
--end case;  
--
--end if; 



            end process;
    
END ARCHITECTURE;