Unit 2
Unit 2
AND ARCHITECTURE
e.g. representing decimal numbers into unsigned binary numbers using 3-bits
Decimal No. Binary equivalent (3-bit binary unsigned numbers)
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
09/08/2024 2
Introduction
• Arithmetic operations are used in digital computers to manipulate the binary
data to produce results that can be used for solution of a particular
computational problem.
• The binary data on which the arithmetic operations are performed can be
represented in signed or unsigned format.
09/08/2024 3
Signed numbers
• Signed binary numbers are represented by magnitude and sign. The MSB is
reserved as sign bit while remaining n-1 bits represent the magnitude
e.g. representing decimal numbers into signed binary numbers using 3-bits
09/08/2024 5
• Signed magnitude representation
e.g. ‒ 7 to be represented using 8-bits
MSB is sign bit: 1 in this case
Remaining bits represent the number 7 into equivalent binary value
1 0000111
09/08/2024 7
Case 3: Both numbers have different signs
09/08/2024 8
• Arithmetic Addition
Case 1: Both numbers are positive
09/08/2024 9
Algorithms for Arithmetic Operations
09/08/2024 11
Algorithms for Arithmetic Operations
• Addition and subtraction with signed-magnitude data
09/08/2024 12
• Addition and subtraction with signed-2’s complement data
Addition of two numbers consists of adding the numbers with sign bits treated as
other bits. Carry out of MSB is neglected.
Subtraction consists of 1st taking 2’s complement of subtrahend and then adding it
to the minuend.
• Hardware implementation
09/08/2024 13
• Hardware algorithm
For the flowchart of
addition/subtraction of
numbers in signed-magnitude
representation, indicate the
overall path the algorithm
takes for the following
(Assume MSB to be sign bit).
Also indicate status of AVF
(i) 0101101 + 0011111
(ii) 0101101 – 0101101
(iii) 1011111 - 0101101
09/08/2024 14
• Multiplication of signed-magnitude data
09/08/2024 15
• Hardware algorithm
09/08/2024 16
• Hardware implementation
09/08/2024 18
Hardware implementation
• First, instead of providing registers to store and add simultaneously as
many binary numbers as there are bits in the multiplier, it is convenient
to provide an adder for the summation of only two binary numbers and
successively accumulate the partial products in a register.
• Second, instead of shifting the multiplicand to the left, the partial
product is shifted to the right, which results in leaving the partial
product and the multiplicand in the required relative positions.
• Third, when the corresponding bit of the multiplier is 0, there is no
need to add all zeros to the partial product since it will not alter its
value.
• The multiplicand is stored in register B and multiplier is stored in register Q.
• Initially register A and E are set to 0.
• The sum of A and B forms the partial product stored in EA
• The final multiplication result is stored in AQ. A: Most significant bit, Q: Least
significant bit
• Sequence counter holds the value equal to no. of bits in multiplier (Q)
• Initially, the multiplicand is in register B and the multiplier in Q. The sum of A and B
forms a partial product which is transferred to the EA register. Both partial product
and multiplier are shifted to the right. This shift will be denoted by the statement
shr EAQ to designate the right shift. The least significant bit of A is shifted into the
most significant position of Q, the bit from E is shifted into the most significant
position of A, and 0 is shifted into E. After the shift, one bit of the partial product is
shifted into Q, pushing the multiplier bits one position to the right.
09/08/2024 20
• Numerical example
09/08/2024 21
• Hardware algorithm
09/08/2024 22
Booth’s multiplication algorithm
Used for multiplying integers represented in signed-2’s complement format
Hardware implementation
09/08/2024 23
• Hardware algorithm
09/08/2024 24
Rules to follow for Booth’s Algorithm
1. The multiplicand is subtracted from the partial product upon
encountering the first least significant 1 in a string of 1's in the
multiplier.
2. The multiplicand is added to the partial product upon encountering
the first 0 (provided that there was a previous 1) in a string of 0’s in the
multiplier.
3. The partial product does not change when the multiplier bit is
identical to the previous multiplier bit.
Booth’s multiplication algorithm
• Booth algorithm gives a procedure for multiplying binary integers in
signed-2's complement representation. It operates on the fact that
strings of 0's in the multiplier require no addition but just shifting, and
a string of l's in the multiplier from bit weight 2k to weight 2m can be
treated as 2k+1 - 2m. For example, the binary number 001110 (+14) has
a string of l's from 23 to 21
• (k =3, m =1). The number can be represented as 2k+1 - 2m = 24 -21 = 16 -
2 = 14. Therefore, the multiplication M x 14, where M is the
multiplicand and 14 the multiplier, can be done as M x 24 - M x 21.
Thus the product can be obtained by shifting the binary multiplicand
M four times to the left and subtracting M shifted left once.
• Numerical example of (-9) X (-13) = (+117)
09/08/2024 27
• Division of signed-magnitude data
09/08/2024 30
• Numerical example
09/08/2024 31
• Divide overflow
When dividend is twice as long as the divisor, divide overflow occurs if high-order
half bits of dividend constitute a number greater than or equal to the divisor.
09/08/2024 32
Floating point representation
• Under this representation, the numbers are represented using 2 parts
Mantissa (fixed point number)
Exponent (position of decimal point)
e.g. + 6132.789
Fraction part: 0.6132789, exponent part: +4
09/08/2024 33
• Number needs to be stored in registers
Format followed
Sign (S) Exponent (E) Mantissa (M)
09/08/2024 34
Normalization Implicit normalization: before decimal point
there should be a digit 1
1.0111 x 22
M= 0111, e = 2
101.11
Explicit normalization: before decimal point
there should be no digit
0.10111 x 23
M=10111, e = 3
Explicit normalization is the default normalization in conventional
09/08/2024 method of floating point representation 35
Getting the number from floating point representation
Explicit normalization
Implicit normalization
09/08/2024 36
Numerical example
Represent (+19.25)10 in floating point format using a 16-bit register for storing the
number. Mantissa follows explicit normalization and exponent is represented in
excess-32 format.
bias = 32, no. of bits used to store exponent = 6
No. of bits used to store sign bit =1
No. of bits used to store the mantissa = 16-(6+1) = 9
(+19.25)10 (10011.01)2 S E M
Normalization: 10011.01 0 100101 100110100
1 bit 6 bits 9 bits
M = 1001101, E = 5 + 32 = 37 100101
09/08/2024 37
IEEE format for floating point representation
• Disadvantage of conventional approach:
Cannot represent number 0
Cannot represent very small numbers
09/08/2024 38
Numerical example
Represent (-27.625)10 in IEEE single precision format
(-27.625)10 (11011.101)2
Normalization: 11011.101
M = 101110100000..00,
S EE = 4 + 127 = 131
M 10000011
1 10000011 101110100000..00
1 bit 8 bits 23 bits
09/08/2024 39
• 2 standard representations used IEEE 32-bit format
Sign (S) Exponent (E) Mantissa (M)
Single precision format (32-bit)
1-bit 8-bits 23-bits
IEEE 64-bit format
Sign (S) Exponent (E) Mantissa (M)
Double precision format (64-bit) 1-bit 11-bits 52-bits
09/08/2024 40
Getting the number from IEEE floating point representation
Implicit normalization
09/08/2024 41