Description:
Design and implement an ALU supporting N-bit operations such as addition, subtraction, bitwise AND/OR, and shifts
ALU:
The Arithmetic Logic Unit (ALU) is a very basic digital circuit of a computer processor that executes arithmetic and logical operations on data. This unit performs important tasks such as arithmetic calculations and bitwise operations on binary integers.
The ALU works on the data it is given, which it refers to as operands, and combines these with an operation code (opcode) to tell the ALU what to do. This combination enables the ALU to perform a very broad set of computational tasks, thereby becoming an essential building block of modern processors.
N-bit ALU:
An N-bit ALU means an Arithmetic Logic Unit able to handle 'N' number of bits for operand size. These include some common examples as 4-bit, 8-bit, 16-bit, and 32-bit ALUs, which operate data on their respective bit-width efficiently. This variety fulfills the requirements for different computational problems; with larger bit widths, they can carry more complex operations and provide high precision.
8 bit ALU:
The designed ALU is an 8-bit one, meaning that it can work with an 8-bit operand, and it supports logical operations such as AND, OR, NOT, XOR, NAND, and NOR. Additionally, the ALU will have functional units dedicated to executing arithmetic operations such as addition, subtraction, multiplication, and division. Lastly, the ALU is designed to execute shift and rotate instructions, which include left shifting, right shifting, left rotating, and right rotating.
Hex displays and tunnels are added to the user interface to enhance the clean, intuitive, and seamless experience while providing clear insights into the functionality of the ALU.
ALU Design Overview:
1. Input:
Two N-bit inputs, labeled A and B, are available for operations.
2. Functional Unit:
The ALU contains several functional units that can perform the following operations:
Arithmetic Operations:
- ADD: Adds inputs A and B.
- SUB: Subtracts input B from input A.
- MUL: Multiplies inputs A and B.
- DIV: Divides input A by input B, producing a quotient and a remainder.
Logical Operations:
- AND: A bitwise AND operation of A and B.
- OR: A bitwise OR operation of A and B.
- NAND: A bitwise NAND operation of A and B.
- NOR: Performs the bitwise NOR of A and B.
-NOT: Performs bitwise NOT operation on either A or B
Bitwise Shift/Rotation Operations:
- SHL (Shift Left): Left shifts bits of A up to one position, or further to the specified left number.
- SHR (Shift Right): Right shifts bits of A up to one position, or further to the specified right number.
-ASR (Arithmetic Shift Right): Right shifts bits of a binary number to the right while preserving the number's sign
- ROL (Rotate Left): Swaps the A bits left to the right
- ROR (Rotate Right): Swaps the A bits to right to left
3. Opcode Select:
4 bits opcode, selected the functional to be done and executed
Opcode corresponds to function unit/perform or exact given functional that leads to exact actions in the given ALU that has been identified.
The flexibility and efficiency ensured in this design allow the ALU to provide for a number of arithmetic, logical, and bitwise operations pertinent to computational purposes.
4. Multiplexer:
The multiplexer selects the output of one functional unit based on the opcode value.
If the opcode is 0000, the ADD operation is selected
If the opcode is 0001, the SUB operation is selected
If the opcode is 0010, the MUL operation is selected
If the opcode is 0011, the DIV operation is selected
If the opcode is 0100, the AND operation is selected
If the opcode is 0101, the OR operation is selected
If the opcode is 0110, the NAND operation is selected
If the opcode is 0111, the NOR operation is selected
If the opcode is 1000, the SHL operation is selected
If the opcode is 1001, the SHR operation is selected
If the opcode is 1010, the ASR operation is selected
If the opcode is 1011, the ROL operation is selected
If the opcode is 1100, the ROR operation is selected
If the opcode is 1101, the XOR operation is selected
If the opcode is 1110, the NOT A operation is selected
If the opcode is 1111, the NOT B operation is selected
Reference Images: