Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity part2 is
  5. port(w: in std_logic;
  6. z: out std_logic);
  7.  
  8. end part2;
  9.  
  10. architecture behavior of part2 is
  11. type state_type is(A,B,C,D,E,F,G,H,I);
  12. signal y_Q,Y_D : state_type; -- y_Q present state, Y_D next state
  13. begin
  14. process (w,y_Q) -- State table
  15. begin
  16. z <= 0;
  17. case y_Q is
  18. when A =>
  19. if (w = '0') then
  20. Y_D <= B;
  21. else
  22. Y_D <= F;
  23. end if;
  24. when B =>
  25. if (w = '0') then
  26. Y_D <= C;
  27. else
  28. Y_D <= F;
  29. end if;
  30. when C =>
  31. if (w = '0') then
  32. Y_D <= D;
  33. else
  34. Y_D <= F;
  35. end if;
  36. when D =>
  37. if (w = '0') then
  38. Y_D <= E;
  39. else
  40. Y_D <= F;
  41. end if;
  42. when E =>
  43. z <= 1;
  44. if (w = '0') then
  45. Y_D <= E;
  46. else
  47. Y_D <= F;
  48. end if;
  49. when F =>
  50. if (w = '0') then
  51. Y_D <= B;
  52. else
  53. Y_D <= G;
  54. end if;
  55. when G =>
  56. if (w = '0') then
  57. Y_D <= B;
  58. else
  59. Y_D <= G;
  60. end if;
  61. when H =>
  62. if (w = '0') then
  63. Y_D <= B;
  64. else
  65. Y_D <= I;
  66. end if;
  67. when I =>
  68. z <= 1;
  69. if (w = '0') then
  70. Y_D <= B;
  71. else
  72. Y_D <= I;
  73. end if;
  74. end case;
  75. end process;
  76.  
  77. process(clock) -- State flip flops
  78. begin
  79. if rising_edge(clock) then
  80. y_Q <= Y_D;
  81. end if;
  82. end process;
  83.  
  84. end architecture behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement