Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.std_logic_1164.all;
- -----------------------------------------
- entity relogio_func is
- port
- (
- -- IN
- clk,clear, B: in std_logic;
- -- OUT
- s: out std_logic_vector (1 downto 0)
- );
- end relogio_func;
- ---------------------------------------
- architecture funcionamento of relogio_func is
- type estado is (hora_atual, alarme, cronometro, data, si0,si1,si2,si3);
- signal estado_atual, proximo_estado: estado;
- begin
- sequencial:
- process (clear, clk) is
- begin
- if(clear = '1') then
- estado_atual <= hora_atual;
- elsif(rising_edge(clk)) then
- estado_atual <= proximo_estado;
- end if;
- end process;
- combinacional:
- process (b,estado_atual) is
- begin
- case estado_atual is
- when hora_atual =>
- s<="00";
- if (b='1') then
- proximo_estado <= hora_atual;
- --s = '00';
- else
- proximo_estado <= si0;
- --s = '00';
- end if;
- when si0 =>
- if (b='1') then
- proximo_estado <= alarme;
- s <= "01";
- else
- proximo_estado <= si0;
- s <= "00";
- end if;
- when alarme =>
- s<="01";
- if (b='1') then
- proximo_estado <= alarme;
- --s='01';
- else
- proximo_estado <=si1;
- --s='01'
- end if;
- when si1 =>
- if (b='1') then
- proximo_estado <= cronometro;
- s<="10";
- else
- proximo_estado <= si1;
- s<="01";
- end if;
- when cronometro =>
- --s<="10";
- if (b='1') then
- proximo_estado <= cronometro;
- s<="10";
- else
- proximo_estado <=si2;
- s<="10";
- end if;
- when si2 =>
- if (b='1') then
- proximo_estado <= data;
- s<="11";
- else
- proximo_estado <= si2;
- s<="10";
- end if;
- when data =>
- if (b='1') then
- proximo_estado <= data;
- s<="11";
- else
- proximo_estado <= si3;
- s<="11";
- end if;
- when si3 =>
- if (b='1') then
- proximo_estado <= hora_atual;
- s<="00";
- else
- proximo_estado <= si3;
- s<="11";
- end if;
- end case;
- end process;
- end funcionamento;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement