Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me to code in VHDL only that I marked by red (ALU and ALU control) ,

ID: 3348810 • Letter: P

Question

Please help me to code in VHDL only that I marked by red (ALU and ALU control) , only this need to code in VHDL, I must only use the one VHDL standard library other libraries is not allowed. Please include the comments in the code for understanding. Thank you.

MI Add 4 Add ALU Shift eft 2 RegDst Branch MemRead MemtoRe Instruction [31-26) Control AL MemWr ReqWrite Instruction [25-2 Read register 1 Read Read data 1 register 2 Instruction [20-16]ead Zero ALU ALU result Instruction [31-0 InstructionInstruction[15-11] regist Read Address data MI uWrite Read MI Write data Registers Write Data data memo Sign32 extend Instruction [15-0] 16 ALU Instruction [5-0]

Explanation / Answer

VHDL code for 32-bit ALU:

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

----==== Entity of AlU with input and Output

entity AlU is Port (

A : in STD_LOGIC_VECTOR (31 downto 0); ---== A input Vector with 32 Bit

B : in STD_LOGIC_VECTOR (31 downto 0); ---== B input Vector with 32 Bit

S : in STD_LOGIC_VECTOR (2 downto 0) ; ---== S select Input Vector 3 bit for operation  

out_AlU : in STD_LOGIC_VECTOR (31 downto 0));---== Output of AlU 32

end AlU;

architecture Behavioral of AlU is

begin

Select_for_operation: Process (S) ---= Deffierent Process for AlU with the selection of S

begin

Case S is  

when "000" =>  

out_AlU <=A xor B ;

when "001"=>

out_AlU <=A Xnor B ;

when "100"=>

out_AlU <=A or B ;

when "101"=>

out_AlU <=A nor B ;

when "110"=>

out_AlU <=A and B ;

when others =>

NULL ;   

end case ;

end Process ;

end Behavioral;

VHDL code for ALU control:

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

entity ALU_Control_VHDL is

port(

ALU_Control: out std_logic_vector(2 downto 0);

ALUOp : in std_logic_vector(1 downto 0);

ALU_Funct : in std_logic_vector(2 downto 0)

);

end ALU_Control_VHDL;

architecture Behavioral of ALU_Control_VHDL is

begin

process(ALUOp,ALU_Funct)

begin

case ALUOp is

when "00" =>

ALU_Control <= ALU_Funct(2 downto 0);

when "01" =>

ALU_Control <= "001";

when "10" =>

ALU_Control <= "100";

when "11" =>

ALU_Control <= "000";

when others => ALU_Control <= "000";

end case;

end process;

end Behavioral;