Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all; -- uzycie standardu bibliotek
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity kolokwium1 is -- deklaracja jednostki
  6. port
  7. (
  8. i1, i2, i3, i4: in std_logic;
  9. x: inout std_logic; -- standard logic bierze sie z biblioteki`
  10. reset: in std_logic;
  11. key: in std_logic; -- 'in' deklaracja na wejsciu
  12. ledg: out std_logic; -- 'out' deklaracja na wyjsciu
  13. ledr: out std_logic_vector(2 downto 0) --w ostatnej deklaracji nie ma srednika
  14.  
  15. ); -- to ostatni srednik
  16. end entity;
  17.  
  18.  
  19. architecture dzialani_od_kolokwium of kolokwium1 is --czesc deklaracji : np. typow, sygnalow, stalych, podprogramy, komponenty
  20. type State_type is (A,B,C);
  21. signal ST: State_type;
  22.  
  23.  
  24. begin -- tutaj definicja dzialania modulu, czesc opisowa : np petle i warunki
  25.  
  26. x <= (i1 and (not i2) and i4) or (i2 and i1 (not i3 )) or (not i4);
  27. process (reset, key, x)
  28. begin
  29. if (reset='1') then
  30. ST <= A; --<=wektor
  31. elsif ( key'event and key='1') then
  32. case ST is
  33. when A =>
  34. ledr (2 downto 0) <= "001";
  35. if (x= '1' ) then
  36. ST <= C;
  37. ledg<='1';
  38. else
  39. ST <= B;
  40. ledg <='0';
  41. end if;
  42. when B =>
  43. ledr (2 downto 0) <= "010";
  44. if (x='1') then
  45. ST <= A;
  46. ledg<='1';
  47. else
  48. ST <= C;
  49. ledg <='0';
  50. end if;
  51. when C =>
  52. ledr (2 downto 0) <= "010";
  53. if (x='1') then
  54. ST <= A;
  55. ledg<='1';
  56. else
  57. ST <= B;
  58. ledg <= '0';
  59. end if;
  60. end case;
  61. end if;
  62. end process;
  63. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement