Advertisement
milica99

Untitled

Dec 13th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity zadatak is
  6. port (
  7. iA : in std_logic_vector (7 downto 0);
  8. iB : in std_logic_vector (2 downto 0);
  9. iSEL : in std_logic_vector (1 downto 0);
  10. oY : out std_logic_vector(3 downto 0);
  11. oZERO: out std_logic
  12. );
  13. end entity;
  14.  
  15. architecture ponasanje of zadatak is
  16. signal sPK : std_logic_vector (2 downto 0);
  17. signal sPK1: std_logic_vector (3 downto 0);
  18. signal sSAB: std_logic_vector (3 downto 0);
  19. signal sPOM: std_logic_vector (3 downto 0);
  20. signal sDEK: std_logic_vector (7 downto 0);
  21. signal sY : std_logic_vector (3 downto 0);
  22.  
  23. begin
  24.  
  25. --prioritetni koder
  26. process (iA,sPK) begin
  27. if (iA(7)='1') then
  28. sPK <= "111";
  29. elsif(iA(6)='1') then
  30. sPK <= "110";
  31. elsif(iA(5)='1') then
  32. sPK <= "101";
  33. elsif(iA(4)='1') then
  34. sPK <= "100";
  35. elsif(iA(3)='1') then
  36. sPK <= "011";
  37. elsif(iA(2)='1') then
  38. sPK <= "010";
  39. elsif(iA(1)='1') then
  40. sPK <= "001";
  41. else sPK <= "000";
  42. end if;
  43. end process;
  44.  
  45. --sabirac
  46. sPK1 <= '0' & sPK;
  47. sSAB <= sPK1 + iB;
  48.  
  49. --pomerac
  50. sPOM <= '0' & '0' & sSAB(3 downto 2);
  51.  
  52. --dekoder
  53. process(iB,sDEK) begin
  54. if (iB(2 downto 0)="000") then
  55. sDEK <= "00000001";
  56. elsif(iB(2 downto 0)="001") then
  57. sDEK <= "00000010";
  58. elsif(iB(2 downto 0)="010") then
  59. sDEK <= "00000100";
  60. elsif(iB(2 downto 0)="011") then
  61. sDEK <= "00001000";
  62. elsif(iB(2 downto 0)="100") then
  63. sDEK <= "00010000";
  64. elsif(iB(2 downto 0)="101") then
  65. sDEK <= "00100000";
  66. elsif(iB(2 downto 0)="110") then
  67. sDEK <= "01000000";
  68. else sDEK <= "10000000";
  69. end if;
  70. end process;
  71.  
  72. --MuX
  73. oY <= sSAB when iSEL <= "00" else
  74. sPOM when iSEL <= "01" else
  75. sDEK(7 downto 4) when iSEL <="10" else
  76. sDEK(3 downto 0);
  77.  
  78. --komparator
  79. sY <= sSAB when iSEL <= "00" else
  80. sPOM when iSEL <= "01" else
  81. sDEK(7 downto 4) when iSEL <="10" else
  82. sDEK(3 downto 0);
  83. process(sY) begin
  84. if(sY <= "0000") then
  85. oZERO <= '1';
  86. else oZERO <= '0';
  87. end if;
  88. end process;
  89.  
  90. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement