Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. entity fsm is
  2. port ( clk, x1, x2, x3: in bit;
  3. y1, y2, y3, y4: out bit );
  4. end entity fsm;
  5.  
  6. architecture bhv of fsm is
  7. type state_type is (s1, s2, s3, s4);
  8. signal state, next_state: state_type := s1;
  9. begin -- bhv
  10. -- Next state and output functions
  11. process (x1, x2, x3, state) begin
  12. case state is
  13. when s1 => if x2='1' then
  14. if x3='0' then
  15. next_state<=s2; y1<='1'; y2<='0'; y3<='1'; y4<='0';
  16. else
  17. next_state<=s3; y1<='1'; y2<='0'; y3<='0'; y4<='1';
  18. end if;
  19. else
  20. if x1='0' then
  21. next_state<=s4; y1<='0'; y2<='1'; y3<='0'; y4<='1';
  22. else
  23. next_state<=s3; y1<='1'; y2<='0'; y3<='0'; y4<='1';
  24. end if;
  25. end if; -- S1 lõpp --
  26.  
  27. when s2 => if x3='0' then
  28. next_state<=s1; y1<='0'; y2<='1'; y3<='1'; y4<='0';
  29. end if;
  30. -- S2 lõpp --
  31.  
  32. when s3 => if x3=x3 then
  33. next_state<=s1; y1<='0'; y2<='1'; y3<='1'; y4<='0';
  34. end if;
  35. -- S3 lõpp ---
  36.  
  37. when s4 => if x1=x1 then
  38. next_state<=s1; y1<='0'; y2<='1'; y3<='1'; y4<='0';
  39. end if;
  40. -- S4 lõpp--
  41. end case;
  42. end process;
  43.  
  44. -- State register
  45. process begin
  46. wait on clk until clk='1';
  47. state<=next_state;
  48. end process;
  49. end architecture bhv;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement