library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ALU4 is
Port ( A : in std_logic_vector(3 downto 0);
B : in std_logic_vector(3 downto 0);
S0 : in std_logic ;
S1 : in std_logic ;
S2: in std_logic ;
G : out std_logic_vector(3 downto 0));
end ALU4;
architecture Behavioral of ALU4 is
begin
process(A, B, S0, S1, S2)
begin
if S2='0' and S1='0' and S0='1' then
G <= A + B;
elsif S2='0' and S1='1' and S0='0' then
G <= A - B;
else
G <= not A;
end if;
end process;
end Behavioral;