Files
Bluetooth_VHDL/ULA_P379.vhd
2023-04-26 11:57:02 -03:00

45 lines
1.1 KiB
VHDL

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ULA_P379 is
Port ( ULA1 : in STD_LOGIC_VECTOR (3 downto 0);
ULA2 : in STD_LOGIC_VECTOR (3 downto 0);
OE : in STD_LOGIC;
OPCODE: in STD_LOGIC_VECTOR (3 downto 0);
CARRY : out STD_LOGIC;
OUTPUT : out STD_LOGIC_VECTOR (3 downto 0));
end ULA_P379;
architecture Behavioral of ULA_P379 is
signal OUTPUT_ALL: std_logic_vector (3 downto 0);
begin
process(OPCODE)
begin
case OPCODE is
when "0000" => output_all <= ULA1 + ULA2;
when "0001" => output_all <= ULA1 - ULA2;
when "0010" => output_all <= ULA1 and ULA2;
when "0011" => output_all <= ULA1 nand ULA2;
when "0100" => output_all <= ULA1 or ULA2;
when "0101" => output_all <= ULA1 xor ULA2;
when "0111" => output_all <= not ULA1;
when others => output_all <= "ZZZZ";
end case;
end process;
process(OE)
begin
case OE is
when '1' => OUTPUT <= output_all;
when others => OUTPUT <= "ZZZZ";
end case;
end process;
end Behavioral;