Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 11:38:35 11/15/2018
  6. -- Design Name:
  7. -- Module Name: domaci2 - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.NUMERIC_STD.ALL;
  23.  
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. --use IEEE.NUMERIC_STD.ALL;
  27.  
  28. -- Uncomment the following library declaration if instantiating
  29. -- any Xilinx primitives in this code.
  30. --library UNISIM;
  31. --use UNISIM.VComponents.all;
  32.  
  33. entity domaci2 is
  34. Port ( iSW : in STD_LOGIC_VECTOR (7 downto 0);
  35. iSEL : in STD_LOGIC;
  36. oLED : out STD_LOGIC_VECTOR (7 downto 0));
  37. end domaci2;
  38.  
  39. architecture Behavioral of domaci2 is
  40. signal sInv : STD_LOGIC_VECTOR (7 downto 0);
  41. signal sSub : STD_LOGIC_VECTOR (3 downto 0);
  42. signal sComp : STD_LOGIC;
  43. signal sCoder : STD_LOGIC_VECTOR (2 downto 0);
  44. signal sFinal : STD_LOGIC_VECTOR (7 downto 0);
  45. begin
  46. sSub(3 downto 0) <= std_logic_vector(unsigned(iSW(7 downto 4)) - unsigned(iSW(3 downto 0)));
  47.  
  48. sComp <= '0' when iSW(7 downto 4) > iSW(3 downto 0) else
  49. '1';
  50. sCoder <= "000" when iSW(0) = '1' else
  51. "001" when iSW(1) = '1' else
  52. "010" when iSW(2) = '1' else
  53. "011" when iSW(3) = '1' else
  54. "100" when iSW(4) = '1' else
  55. "101" when iSW(5) = '1' else
  56. "110" when iSW(6) = '1' else
  57. "111";
  58. sFinal <= sCoder & sComp & sSub when iSEL = '1' else
  59. not(iSW(7 downto 0));
  60. oLED(7) <= sFinal(7);
  61. oLED(6) <= sFinal(6);
  62. oLED(5) <= sFinal(5);
  63. oLED(4) <= sFinal(4);
  64. oLED(3) <= sFinal(3);
  65. oLED(2) <= sFinal(2);
  66. oLED(1) <= sFinal(1);
  67. oLED(0) <= sFinal(0);
  68.  
  69. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement