Advertisement
Guest User

Untitled

a guest
May 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. entity lab9 is
  2. Port(clk_wejscie : in STD_LOGIC;
  3. kierunek : in STD_LOGIC;
  4. y0 : out STD_LOGIC;
  5. y1 : out STD_LOGIC;
  6. y2 : out STD_LOGIC;
  7. y3 : out STD_LOGIC);
  8. end lab9;
  9.  
  10. architecture Behavioral of lab9 is
  11.  
  12. type stany is(s0,s1,s2,s3);
  13. signal aktualny_stan, nastepny_stan: stany;
  14. signal wyjscie:std_logic_vector(0 to 3);
  15. signal licznik: integer range 0 to 4999999:=0;
  16. signal tym: std_logic:='0';
  17. signal clk_wyjscie: std_logic;
  18.  
  19. begin
  20. process(aktualny_stan,kierunek)
  21. begin
  22.  
  23. case aktualny_stan is
  24. when s0 =>
  25. wyjscie <= "0111";
  26. if(kierunek='0') then
  27. nastepny_stan<=s1;
  28. else
  29. nastepny_stan<=s3;
  30. end if;
  31. when s1 =>
  32. wyjscie <= "1011";
  33. if(kierunek='0') then
  34. nastepny_stan<=s2;
  35. else
  36. nastepny_stan<=s0;
  37. end if;
  38. when s2 =>
  39. wyjscie <= "1101";
  40. if(kierunek='0') then
  41. nastepny_stan<=s3;
  42. else
  43. nastepny_stan<=s1;
  44. end if;
  45. when s3 =>
  46. wyjscie <= "1110";
  47. if(kierunek='0') then
  48. nastepny_stan<=s0;
  49. else
  50. nastepny_stan<=s2;
  51. end if;
  52. end case;
  53. end process;
  54.  
  55. process(clk_wejscie)
  56. begin
  57. if(rising_edge(clk_wejscie))then
  58. if(licznik=499999) then
  59. tym<=not tym;
  60. licznik<=0;
  61. else
  62. licznik<=licznik+1;
  63. end if;
  64. end if;
  65. end process;
  66. clk_wyjscie<=tym;
  67.  
  68. process(clk_wyjscie)
  69. begin
  70. if(rising_edge(clk_wyjscie))then
  71. aktualny_stan<=nastepny_stan;
  72. end if;
  73. end process;
  74.  
  75. y0<=wyjscie(0);
  76.  
  77. y1<=wyjscie(1);
  78.  
  79. y2<=wyjscie(2);
  80.  
  81. y3<=wyjscie(3);
  82.  
  83. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement