Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.22 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity motorstart is
  5. port (clock, a, b: in  std_logic;
  6.         reset : in std_logic;
  7.       u0, ut : out std_logic);
  8. end motorstart;
  9.  
  10. architecture beh of motorstart is
  11. signal pre_state : std_logic_vector(2 downto 0) := "000";
  12. signal next_state: std_logic_vector(2 downto 0);
  13.  
  14. begin
  15.  
  16. process(pre_state)
  17. begin
  18.  
  19. case pre_state is
  20. when "000" => next_state <= "001";
  21. when "001" => next_state <= "010";
  22. when "010" => next_state <= "011";
  23. when "011" => next_state <= "100";
  24.  
  25. when others => next_state <= "000";
  26.  
  27. end case;
  28. end process;
  29.  
  30. process(a, b, pre_state, reset)
  31. begin
  32.     if pre_state = "000" and a = '1' and b = '0' then
  33.       pre_state <= next_state;
  34.     elsif pre_state /= "000" and pre_state /= "100" and b = '1' and a = '0' then
  35.       pre_state <= next_state;
  36.     elsif a = '0' and b = '0' then
  37.         -- om både a och b är 0 har ingen knapptryking skett.
  38.     else
  39.         pre_state <= "100";
  40.         u0 <= '1';
  41.            
  42.     end if;
  43.  
  44.     if reset = '1' then
  45.       pre_state <= "000";
  46.       ut <= '0';
  47.       u0 <= '0';
  48.     end if;
  49.    
  50.     if pre_state = "011" then
  51.         ut <= '1';
  52.     end if;
  53. end process;
  54.  
  55. --process(pre_state)
  56. --begin
  57. --if pre_state = "011" then
  58. --  ut <= '1';
  59. --end if;
  60. --end process;
  61. end beh;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement