Design and implement an ALU supporting N-bit operations such as addition, subtraction, bitwise AND/OR, and shifts.
1. Design ALU components for basic arithmetic and logical operations.
2. Simulate the design using a Simulation Tool.
3. Test ALU for different bit widths (e.g., 4-bit, 8-bit, 16-bit) and various operations.
An N-bit Arithmetic Logic Unit (ALU) is a digital circuit designed to perform a variety of arithmetic and logical operations on N-bit wide data inputs. It takes two N-bit operands, along with control signals, to execute operations such as addition, subtraction, bitwise AND, OR, XOR, and NOT. Additionally, it can handle shift and rotate functions. The ALU generates an N-bit result along with status flags like Carry Out, Zero, Overflow, and Sign to indicate the state of the operation. Multiplexers are employed to select the desired operation based on control signals. The ALU is a fundamental component of a CPU, enabling data processing and decision-making in computing systems.
Working
Two n-bit inputs labeled A and B are provided.
Arithmetic Operations:
ADD: Adds A and B.
SUB: Subtracts B from A.
MUL: Multiplies A and B.
DIV: Divides A by B, producing both a quotient and a remainder.
Logical Operations:
AND: Performs a bitwise AND between A and B.
OR: Performs a bitwise OR between A and B.
NAND: Performs a bitwise NAND between A and B.
NOR: Performs a bitwise NOR between A and B.
Bitwise Shift/Rotation Operations:
SHL (Shift Left): Shifts the bits of A left by one or more positions.
SHR (Shift Right): Shifts the bits of A right by one or more positions.
ROL (Rotate Left): Rotates the bits of A to the left.
ROR (Rotate Right): Rotates the bits of A to the right.
The opcode is a 4-bit value that selects which operation the ALU should perform. Each opcode corresponds to one functional unit
The multiplexer selects the output of one functional unit based on the opcode value.
If the opcode is 0000, the ADD operation result is selected
If the opcode is 0001, the SUB operation result is selected
If the opcode is 0010, the MUL operation result is selected
If the opcode is 0011, the DIV operation result is selected
If the opcode is 0100, the AND operation result is selected
If the opcode is 0101, the OR operation result is selected
If the opcode is 0110, the NAND operation result is selected
If the opcode is 0111, the NOR operation result is selected
If the opcode is 1000, the SHL operation result is selected
If the opcode is 1001, the SHR operation result is selected
If the opcode is 1010, the ROL operation result is selected
If the opcode is 1011, the ROR operation result is selected
The output of the selected operation is displayed.