Click here to load reader
Dec 14, 2014
ARITHMETIC AND LOGIC UNIT
A project of Computer Architecture and Organization
WHAT WE WILL LEARN?
• Computer Organization• What is ALU?
Digital Computer Organization
Feeds data into the computer.
Stores instructions
and data
Fetches and executes
instructions
Manipulates data
Computer Organization
• Input Unit (I/P)– Feeds data into the computer.
• Output Unit (O/P) – Displays information to the user.
• Central Processing Unit (CPU)– Memory Unit (MU)
• Stores instructions and data.– Control Unit (CU)
• Fetches and executes instructions.– Arithmetic Logic Unit (ALU)
• Manipulates data.
What is ALU?
Definition
• ALU stands for Arithmetic and Logic Unit.
• ALU manipulates data.• ALU handles all Boolean (logical) and
mathematical (arithmetic) operations• Responsible for – Arithmetic Operations– Logical Operations
ALU SYMBOL
MICROOPERATIONS
• Elementary operations performed with the data stored in registers.
• Classifications– Register Transfer Microoperation.– Arithmetic Microoperation.– Logic Microoperation.– Shift Microoperation.
Register Transfer Microoperation
• Moves the content of the source registers to the destination register.
• Contents of the source register is not changed.
• Denoted byR2 ← R1
Where R2 is the destination register and R1 is the source register.
Contents of R1 being transferred to R2.
ARITHMETIC MICROOPERATIONS
• Performs arithmetic operations on numeric data stored in registers.
• Some of the arithmetic microoperations:– ADD microoperation.– SUBTRACT microoperation.
ADD MICROOPERATION
• Defined by the statement
R3 ← R1 + R2
• Here, R3 stores the sum of R1 and R2.
R3 stores the sum of R1 and R2
SUBTRACT MICROOPERATION
• Defined by the statement
R3 ← R1 - R2
• Here, R3 stores the difference of R1 and R2.
R3 stores the difference of R1 and R2
ADD AND SUBTRACT MICROOPERATIONS
HARDWARE IMPLEMENTATION
LOGIC MICROOPERATIONS
• Specify binary operations for strings of bits stored in registers.
• Consider each bit of the register separately and treat them as binary variables.
LOGIC MICROOPERATION
HARDWARE IMPLEMENTATION
• Requires logic gates to be inserted for each bit or pair of bits to perform the required logical function.
• Irrespective of sixteen logic microoperations present, most computers use only for – AND, OR, COMPLEMENT, XOR.
• Remaining microoperations can be obtained from above stated microoperations.
SHIFT MICROOPERATIONS
• Used for serial transfer of data.• Also used in conjunction with
arithmetic, logic, and other data – processing operations.
• Contents of a register can be shifted either right or left.
CLASSIFICATION
• Logical Shift– Logical Left Shift– Logical Right Shift
• Arithmetic Shift– Arithmetic Left Shift– Arithmetic Right Shift
LOGICAL SHIFT
• The bits that are shifted out are discarded, and zeros are shifted in.
• The logical shift is suitable for unsigned binary numbers.
ARITHMETIC SHIFT
• The bits that are shifted out of either end are discarded.
• In computer programming , an arithmetic shift is a shift operator , sometimes known as a signed shift (though it is not restricted to signed operands).
• For binary numbers, it is a bitwise operations that shifts all of the bits of its operand.
• When shifting to the right, the leftmost bit (usually the sign bit in signed integer representations) is replicated to fill in all the vacant positions.
LOGICAL LEFT SHIFT
• Zeros are shifted in on the right . • For example,
00010111= 001011100 being added
to at the rightmost bit
ARITHMETIC RIGHT SHIFT
• Inserts bits with value 0 instead of copying in the sign bit.
• For example, 00010111= 00001011
MSB being copied to shift
the bits to right
ARITHMETIC LEFT SHIFT
• Zeros are shifted in on the right . • For example,
This example uses an 8-bit register:- 00010111= 00101110
• A left arithmetic shift by n is equivalent to multiplying by 2n (provided the value does not overflow).
• For example,00010111 LEFT-SHIFT-BY-TWO= 01011100
0 being added to at the
rightmost bit
ARITHMETIC RIGHT SHIFT
• The sign bit is shifted in on the left preserving the sign of the operand.
• The empty spaces will be filled up with a copy of the MSB.
• For example, 00010111= 00001011
0 being added to the MSB. Thus
changes the sign of negative numbers