You are on page 1of 19

Computer Organization

Lec #11 : ALU

Bnar Mustafa
bnar.mustafa8@gmail.com
Spring 2021

Computer Organization - Bnar Mustafa 1


Video Links:

Part 1: https://youtu.be/YNWaH8oDKsk

Part 2: https://youtu.be/LN1aiPu6i4Q

Part 3: https://youtu.be/9peL4EM-HNI

Computer Organization - Bnar Mustafa 2


Arithmetic logic unit
• The arithmetic logic unit is that part of the CPU that handles all
the calculations the CPU may need (Addition, Subtraction,
Comparisons). It performs Logical Operations, Bit Shifting
Operations, and Arithmetic Operation.

• The control unit supplies the data required by the ALU from
memory, or from input devices, and directs the ALU to perform a
specific operation based on the instruction fetched from the
memory. ALU is the ―calculator‖ portion of the computer.

• In some microprocessor architectures, the ALU is divided into


the arithmetic unit (AU) and the logic unit (LU).

• ALU is also known as an Integer Unit (IU)


Computer Organization - Bnar Mustafa 3
Computer Organization - Bnar Mustafa 4
Design of an ALU of 8- bit Adder_Sub tractor
In order to design this block diagram so all the register of this
processor were 8-bit size.

Computer Organization - Bnar Mustafa 5


Each Adder consist of many adders depending on the size of
processor register.
The following Figure of 8-bit Adder
(- 3) + ( +3)
Flouting point form
It will be represent by two parts mantissa and exponent using the
following form
m*r e
Where;
m: mantissa, r:radix, and e : exponent
Example : (+6132.789) decimal value of radix 10
equivalent to ( 0.6132789 * 104 )
m= 6132789
e=4
Flouting point in Binary
• A floating point number in binary consists of bits allocated to store
the mantissa and the exponent.

• The number base (radix) is not stored, as it is always 2.

• The binary point (.) is also not stored; it is always found in the same
place – immediately after the first bit.
The Sign
• The sign of a binary floating-point number is represented by a
single bit. A 1 bit indicates a negative number, and a 0 bit
indicates a positive number.

Computer Organization - Bnar Mustafa 9


The Mantissa
• It is useful to consider the way decimal floating-point numbers
represent their mantissa. Using (-3.154 x 105 ) as an example,
the sign is negative, the mantissa is 3.154, and the exponent is 5.
The fractional portion of the mantissa is the sum of each digit
multiplied by a power of 10:
.154 = 1/10 + 5/100 + 4/1000

• A binary floating-point number is similar. For example, in the


number ( +11.1011 x 23 ), the sign is positive, the mantissa is
11.1011, and the exponent is 3. The fractional portion of the
mantissa is the sum of successive powers of 2. In our example, it
is expressed as:
.1011 = 1/2 + 0/4 + 1/8 + 1/16

Computer Organization - Bnar Mustafa 10


• If the binary number 0.101 x 24 is stored in a format that allows 8
bits for the mantissa and 4 bits for the exponent, it would be
stored as a 12-bit number as shown below.

Computer Organization - Bnar Mustafa 11


The flouting point binary number will be represent in the same manner,
only the base of the exponent (radix) will be 2 rather than 10

Ex: (+1001.11) represented by 8-bit fraction and 6-bit exponent as


follows
fraction = 01001110
exponent=000100

Note :in (fraction)The left hand side 0 bit denote positive sign while right
hand side 0 bit to complete the 8-bit size .

the binary point of the fraction follows the sign bit but is not shown in
the register.
Addition
• Addition is similar to decimal arithmetic. The addition of two binary
number 1 and 1 is 10, where we consider 0 and carry forward 1 to
next high order.
• For example, 1 + 1 + 1 = 3 in base 10 and 1 + 1 + 1 = 11 in binary
number system.
Rules:
0+0=0
0+1=1
1+0=1
1 + 1 = 10 (which is 0 carry 1)

Example:
1011
(+) 1 0 1
——————
1 0000

Computer Organization - Bnar Mustafa 13


Subtraction
• In case of decimal subtraction, when 1 is subtracted from 0, then we
borrow 1 from next preceding number and make it 10, and after
subtraction, it results in 9, i.e. 10 – 1 = 9. But for binary subtraction,
it results in 1 only.
Rules :
• 0–0=0
• 0 – 1 = 1 ( with a borrow of 1)
• 1–0=1
• 1–1=0
Example
1010
(-) 1 0 1
——————
0101
Computer Organization - Bnar Mustafa 14
Consider other examples of binary subtractions are as follows:
Example 1: 0011010 – 001100
Solution:
001 1 0 1 0
(-) 0 0 1 1 0 0
———————
000111 0
Decimal Equivalent :
0 0 1 1 0 1 0 = 26
0 0 1 1 0 0 = 12
Therefore, 26 – 12 = 14
The binary resultant 0 0 0 1 1 1 0 is equivalent to the 14

Computer Organization - Bnar Mustafa 15


• Example :
1111011.11
– 1010101.10
——————–
100110.01

Computer Organization - Bnar Mustafa 16


• Positive Signed Binary Numbers

• Negative Signed Binary Numbers

Computer Organization - Bnar Mustafa 17


Homework
• Calculate the result of the following expressions:

• 0100010 – 0001010
• 1 + 11
• 1010 + 11
• 100101 + 10101

Computer Organization - Bnar Mustafa 19


Good luck 

Computer Organization - Bnar Mustafa 20

You might also like