Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.std_logic_1164.all;
- entity unidade_controle is
- port (CLOCK, INICIAR, RESET: in STD_LOGIC;
- ZERA, CONTA, CARREGA: out STD_LOGIC;
- Sreg_Debug: out STD_LOGIC_VECTOR(1 downto 0)
- );
- end;
- architecture unidade_controle_arq of unidade_controle is
- type State_type is (INICIAL, CONTAGEM, RESULTADO);
- signal Sreg, Snext: State_type; -- proximo estado e estado atual
- begin
- process (CLOCK) -- memoria de estado
- begin
- if CLOCK'event and CLOCK = '1' then
- Sreg <= Snext;
- end if;
- end process;
- process (INICIAR, RESET, Sreg) -- logica de proximo estado
- begin
- case Sreg is
- when INICIAL => if INICIAR = '1' and RESET = '0' then Snext <= CONTAGEM;
- else
- Snext <= INICIAL;
- end if;
- when CONTAGEM => if INICIAR = '0' and RESET = '0' then Snext <= RESULTADO;
- elsif INICIAR = '1' and RESET = '0' then Snext <= CONTAGEM;
- else
- Snext <= INICIAL;
- end if;
- when RESULTADO =>
- Snext <= INICIAL;
- when others =>
- Snext <= INICIAL;
- end case;
- end process;
- process (Sreg) -- logica de saida
- begin
- case Sreg is
- when INICIAL => ZERA <= '1';
- CONTA <= '0';
- CARREGA <= '0';
- when CONTAGEM => CONTA <= '1';
- ZERA <= '0';
- CARREGA <= '0';
- when RESULTADO => CARREGA <= '1';
- ZERA <= '0';
- CONTA <= '0';
- end case;
- end process;
- process (Sreg) -- depuracao
- begin
- case Sreg is
- when INICIAL => Sreg_Debug <= "00";
- when CONTAGEM => Sreg_Debug <= "01";
- when RESULTADO => Sreg_Debug <= "10";
- end case;
- end process;
- end unidade_controle_arq;
Advertisement
Add Comment
Please, Sign In to add comment