Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_arith.all;
  4.  
  5. entity alarm is port (
  6. clk: IN std_logic;
  7. le : OUT std_logic;
  8. a: IN std_logic_vector(3 downto 0);
  9. b: IN std_logic_vector(3 downto 0);
  10. x: OUT std_logic_vector(1 downto 0));
  11. end alarm;
  12.  
  13. architecture arch_alarm of alarm is
  14. type states is (state0, state1, state2, state3 );
  15. signal stado_pres, stado_fut: states;
  16. begin
  17.  
  18. p_estados: process(stado_pres,a,b) begin
  19. case stado_pres is
  20. when state0 =>
  21. x <= "00";
  22. le <= '0';
  23. if a = NOT(b) then
  24. stado_fut <= state1;
  25. else
  26. stado_fut <= state0;
  27. end if;
  28. when state1 =>
  29. x <= "01";
  30. if a = NOT(b) then
  31. stado_fut <= state2;
  32. else
  33. stado_fut <= state0;
  34. end if;
  35. when state2 =>
  36. x <= "10";
  37. if a = NOT(b) then
  38. stado_fut <= state3;
  39. else
  40. stado_fut <= state0;
  41. end if;
  42. when state3 =>
  43. x <= "11";
  44. if a = NOT(b) then
  45. le <= '1';
  46. end if;
  47. stado_fut <= state0;
  48. end case;
  49. end process p_estados;
  50.  
  51. p_reloj: process(clk) begin
  52. if(clk'event and clk= '1') then
  53. stado_pres <= stado_fut;
  54. end if;
  55. end process p_reloj;
  56. end arch_alarm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement