-- ALU Control Unit
-- Expected Behavior: The last 6 bits of each instruction along with
-- a 2 bit opcode that is produced by the Main Control Unit. Together,
-- they determine the type of operation and the appropriate op codes are
-- sent to the ALU. Possible instructions that use the ALU: XOR, NOR, ADD,
-- SUB, LW, SW, BEQ, and SLT.
library IEEE;
use IEEE.std_logic_1164.all;
entity alucontrol is -- New entity for ALU Control Unit
port(inv : in std_logic_vector(5 downto 0); -- is defined
ALUop : in std_logic_vector(1 downto 0);
outv : out std_logic_vector(2 downto 0));
end alucontrol;
architecture behavior of alucontrol is
signal ALUop0not,ALUop1not,inv2not,s0,s1,s2,s3,s4: std_logic;
begin
ALUop0not <= NOT ALUop(0) after 1 ns;
ALUop1not <= NOT ALUop(1) after 1 ns;
inv2not <= NOT inv(2) after 1 ns;
s0 <= inv(1) NAND ALUop(1) after 2 ns; -- Calculation for MSB
s1 <= ALUop(1) NAND inv2not after 2 ns;
s2 <= s1 NOR s0 after 2 ns;
s3 <= s2 NOR ALUop(0) after 2 ns;
outv(2) <= NOT s3 after 1 ns;
outv(1) <= inv(2) NAND ALUop(1) after 2 ns; -- Calculation for Middle Bit
s4 <= inv(3) NOR inv(0) after 2 ns; -- Calculation for LSB
outv(0) <= s4 NOR ALUop1not after 2 ns;
end behavior;