Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 11/19/2019 12:33:53 PM
  6. -- Design Name:
  7. -- Module Name: last - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx leaf cells in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity last is
  35. Port (x,rst,clk:in std_logic ;
  36. y:out std_logic);
  37. end last;
  38.  
  39. architecture Behavioral of last is
  40. type fast is (S0,S1,S2,S3,S4,S5,S6);
  41. signal pr_state,nt_state : fast;
  42. begin
  43. process (rst,clk)
  44. begin
  45. if(rst='1') then pr_state<=S0;
  46. elsif(rising_edge(clk))then
  47. pr_state<=nt_state;
  48. end if;
  49. end process;
  50. process (pr_state,x)
  51. begin
  52. case pr_state is
  53. when S0=> if(x='0')then
  54. nt_state<=S1;
  55. y<='1';
  56. else
  57. nt_state<=S2;
  58. y<='0';
  59. end if;
  60. when S1=> if(x='0')then
  61. nt_state<=S3;
  62. y<='1';
  63. else
  64. nt_state<=S4;
  65. y<='0';
  66. end if;
  67. when S2=> if(x='0')then
  68. nt_state<=S4;
  69. y<='0';
  70. else
  71. nt_state<=S4;
  72. y<='1';
  73. end if;
  74. when S3=>if(x='0')then
  75. nt_state<=S5;
  76. y<='0';
  77. else
  78. nt_state<=S5;
  79. y<='1';
  80. end if;
  81. when S4=>if(x='0')then
  82. nt_state<=S5;
  83. y<='1';
  84. else
  85. nt_state<=S6;
  86. y<='0';
  87. end if;
  88. when S5=>if(x='0')then
  89. nt_state<=S0;
  90. y<='0';
  91. else
  92. nt_state<=S0;
  93. y<='1';
  94. end if;
  95. when S6=>if(x='0')then
  96. nt_state<=S0;
  97. y<='1';
  98. end if;
  99. end case;
  100. end process;
  101. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement