VHDL Problem: Question: Create a Quartus project which contains a file: - ALU.vh
ID: 2248197 • Letter: V
Question
VHDL Problem:
Question:
Create a Quartus project which contains a file:
- ALU.vhd: The VHDL description of the 32-bit ALU described above. Simulate your design and make sure it generates the correct output
Explanation / Answer
library ieee;
use ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ALU is
port (
A,B:in std_logic_vector (31 downto 0);
F:in std_logic_vector (1 downto 0);
ENA: in std_logic;
INVA: in std_logic;
ENB: in std_logic;
CLK: in std_logic;
RESULT: out std_logic_vector (31 downto 0);
ZERO: out std_logic;
NEG: out std_logic
);
end ALU;
architecture beh of ALU is
signal A_inv : std_logic_vector(31 downto 0);
signal A_e,B_e : std_logic_vector (31 downto 0);
signal RES: std_logic_vector (31 downto 0);
begin
process (A,B,ENA,INVA,ENB,CLK)
begin
if (CLK'event and CLK='1') then
if (ENA='1') then
A_e<=A;
elsif (INVA='1') then
A_e<=not A_e;
end if;
if (ENB='1') then
B_e<=B;
else
B_e<=(others=>'0');
end if;
case F is
when "00" => RES<= A_e and B_e;
when "01" => RES <= not B_e;
when "10" => RES <= A_e or B_e;
when others => RES <= A_e + B_e;
end case;
if (RES="00000000000000000000000000000000") then
ZERO<='1';
else
ZERO<='0';
end if;
if (RES(31)='1') then
NEG<='1';
else
NEG<='0';
end if;
end if;
RESULT<=RES;
end process;
end beh;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.