Lecture 15: pipeline (1) Lecturer: Noor Kadhum Arithmetic pipeline Arithmetic pipeline divides an arithmetic operation into sub-operations for execution in the pipeline segments, it's used to implement the floating point operation , multiplication of fixed point numbers and similar computations encountered in scientific problems. Arithmetic pipe with fixed point Suppose that we want to perform the combined multiply and add operations with a stream numbers: Ai * Bi +Ci for i=1,2,3,…, 7 The first rule: there is no fixed number of segments ,How? The No. of segment depends on the arithmetic expression, i.e. each sub-operation is implemented in a segment. The second rule : we need registers for holding inputs and the results of segments. In addition, we need a combinational circuit to perform required operation. return to previous example , we have three segments: seg1: R1← Ai , r2← Bi (loading of inputs Ai and Bi) seg2: R3 ← R1 *R2, R4 ← Ci (multiplying and load C) seg3: R5 ← Ci (adding Ci to the product) The No. of tasks = 7 because these segments repeated 7 times (i=1,2,...,7) . The combinational circuit that perform this instruction is consist of multiplier and adder as shown below : Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Lecturer: Noor Kadhum Now, if tp= 25 ns: n * k* tp speed up= ـــــــــــــــــــــــــــــــــــــــــ (n+k-1)*tp = (7*3*25)/ (9*25) = 2.333 Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Lecturer: Noor Kadhum The content of the registers will be: Clock SEGMENT1 SEGMENT2 cycle R1 R2 R3 R4 1 A1 B1 2 A2 B2 A1 *B1 C1 3 A3 B3 A2*B2 C2 A1*B1+C1 4 A4 B4 A3*B3 C3 A2*B2+C2 5 A5 B5 A4*B4 C4 A3*B3+C3 6 A6 B6 A5*B5 C5 A4*B4+C4 7 A7 B7 A6*B6 C6 A5*B5+C5 A7*B7 C7 A6*B6+C6 8 SEGMENT3 9 R5 A7*B7+C7 Question for discussion : If the previous example was : x= Ai * Bi +Ci for i=1,2,3,…, 7 1- How many segments we need? 2- Design a hardware to perform this problem. 3- show the content of the registers during the execution. Pipeline for floating point operation Representation of floating point number is not unique. For example, the number 55.66 can be represented as 5.566×10^1, 0.5566×10^2,0.05566×10^3, and so on. Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Lecturer: Noor Kadhum It is important to note that floating-point numbers suffer from loss of precision when represented with a fixed number of bits (e.g., 32-bit or 64-bit). This is because there are infinite number of real numbers (even within a small range of says 0.0 to 0.1). On the other hand, a n-bit binary pattern can represent a finite 2^n distinct numbers. Hence, not all the real numbers can be represented. The nearest approximation will be used instead, resulted in loss of accuracy. It is also important to note that floating number arithmetic is very much less efficient than integer arithmetic. It could be speed up with a so-called dedicated floating-point coprocessor. Hence, use integers if your application does not require floating-point numbers. floating point operations are easily decomposed ( )ﺗﺠ ﺰأinto sub-operations. We will now show an example of a pipeline unit for floating point addition and subtraction : the inputs to the floating point adder pipeline are two normalized floating point binary numbers : X= A × 2a Y= B ×2b A and B are fractions ( )ﻛﺴ ﻮرthat represent the mantissa ()اﻟﻤﻘ ﺪار and a and b are the exponents. The floating point addition and subtraction can be performed in four segment , the registers labeled R are placed between the segments to store intermediate results. The Four segments are : Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Lecturer: Noor Kadhum 1- compare the exponents and find the difference (d) by subtracting them: - choose the larger exponent to be the exponent of the result. -the difference (d) is important for shifting operation in the next step. 2- Align the mantissa: use the difference (d) to shift the mantissa associated with the smallest exponent d times to the right , each right shift increases the exponent by one. 3- add or subtract the mantissa. 4- normalize the result so that it has a fraction with a nonzero first digit this is done by shifting the mantissa to right and increasing the exponent by one for each shifting to obtain the normalized result . The following example may clarify the sub-operations performed in each segment. For simplicity, we use decimal numbers. Consider the two normalized floating point numbers : x= 0.9504 ×103 y= 0.8200 ×102 1- comparison between the exponents: d= 3-2=1 this mean that the alignment done by shifting y(number with smallest exponent) once to the right. Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Lecturer: Noor Kadhum 2- Alignement: x= 0.9504 ×103 y= 0.082 ×103 3- addition : z=x+y z= 0.9504 ×103 + 0.082 ×103 z= 1.0324 ×103 4- result normalization by shifting the mantissa to the right and increasing the exponent : z= 0.10324 ×104 To build a hardware for this operation we need : 1- comparator (subtructer). 2- shifter . 3- adder (subtracter). 4- normalizer. Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Segment 1 : Lecturer: Noor Kadhum Exponents a b Mantissas A B R R Compare exponents by subtraction Difference R Segment 2 : Choose exponent Align mantissas R Add or subtract mantissas Segment 3 : Segment 4 : R R Adjust exponent Normalize result R R u Vector Instruction Format : Fig. 9-11 Babylon university - Sciences College For Women - Architecture – Third class Lecture 15: pipeline (1) Lecturer: Noor Kadhum Babylon university - Sciences College For Women - Architecture – Third class