Guest User

Untitled

a guest
Apr 13th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. library IEEE;
  2.  
  3. use IEEE.std_logic_1164.all;
  4.  
  5. entity unidade_controle is
  6. port (CLOCK, INICIAR, RESET: in STD_LOGIC;
  7. ZERA, CONTA, CARREGA: out STD_LOGIC;
  8. Sreg_Debug: out STD_LOGIC_VECTOR(1 downto 0)
  9. );
  10. end;
  11.  
  12. architecture unidade_controle_arq of unidade_controle is
  13. type State_type is (INICIAL, CONTAGEM, RESULTADO);
  14. signal Sreg, Snext: State_type; -- proximo estado e estado atual
  15.  
  16. begin
  17. process (CLOCK) -- memoria de estado
  18. begin
  19. if CLOCK'event and CLOCK = '1' then
  20. Sreg <= Snext;
  21. end if;
  22. end process;
  23.  
  24. process (INICIAR, RESET, Sreg) -- logica de proximo estado
  25. begin
  26. case Sreg is
  27. when INICIAL => if INICIAR = '1' and RESET = '0' then Snext <= CONTAGEM;
  28. else
  29. Snext <= INICIAL;
  30. end if;
  31.  
  32. when CONTAGEM => if INICIAR = '0' and RESET = '0' then Snext <= RESULTADO;
  33. elsif INICIAR = '1' and RESET = '0' then Snext <= CONTAGEM;
  34. else
  35. Snext <= INICIAL;
  36. end if;
  37. when RESULTADO =>
  38. Snext <= INICIAL;
  39.  
  40. when others =>
  41. Snext <= INICIAL;
  42. end case;
  43. end process;
  44.  
  45. process (Sreg) -- logica de saida
  46. begin
  47. case Sreg is
  48. when INICIAL => ZERA <= '1';
  49. CONTA <= '0';
  50. CARREGA <= '0';
  51. when CONTAGEM => CONTA <= '1';
  52. ZERA <= '0';
  53. CARREGA <= '0';
  54. when RESULTADO => CARREGA <= '1';
  55. ZERA <= '0';
  56. CONTA <= '0';
  57. end case;
  58. end process;
  59.  
  60. process (Sreg) -- depuracao
  61. begin
  62. case Sreg is
  63. when INICIAL => Sreg_Debug <= "00";
  64.  
  65. when CONTAGEM => Sreg_Debug <= "01";
  66.  
  67. when RESULTADO => Sreg_Debug <= "10";
  68. end case;
  69. end process;
  70. end unidade_controle_arq;
Advertisement
Add Comment
Please, Sign In to add comment