Top Banner

Click here to load reader

25
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ARITHMETIC AND LOGIC UNIT

ARITHMETIC AND LOGIC UNIT

A project of Computer Architecture and Organization

Page 2: ARITHMETIC AND LOGIC UNIT

WHAT WE WILL LEARN?

• Computer Organization• What is ALU?

Page 3: ARITHMETIC AND LOGIC UNIT

Digital Computer Organization

Feeds data into the computer.

Stores instructions

and data

Fetches and executes

instructions

Manipulates data

Page 4: ARITHMETIC AND LOGIC UNIT

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.

Page 5: ARITHMETIC AND LOGIC UNIT

What is ALU?

Page 6: ARITHMETIC AND LOGIC UNIT

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

Page 7: ARITHMETIC AND LOGIC UNIT

ALU SYMBOL

Page 8: ARITHMETIC AND LOGIC UNIT

MICROOPERATIONS

• Elementary operations performed with the data stored in registers.

• Classifications– Register Transfer Microoperation.– Arithmetic Microoperation.– Logic Microoperation.– Shift Microoperation.

Page 9: ARITHMETIC AND LOGIC UNIT

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.

Page 10: ARITHMETIC AND LOGIC UNIT

ARITHMETIC MICROOPERATIONS

• Performs arithmetic operations on numeric data stored in registers.

• Some of the arithmetic microoperations:– ADD microoperation.– SUBTRACT microoperation.

Page 11: ARITHMETIC AND LOGIC UNIT

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

Page 12: ARITHMETIC AND LOGIC UNIT

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

Page 13: ARITHMETIC AND LOGIC UNIT

ADD AND SUBTRACT MICROOPERATIONS

Page 14: ARITHMETIC AND LOGIC UNIT

HARDWARE IMPLEMENTATION

Page 15: ARITHMETIC AND LOGIC UNIT

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.

Page 16: ARITHMETIC AND LOGIC UNIT

LOGIC MICROOPERATION

Page 17: ARITHMETIC AND LOGIC UNIT

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.

Page 18: ARITHMETIC AND LOGIC UNIT

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.

Page 19: ARITHMETIC AND LOGIC UNIT

CLASSIFICATION

• Logical Shift– Logical Left Shift– Logical Right Shift

• Arithmetic Shift– Arithmetic Left Shift– Arithmetic Right Shift

Page 20: ARITHMETIC AND LOGIC UNIT

LOGICAL SHIFT

• The bits that are shifted out are discarded, and zeros are shifted in.

• The logical shift is suitable for unsigned binary numbers.

Page 21: ARITHMETIC AND LOGIC UNIT

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.

Page 22: ARITHMETIC AND LOGIC UNIT

LOGICAL LEFT SHIFT

• Zeros are shifted in on the right . • For example,

00010111= 001011100 being added

to at the rightmost bit

Page 23: ARITHMETIC AND LOGIC UNIT

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

Page 24: ARITHMETIC AND LOGIC UNIT

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

Page 25: ARITHMETIC AND LOGIC UNIT

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