Advertisement
Guest User

task 4

a guest
Jan 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.std_logic_1164.all;
  3. use work.fsm_pkg.all;
  4.  
  5. architecture behavior of fsm is
  6.  
  7. signal s_state : fsm_state := START;
  8. signal next_state : fsm_state:=START;
  9. signal next_output : std_logic_vector(1 downto 0):="00";
  10.  
  11. begin
  12.  
  13. fsm_seq : process(CLK,RST)
  14. begin
  15. if(RST = '1' and rising_edge(CLK)) then
  16. s_state <= START;
  17. OUTPUT<= "00";
  18. elsif rising_edge(CLK) then
  19. s_state <=next_state;
  20. OUTPUT <= next_output;
  21. end if;
  22. end process fsm_seq;
  23.  
  24. fsm_comb: process(s_state,INPUT)
  25. begin
  26. case s_state is
  27. when START => if(INPUT="00") then
  28. next_state <=S1;
  29. next_output<= "11";
  30. end if;
  31. STATE <= START;
  32.  
  33. when S1=>if(INPUT="00")then
  34. next_state <=S0;
  35. next_output<= "10";
  36. elsif(INPUT="10")then
  37. next_state<=S2;
  38. next_output<="00";
  39. end if;
  40. STATE <=S1;
  41. when S2=>if(INPUT="10")then
  42. next_state<=S2;
  43. next_output<="00";
  44. elsif(INPUT="00")then
  45. next_state<=S1;
  46. next_output<="01";
  47. end if;
  48. STATE<=S2;
  49. when S0=>if(INPUT="00")then
  50. next_state<=S2;
  51. next_output<="01";
  52. end if;
  53. STATE<=S0;
  54. end case;
  55. end process fsm_comb;
  56.  
  57.  
  58. end behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement