The processors of scientific computers add and multiply floating-point numbers millions of times. Doing the work of one floating-point operation in separate stages allows a new operation to begin on every clock cycle.

Floating-Point Addition in Stages

A floating-point number is stored as a mantissa and an exponent. To add two such numbers the exponents must be made equal first. The addition is therefore divided into four segments: compare the exponents, align the mantissas, add or subtract the mantissas, and normalise the result.

Definition: Arithmetic pipeline. A pipeline whose segments perform the successive steps of an arithmetic operation, such as floating-point addition or multiplication, on a stream of operands.

Working of the Stages

In segment 1 the exponents are subtracted, and the larger one is chosen. In segment 2 the mantissa of the number with the smaller exponent is shifted to the right by the difference. In segment 3 the aligned mantissas are added. In segment 4 the result is normalised, which means that the mantissa is shifted until it has the standard form and the exponent is adjusted. The segments are separated by registers that hold the intermediate results, so each segment can accept new data at every clock pulse. Without these registers the segments would interfere with one another.

A pipeline for floating-point multiplication follows a similar plan. The exponents are added, the mantissas are multiplied and the product is normalised. Since every segment works on a different pair of operands, a vector of operands can be processed at the rate of one result per clock cycle once the pipeline is full. This is why arithmetic pipelines are common in the processors used for scientific calculation and for vector processing.

Table 4.3: Stages of floating-point addition

Segment Operation Example
1 Compare exponents 3 and 2, difference 1
2 Align mantissas 0.8200 becomes 0.0820
3 Add mantissas 0.9504 + 0.0820 = 1.0324
4 Normalise 1.0324 x 10^3 becomes 0.10324 x 10^4

Example 4.3: Adding two floating-point numbers

Problem: Add X = 0.9504 × 10^3 and Y = 0.8200 × 10^2 by the four steps.

Solution:

  1. Compare exponents: 3 and 2. The difference is 1.
  2. Align: shift the mantissa of Y one place to the right, so Y = 0.0820 × 10^3.
  3. Add the mantissas: 0.9504 + 0.0820 = 1.0324, giving 1.0324 × 10^3.
  4. Normalise: shift right by one place and increase the exponent, giving 0.10324 × 10^4.

Result: X + Y = 0.10324 × 10^4, which is 1032.4.

x, y = 0.9504e3, 0.8200e2
print(x + y)

Output

1032.4

Common mistakes

  • Adding the mantissas before the exponents are equal.
  • Shifting the mantissa of the larger number during alignment.
  • Omitting the normalisation step after the addition.

Key takeaways

  • Floating-point addition has four segments: compare, align, add, normalise.
  • The mantissa of the smaller number is shifted during alignment.
  • A new addition can start in segment 1 on every clock cycle.
  • Normalisation puts the result in standard form.

Practice questions

  1. Name the four segments of a floating-point addition pipeline.
  2. Why must the exponents be equal before adding the mantissas?
  3. What is normalisation?

Answers to the practice questions

  1. Compare exponents, align mantissas, add or subtract mantissas, normalise the result.
  2. The mantissas are only meaningful at the same power, so the smaller one is shifted to match.
  3. Shifting the mantissa to its standard form and adjusting the exponent.

Sources

  • Official BCA syllabus Computer Architecture, course code 25BCA401DS02, Unit IV