Advertisement
mdabkow

Lab1Zadanie2Ucyf

Nov 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. ZADANIE A
  2.  
  3. library IEEE;
  4. use IEEE.std_logic_1164.all;
  5. use IEEE.numeric_std.all;
  6.  
  7. entity zA is
  8. port (
  9. a : in std_logic_vector(4 downto 0);
  10. x, y : in std_logic_vector(2 downto 0);
  11. s : in std_logic_vector(1 downto 0);
  12. y0, y2 : out std_logic;
  13. y3 : out std_logic_vector(2 downto 0)
  14. );
  15. end entity;
  16.  
  17. architecture z1 of zA is
  18. begin
  19.  
  20. process(a)
  21. begin
  22. if to_integer(unsigned(a(3 downto 0))) = 1 or
  23. to_integer(unsigned(a(3 downto 0))) = 3 or
  24. to_integer(unsigned(a(3 downto 0))) = 5 or
  25. to_integer(unsigned(a(3 downto 0))) = 12 or
  26. to_integer(unsigned(a(3 downto 0))) = 13 then
  27. y0 <= '1';
  28. else
  29. y0 <= '0';
  30. end if;
  31. end process;
  32.  
  33. process(a)
  34. begin
  35. case to_integer(unsigned(a(2 downto 0))) is
  36. when 0 => y2 <= not a(4);
  37. when 1 => y2 <= '-';
  38. when 2 => y2 <= a(4);
  39. when 3 => y2 <= not a(4);
  40. when 4 => y2 <= not a(4);
  41. when 5 => y2 <= a(3);
  42. when 6 => y2 <= not a(4);
  43. when others => y2 <= a(4);
  44. end case;
  45. end process;
  46.  
  47. y3 <= (not x or y) when (s = "00") else
  48. (x and (not y)) when s = "-1" else
  49. std_logic_vector(unsigned(x) - unsigned(y));
  50.  
  51. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement