Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1.  
  2. library IEEE;
  3. use IEEE.std_logic_1164.all;
  4. use IEEE.std_logic_unsigned.all;
  5.  
  6. entity moore is
  7. port(
  8. Entrada, CLK, RST: IN BIT;
  9. F: OUT BIT
  10. );
  11. end moore;
  12.  
  13. architecture fsm of moore is
  14. subtype state_type is std_logic_vector (2 downto 0);
  15. signal state: state_type;
  16. constant A: state_type:="000";
  17. constant B: state_type:="001";
  18. constant C: state_type:="011";
  19. constant D: state_type:="010";
  20. constant E: state_type:="110";
  21. signal current_state, next_state: state_type;
  22.  
  23. begin
  24. ff: process (CLK, RST)
  25. begin
  26. if(RST='1') then
  27. current_state <= A;
  28. elsif (CLK'EVENT and CLK='1') then
  29. current_state <= next_state;
  30. end if;
  31. end process ff;
  32.  
  33. logic: process(Entrada, current_state)
  34. begin
  35. case current_state is
  36. when A =>
  37. if(Entrada='0') then
  38. next_state <= A;
  39. else
  40. next_state <= B;
  41. end if;
  42. when B =>
  43. if(Entrada='0') then
  44. next_state <= B;
  45. else
  46. next_state <= C;
  47. end if;
  48. when C =>
  49. if(Entrada='0') then
  50. next_state <= D;
  51. else
  52. next_state <= C;
  53. end if;
  54. when D =>
  55. if(Entrada='0') then
  56. next_state <= E;
  57. else
  58. next_state <= C;
  59. end if;
  60. when E =>
  61. if(Entrada='0') then
  62. next_state <= B;
  63. else
  64. next_state <= C;
  65. end if;
  66. when others =>
  67. next_state <= A;
  68. end case;
  69. end process;
  70. F <= '1' when current_state = E else '0';
  71. end fsm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement