Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5.  
  6. entity najslozeniji is
  7. port (
  8. iA : in std_logic_vector (7 downto 0);
  9. iB : in std_logic_vector (2 downto 0);
  10. iSEL : in std_logic_vector (1 downto 0);
  11.  
  12. oY : out std_logic_vector(3 downto 0);
  13. oZERO : out std_logic
  14.  
  15. );
  16.  
  17. end entity;
  18.  
  19. architecture Behavioral of najslozeniji is
  20. signal sPRIO_KODER_IZLAZ : std_logic_vector (2 downto 0);
  21. signal sPRIO_KODER_PLUS_IB : std_logic_vector (3 downto 0);
  22. signal sPRIO_KODER_PLUS_IB_SHIFT2 : std_logic_vector (3 downto 0);
  23. signal sDEKODER : std_logic_vector (7 downto 0);
  24. signal sOUT : std_logic_vector(3 downto 0);
  25.  
  26. begin
  27.  
  28. process (iA) begin -- PRIORITETNI KODER
  29. if (iA(7) = '1') then
  30. sPRIO_KODER_IZLAZ <= "111";
  31. elsif (iA(7 downto 6) = "01") then
  32. sPRIO_KODER_IZLAZ <= "110";
  33. elsif (iA(7 downto 5) = "001") then
  34. sPRIO_KODER_IZLAZ <= "101";
  35. elsif (iA(7 downto 4) = "0001") then
  36. sPRIO_KODER_IZLAZ <= "100";
  37. elsif (iA(7 downto 3) = "00001") then
  38. sPRIO_KODER_IZLAZ <= "011";
  39. elsif (iA(7 downto 2) = "000001") then
  40. sPRIO_KODER_IZLAZ <= "010";
  41. elsif (iA(7 downto 1) = "0000001") then
  42. sPRIO_KODER_IZLAZ <= "001";
  43. else
  44. sPRIO_KODER_IZLAZ <= "000";
  45.  
  46. end if;
  47.  
  48. end process;
  49.  
  50. sPRIO_KODER_PLUS_IB <= ('0' & iB) + ('0' & sPRIO_KODER_IZLAZ); --sabiranje dva signala
  51.  
  52. sPRIO_KODER_PLUS_IB_SHIFT2 <= "00" & sPRIO_KODER_PLUS_IB(3 downto 2); --shift 2 mesta u desno
  53.  
  54. sDEKODER <= "00000001" when iB = "000" else
  55. "00000010" when iB = "001" else
  56. "00000100" when iB = "010" else
  57. "00001000" when iB = "011" else
  58. "00010000" when iB = "100" else
  59. "00100000" when iB = "101" else
  60. "01000000" when iB = "110" else
  61. "10000000" when iB = "111";
  62.  
  63.  
  64. process (iSEL) begin
  65. if(iSEL = "00") then
  66. sOUT <= sPRIO_KODER_PLUS_IB;
  67. elsif(iSEL = "01") then
  68. sOUT <= sPRIO_KODER_PLUS_IB_SHIFT2;
  69. elsif(iSEL = "10") then
  70. sOUT <= sDEKODER(7 downto 4);
  71. else
  72. sOUT <= sDEKODER(3 downto 0);
  73. end if;
  74.  
  75. end process;
  76.  
  77. oY <= sOUT;
  78.  
  79. oZERO <= '1' when sOUT = "0000" else '0';
  80.  
  81.  
  82. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement