2 BIT ALU
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity alllllll is
Port ( a : in STD_LOGIC_VECTOR (1 downto 0);
b : in STD_LOGIC_VECTOR (1 downto 0);
sel : in STD_LOGIC_VECTOR (1 downto 0);
res : out STD_LOGIC_VECTOR (1 downto 0));
end alllllll;
architecture Behavioral of alllllll is
begin
process(a,b,sel)
begin
case sel is
when"00"=>
res<=a+b;
when"01"=>
res<=a-b;
when"10"=>
res<=a nand b;
when "11"=>
res<=a nor b;
when others=>
res<="XX";
end case;
end process;
end Behavioral;
SIMULATION
BLOCK DIAGRAM
LOGIC DIAGRAM