Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.28 KB | None | 0 0
  1. entity DomaciZadatak2 is
  2.     Port ( iSEL : in  STD_LOGIC;
  3.            iSW : in  STD_LOGIC_VECTOR (7 downto 0);
  4.            oLED : out  STD_LOGIC_VECTOR (7 downto 0));
  5. end DomaciZadatak2;
  6.  
  7. architecture Behavioral of DomaciZadatak2 is
  8.  
  9. begin
  10.     process (iSEL,iSW) begin
  11.         case(iSEL) is
  12.             when '0' =>
  13.                 oLED <= not(iSW);
  14.             when '1' =>
  15.                 oLED(3 downto 0) <= iSW(7 downto 4) - iSW(3 downto 0);
  16.                 if( iSW(7 downto 4) > iSW(3 downto 0)) then
  17.                     oLED(4) <= '0';
  18.                 else
  19.                     oLED(4) <= '1';
  20.                 end if;
  21. --              dis dont work
  22. --              not(iSW + "1") and
  23. --              oLED(7 downto 5) <= ((not(iSW) + "1")and iSW);
  24.  
  25.                
  26.                 case ((not(iSW) + "1") and iSW) is
  27.                     when "10000000"
  28.                     => oLED(7 downto 5) <= "111";
  29.                     when "01000000"
  30.                     => oLED(7 downto 5) <= "110";
  31.                     when "00100000"
  32.                     => oLED(7 downto 5) <= "101";
  33.                     when "00010000"
  34.                     => oLED(7 downto 5) <= "100";
  35.                     when "00001000"
  36.                     => oLED(7 downto 5) <= "011";
  37.                     when "00000100"
  38.                     => oLED(7 downto 5) <= "010";
  39.                     when "00000010"
  40.                     => oLED(7 downto 5) <= "001";
  41.                     when "00000001"
  42.                     => oLED(7 downto 5) <= "000";
  43.                     when others => oLED <= (others => '0');
  44.                 end case;
  45.        
  46.                
  47.             when others => oLED <= (others => '1');
  48.         end case;
  49.  
  50.     end process;
  51.  
  52. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement