[go: up one dir, main page]

0% found this document useful (0 votes)
53 views51 pages

03 - 02 Computer Arithmetic

This document covers the fundamentals of computer arithmetic, including addition, subtraction, multiplication, and division algorithms for various data types such as fixed-point binary, floating-point, and BCD. It discusses the implementation of these algorithms in hardware and the complexities involved in floating-point operations. The document also outlines the procedures for arithmetic operations and the necessary hardware configurations for efficient computation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views51 pages

03 - 02 Computer Arithmetic

This document covers the fundamentals of computer arithmetic, including addition, subtraction, multiplication, and division algorithms for various data types such as fixed-point binary, floating-point, and BCD. It discusses the implementation of these algorithms in hardware and the complexities involved in floating-point operations. The document also outlines the procedures for arithmetic operations and the necessary hardware configurations for efficient computation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Computer Organization and Architecture

UNIT – III
Computer Arithmetic
Prof. Murali Nath R S, Ms. Kavitha P & Ms. Nagamani G
Department of Computer Science & Engineering

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study thistocourse?
Topics be Covered
Introduction
Examples

Addition and Subtraction


Multiplication Algorithms
Division Algorithms

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course?
Introduction
Arithmetic instructions manipulate data to produce results as the solution for
Examples
computational problems.
These are responsible for the bulk of activity involved in processing data in a
computer.

The four basic arithmetic operations are addition, subtraction, multiplication


and division.
These four basic operations are used to formulate other arithmetic functions
and solve scientific problems by means of numerical analysis methods.

An arithmetic processor is the part of a processor unit that executes arithmetic


operations.
BVRIT HYDERABAD College of Engineering for Women
Here, various arithmetic algorithms are developed and the procedure
for implementing them with digital hardware is shown.

Let us consider addition, subtraction, multiplication, and division for the


following types of data:
- Fixed-point binary data in signed-magnitude representation
- Fixed-point binary data in signed-2's complement representation
- Floating-point binary data
- Binary-coded decimal (BCD) data

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study thisand
Addition course?
Subtraction
The Addition and Subtraction operations can be performed on the data
Examples as:
represented
- Signed-Magnitude
- Signed-2’s Complement
- Floating-Point
- BCD

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course? Data
Signed-Magnitude
The magnitude of the two numbers are denoted by A and B.
Examples A + B A: Augend B: Addend
Addition:
Subtraction: A - B A: Minuend B: Subtrahend
For signed numbers’ addition or subtraction, eight different conditions to be
considered, based on the sign & the operation.

BVRIT HYDERABAD College of Engineering for Women


In the above table:
- All possible eight conditions are listed in the first column.
- The other columns show the actual operation to be performed with the
magnitude of the numbers.
- The last column is needed to prevent a negative zero, i.e., to get +0 not
-0.

The algorithms for addition and subtraction are designed based on the table
and can be stated as follows:
Addition (subtraction) algorithm:
When the signs of A and B are identical (different):
- Add the two magnitudes
- Attach the sign of A to the result.
BVRIT HYDERABAD College of Engineering for Women
When the signs of A and B are different (identical):
- Compare the magnitudes and subtract the smaller number from
the larger.
- Choose the sign of the result to be the same as A if A > B or the
complement of the sign of A if A < B.
- If the two magnitudes are equal, subtract B from A and make the sign
of the result positive.

The two algorithms are similar except for the sign comparison.
The procedure to be followed for identical signs in the addition algorithm
is the same as for different signs in the subtraction algorithm, and vice
versa.

BVRIT HYDERABAD College of Engineering for Women


Why Should I Hardware
Study this Implementation
course?
Let A and B be two registers holding the magnitudes of the numbers, and As and
BExamples
s be two flip-flops holding the signs.
The result of the operation may be transferred to a third register, but a saving is
achieved if the result is transferred into A and As, forming an accumulator
register.
The hardware implementation of the above algorithms:
First, a parallel-adder is needed to perform the microoperation A + B.
Second, a comparator circuit is needed to establish if A > B, A = B, or A < B.
Third, two parallel-subtractor circuits are needed to perform the microoperations
A - B and B - A.
The sign relationship can be determined from an XOR gate with As and Bs as
inputs.
BVRIT HYDERABAD College of Engineering for Women
But the above implementation is not economical and also increases the
complexity of the design.
An efficient design can be done with the observations:
-The subtraction can be accomplished by means of complement and add.
-The result of a comparison can be determined from the end carry after the
subtraction.

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course?
Hardware Algorithm

Examples

BVRIT HYDERABAD College of Engineering for Women


Why Should ISigned-2's
Study thisComplement
course? Data
In the signed-2's complement representation of numbers, the leftmost bit of
aExamples
binary number represents the sign bit: 0 for positive and 1 for negative.
If the sign bit is 1, the entire number is represented in 2' s complement
form. Thus + 33 is represented as 00100001 and - 33 as 11011111.

The addition is performed by adding two numbers with the sign bits treated
the same as the other bits of the number. A carry-out of the sign-bit position
is discarded.

The subtraction consists of first taking the 2' s complement of the


subtrahend and then adding it to the minuend.
BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
Hardware & Algorithm

Examples

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course?
Floating-Point Numbers
A floatingpoint number in computer registers consists of two parts: a mantissa m
Examples
and an exponent e.
The mantissa may be a fraction or an integer.
The location of the radix point and the value of the radix r are assumed and are not
included in the registers.
For example, the decimal number 537.25 is represented in a register with m =
53725 and e = 3.
Floating-point representation increases the range of numbers that can be
accommodated in a given register.
In a 48-bit computers, a floating-point number is represented with 36 bits for the
mantissa and 12 bits for the exponent.
Computers with shorter word lengths use two or more words to represent a floating-
point number.
BVRIT HYDERABAD College of Engineering for Women
Arithmetic operations with floating-point numbers, compared with fixed-
point numbers are:
- Complicated
- Longer Execution
- Require Complex Hardware

Addition or subtraction of two numbers require an alignment of the radix


point to make the exponents equal.
The alignment is done by shifting one mantissa while its exponent is
adjusted until it is equal to the other exponent.
Example:
.5372400 X 102 + .1580000 X 10-1
.56780 X 105 - .56430 X 105
BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this Configuration
Register course?
The register configuration for floating-point operations is quite similar to the layout
Examples
for fixed-point operations.
The same registers and adder used for fixed-point arithmetic are used for processing
the mantissas.
The difference lies in the way the exponents are handled.
The register organization for floating-point operations is:

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course?
Algorithm
For addition or subtraction, the two floating-point operands are in AC
Examples
and BR.
The sum or difference is formed in the AC.

The algorithm can be divided into four consecutive parts:


1. Check for zeros.
2. Align the mantissas.
3. Add or subtract the mantissas.
4. Normalize the result.

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
BCD

Examples

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
BCD Binary Equivalent Binary Equivalent
(9 – d)
(d) B8 B4 B2 B1 x8 x4 x2 x1

0 0 0 0 0 9 1 0 0 1

1 0 0 0 1 8 1 0 0 0

2 0 0 1 0 7 0 1 1 1

3 0 0 1 1 6 0 1 1 0

4 0 1 0 0 5 0 1 0 1

5 0 1 0 1 4 0 1 0 0

6 0 1 1 0 3 0 0 1 1

7 0 1 1 1 2 0 0 1 0

8 1 0 0 0 1 0 0 0 1

9 1 0 0 1 0 0 0 0 0

BVRIT HYDERABAD College of Engineering for Women


x1 = B1M + B1 M
x2 = B2
x4 = B4M + (B4B2 + B4B2)M
x8 = B8M + B8 B4 B2 M

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
Signed-Magnitude

Examples

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course?
Hardware

Examples

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Why Should I StudyBooth
this course?
Algorithm
Signed 2’s Complement Numbers
AExamples
String of 0s in the multiplier require no addition, but shifting
A String of 1s in the multiplier from bit weight 2k to weight 2m can be
treated as 2k+1 – 2m.
The multiplication process is:
1. The multiplicand i subtracted from the partial product upon encountering
the first least significant 1 in a string of 1’s in the multiplier (10).
2. The multiplicand is added to the partial product upon encountering the
first 0 (previous should be 1) in a string of 0’s in the multiplier (01).
3. The partial product does not change when the multiplier bit is identical
to the previous multiplier bit (00 or 11).
BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
Hardware

Examples

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Why Should I StudyArray
this course?
Multiplier

Examples

BVRIT HYDERABAD College of Engineering for Women


For j multiplier bits and k
multiplicand bits, j x k
AND gates and (j - 1) k-bit
adders needed to produce a
product of j + k bits.

BVRIT HYDERABAD College of Engineering for Women


Why Should I Study this course?
Floating-point Numbers
The multiplication of two floating-point numbers require:
Examples
- Multiplication of mantissas &
- Addition of the exponents

The multiplication algorithm can be subdivided into four parts:


1. Check for zeros
2. Add the exponents
3. Multiply the mantissas
4. Normalize the product

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
Why Should I StudyBCD
this course?
Numbers
The multiplication of fixed-point decimal numbers is similar to binary
Examples
except that the way the partial products are formed.

In the binary case, the multiplicand is added to the partial product if the
multiplier bit is 1.

In the case of decimal, the multiplicand must be multiplied by the digit


multiplier and the result added to the partial product.

This operation can be accomplished by adding the multiplicand to the


partial product a number of times equal to the value of the multiplier digit.
BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
Signed- Magnitude
Division of two fixed-point binary numbers in signed-magnitude
Examples
representation is done with paper and pencil by a process of successive
operations:
- Compare,
- Shift,
- Subtract.

Binary division is simpler than decimal division because:


- The quotient digits are either 0 or 1.
- No need to estimate how many times the dividend or partial
remainder fits into the divisor.
BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
Hardware

Examples

BVRIT HYDERABAD College of Engineering for Women


Instead of shifting the divisor to
the right, the dividend, or partial
remainder, is shifted to the left,
thus leaving the two numbers in
the required relative position.

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
Why Should I Study this course?
Floating-point Numbers
Floating-point division requires:
Examples
- The exponents be subtracted
- The mantissas divided.

The mantissa division is done as in fixed-point except that it is a fraction and not an
integer.

The division algorithm can be subdivided into five parts:


1. Check for zeros.
2. Initialize registers and evaluate the sign.
3. Align the dividend.
4. Subtract the exponents.
5. Divide the mantissas.
BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Why Should I StudyBCD
this course?
Numbers
Decimal division is similar to binary division except that the quotient
Examples
digits may have any of the 10 values from 0 to 9.

In the restoring division method, the divisor is subtracted from the


dividend or partial remainder as many times as necessary until a negative
remainder results.
The correct remainder is then restored by adding the divisor.
The digit in the quotient reflects the number of subtractions up to but
excluding the one that caused the negative difference.

BVRIT HYDERABAD College of Engineering for Women


BVRIT HYDERABAD College of Engineering for Women
BVRIT HYDERABAD College of Engineering for Women
Thank You

BVRIT HYDERABAD College of Engineering for Women

You might also like