32-bit ALU in VHDL
In this post the design of a 32-bit ALU will be presented.
The ALU has 2 data inputs A & B, 1 carry input and ALU control input. accroding to the ALU control the ALU can perform a set of arithmetic and logic operations, the following table shows the arithmetic and logic operations performed according to the ALU control input
The Zero flag output is equal to one only when the result is zero.
add overflow output is equal to one when both inputs are positive and the result is negative or when both inputs are negative and the output is positive.
subtraction overflow takes place when A is positive and the result is negative, or when A is negative and the result is positive.
Carry out is the carry of the adder when the function is addition, otherwise it is the carry of the subtraction.
VHDL Code for the 32-bit ALU :
The test bench for the ALU :
Simulation results :