Advertisement
Guest User

Untitled

a guest
May 5th, 2017
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3.  
  4. entity fsm3 is
  5. port(clock, w, reset : in std_logic;
  6. z : out std_logic;
  7. state : out std_logic_vector(8 downto 0)); --input output ports
  8.  
  9. end fsm;
  10.  
  11. architecture behavior of fsm is
  12.  
  13. type State_type is (A,B,C,D,E,F,G,H,I);
  14. signal y_Q, Y_D : State_type;
  15.  
  16. begin
  17. process(w, y_Q)--state table
  18. begin
  19. case y_Q is
  20. when A
  21. state<="000000001";
  22. z<= '0';
  23. if(w = '0') then
  24. y_Q <=B;--if we get a 0, go to B
  25. else
  26. y_Q <=F;--if we get a 1 go to F
  27. end if;
  28.  
  29. when B
  30. state<="000000010";
  31. z<= '0';
  32. if(w = '0') then
  33. y_Q <=C;
  34. else
  35. y_Q <=F;
  36. end if;
  37.  
  38. when C
  39. state<="000000100";
  40. z<= '0';
  41. if(w = '0') then
  42. y_Q <=D;
  43. else
  44. y_Q <=F;
  45. end if;
  46.  
  47. when D
  48. state<="000001000";
  49. z<= '0';
  50. if(w = '0') then
  51. y_Q <=E;
  52. else
  53. y_Q <=F;
  54. end if;
  55.  
  56. when E
  57. state<="000010000";
  58. z<='1';
  59. if(w = '0') then
  60. y_Q <=E;
  61. else
  62. y_Q <=F;
  63. end if;
  64.  
  65. when F
  66. state<="000100000";
  67. z<='0';
  68. if(w = '1') then
  69. y_Q <=G;--if we get a 1, go to G
  70. else
  71. y_Q <=B;--if we get a 0, go to B
  72. end if;
  73.  
  74. when G
  75. state<="001000000";
  76. z<='0';
  77. if(w = '1') then
  78. y_Q <=H;
  79. else
  80. y_Q <=B;
  81. end if;
  82.  
  83. when H
  84. state<="010000000";
  85. z<='0';
  86. if(w = '1') then
  87. y_Q <=I;
  88. else
  89. y_Q <=B;
  90. end if;
  91.  
  92. when I
  93. state<="100000000";
  94. z<='1';
  95. if(w = '1') then
  96. y_Q <=I;
  97. else
  98. y_Q <=B;
  99. end if;
  100.  
  101. end case;
  102. end process;--state table
  103.  
  104. process(clock)
  105. begin
  106. if(clock'event and clock = '1') then
  107.  
  108. end process;
  109.  
  110. --assignments for output z and LEDs
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. end behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement