Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital Kommunikationselektronik TNE027 Lecture 3 1 Multiply-Accumulator (MAC) Compute Sum of Product (SOP) Linear convolution y[n] = f[n]*x[n] = Σ f[k]

Similar presentations


Presentation on theme: "Digital Kommunikationselektronik TNE027 Lecture 3 1 Multiply-Accumulator (MAC) Compute Sum of Product (SOP) Linear convolution y[n] = f[n]*x[n] = Σ f[k]"— Presentation transcript:

1 Digital Kommunikationselektronik TNE027 Lecture 3 1 Multiply-Accumulator (MAC) Compute Sum of Product (SOP) Linear convolution y[n] = f[n]*x[n] = Σ f[k] x[n-k] requires L consecutive multiplications and L–1 additions. For a N  N multiplier, the product is 2N bits wide. The Accumulator should be designed with an extra K bits in width depending on L. k=0 L-1

2 Digital Kommunikationselektronik TNE027 Lecture 3 2 Distributed Arithmetic (DA) A method for computing Sum of Product y = = Σ c[n] x[n] = Σ c[n]  Σ x b [n]  2 b = Σ 2 b  Σ c[n]  x b [n] = Σ 2 b  F c (x b ) N-1 n=0 b=0 B-1 N-1 n=0 B-1 b=0 N-1 n=0 B-1 b=0

3 Digital Kommunikationselektronik TNE027 Lecture 3 3 F c (x b ) = Σ c[n]  x b [n] where x b = (x b [0], x b [1], …, x b [N–1]) F c (x b ) is a function of an N-bit input vector and can be pre-computed and saved in a look-up table. During computation, the look-up table accepts one bit from each of the N words as its input. The output of the look-up table is weighted by the approximate power-of-two factor and accumulated. Note that, in Fig.2.31, the content of the accumulator is shifted instead of shifting the output of the look-up table. N-1 n=0

4 Digital Kommunikationselektronik TNE027 Lecture 3 4 Signed DA systems x[n] = – 2 B  x B [n] + Σ x b [n]  2 b where x[n] has (B+1) bits. y = – 2 B  F c (x B ) + Σ 2 b  F c (x b ) where x B is the N-bit vector of sign bit. –The signed DA system can be implemented by An accumulator with add/subtract control (See Fig. 2.31) Using a ROM with one additional input bit to indicate F c (x b ) or – F c (x b ) and an accumulator without add/subtract control. B-1 b=0 B-1 b=0

5 Digital Kommunikationselektronik TNE027 Lecture 3 5 Modified DA Solutions –Use partial LUTs to reduce the size of ROM Suppose the length L  N inner product is computed y = = Σ c[n] x[n] = Σ Σ c[N  l+n] x[N  l+n] See Fig. 2.32. The ROM size is reduced from 2 LN  B to L  2 N  B. L  N –1 n=0 L –1N –1 l=0n=0

6 Digital Kommunikationselektronik TNE027 Lecture 3 6 Modified DA Solutions (cont.) Use additional LUTs to increase speed –A basic DA architecture accepts one bit from each of the N words as input to its LUT. If two bits per words are accepted, then the computational speed can be essentially doubled. –The maximum speed can be achieved with the fully pipelined word-parallel architecture. See Fig. 2.33.

7 Digital Kommunikationselektronik TNE027 Lecture 3 7 Computation of Special Functions Using CORDIC Digital signal processing algorithms might use certain trigonometric, hyperbolic, linear and logarithmic functions. Taylor series can be computed to approximate the function and a sequence of multiply and add operations should be performed.

8 Digital Kommunikationselektronik TNE027 Lecture 3 8 Coordinate Rotation Digital Computer (CORDIC) CORDIC algorithm is a more efficient alternative approach. CORDIC algorithm: At each iteration, compute [] = [] [ X k+1 Y k+1 XkXk ] YkYk 1 1 –mδk2–k–mδk2–k δk2–kδk2–k Z k+1 = Z k – δ k θ k

9 Digital Kommunikationselektronik TNE027 Lecture 3 9 CORDIC Theory The following text is based on the article ”A survey of CORDIC algorithms for FPGA based computers” by Ray Andraka Vector rotation transform x´ = x cosφ – y sinφ y´ = y cosφ + x sinφ which rotate a vector in a Cartesian plane by the angle φ. x´ = cosφ (x – y tanφ) y´ = cosφ (y + x tanφ)

10 Digital Kommunikationselektronik TNE027 Lecture 3 10 If the rotation angles are restricted so that tanφ = ±2 –i, the multiplication by the tangent term is reduced to a simple shift operation. Arbitrary angles of rotation are obtainable by performing a series of successively smaller elementary rotations. If the decision at each iteration, i, is which direction to rotate, then the cos(δ i ) term becomes a constant, because cos(δ i ) = cos(– δ i ). x i + 1 = K i (x i – y i d i 2 –i ) y i + 1 = K i (y i + x i d i 2 –i ) where: K i = cos(tan –1 2 –i ) = 1/ (1 + 2 –2i ) 1/2 d i = ±1

11 Digital Kommunikationselektronik TNE027 Lecture 3 11 Removing the scale constant from the iterative equations yields a shift-add algorithm for vector rotation. The product of the K i ’s can be applied elsewhere in the system or treated as part of a system processing gain. That product approaches 0.6073 as the number of iterations goes to infinity. Therefore, the rotation algorithm has a gain, A n, of approximately 1.647. The exact gain depends on the number of iterations, and obeys the relation A n = П (1 + 2 –2i ) 1/2 n

12 Digital Kommunikationselektronik TNE027 Lecture 3 12 The angle of a composite rotation is uniquely defined by the sequence of the directions of the elementary rotations. That sequence can be represented by a decision vector. Conversion from this vector representation to a convensional angle representation can be accomplished by using a look-up table. A better conversion method uses an additional adder-subtractor that accumulates the elementary rotation angles at each iteration. The angular values are supplied by a small look- up table (one entry per iteration) or are hardwired.

13 Digital Kommunikationselektronik TNE027 Lecture 3 13 The angle accumulator adds a third difference equation to the CORDIC algorithm: z i + 1 = z i – d i tan –1 (2 –i ) CORDIC rotator is normally operated in one of two modes: –Rotation mode –Vectoring mode

14 Digital Kommunikationselektronik TNE027 Lecture 3 14 The rotation mode rotates the input vector by a specified angle. In the rotation mode, the CORDIC equations are: x i + 1 = x i – y i d i 2 –i y i + 1 = y i + x i d i 2 –i z i + 1 = z i – d i tan –1 (2 –i ) where d i = –1 if z i < 0, +1 otherwise. The angle acummulator z i is initialized with the desired rotation angle z 0. x i and y i are initialized with the input vector x 0 and y 0.

15 Digital Kommunikationselektronik TNE027 Lecture 3 15 The following results of the rotation mode are obtained when n is reasonably large: x n = A n (x 0 cosz 0 – y 0 sinz 0 ) y n = A n (y 0 cosz 0 + x 0 sinz 0 ) z n = 0 A n = П (1 + 2 –2i ) 1/2 where x 0 and y 0 define the initial input vector and z 0 defines the desired rotation angle. The result x n and y n should be scaled by 1/A n to get the actual rotated vector. n

16 Digital Kommunikationselektronik TNE027 Lecture 3 16 The vectoring mode rotates the input vector to the x axis while recoding the angle required to make that rotation. In the vectoring mode, the CORDIC equations are: x i + 1 = x i – y i d i 2 –i y i + 1 = y i + x i d i 2 –i z i + 1 = z i – d i tan –1 (2 –i ) where d i = +1 if y i < 0, –1 otherwise.

17 Digital Kommunikationselektronik TNE027 Lecture 3 17 In the vectoring mode, after n iterations, the result is: x n = A n (x 0 2 + y 0 2 ) 1/2 y n = 0 z n = z 0 + tan –1 (y 0 / x 0 ) A n = П (1 + 2 –2i ) 1/2 z n is the rotated angle, i.e., the angle between the input vector (x 0, y 0 ) and x axis. x n /A n is the magnitude of the input vector (x 0, y 0 ). n

18 Digital Kommunikationselektronik TNE027 Lecture 3 18 The CORDIC rotation and vectoring algorithms are limited to rotation angles between –π/2 and π/2. The limitation is due to the use of 2 0 for the tangent in the first iteration. For composite rotation angles larger than π/2, an additional rotation of π/2 or π is required.

19 Digital Kommunikationselektronik TNE027 Lecture 3 19 Computing sin(θ) and cos(θ) –Use the rotation mode –Setting y 0 = 0, x 0 = 1/ A n and z 0 = θ –sin(θ) and cos(θ) can be obtained at the end of rotation: x n = A n ((1/ A n )cos θ – 0 · sin θ) y n = A n (0 · cos θ + ((1/ A n ) sin θ) –Note that multiplication of 1/ A n is performed as part of rotation operation. This eliminates the need for another multiplier for modulation.

20 Digital Kommunikationselektronik TNE027 Lecture 3 20 Extension to Linear Functions –A simple modification to the CORDIC equation permits the computation of linear functions: x i + 1 = x i – 0 y i d i 2 –i = x i y i + 1 = y i + x i d i 2 –i z i + 1 = z i – d i (2 –i ) For rotation mode, d i = – 1 if z i < 0, +1 otherwise, the linear rotation produces: x n = x 0 y n = y 0 + x 0 z 0 z n = 0 The operation is similar to that of a shift-add multiplier.

21 Digital Kommunikationselektronik TNE027 Lecture 3 21 For the vectoring mode, d i = +1 if y i < 0, –1 otherwise, it provides a method for evaluating ratios: x n = x 0 y n = 0 z n = z 0 + y 0 /x 0 Note that for linear functions, no scaling corrections are required, since the gain is a unity gain.

22 Digital Kommunikationselektronik TNE027 Lecture 3 22 Extension to Hyperbolic Functions The close relationship between the trigonometric and hyperbolic functions suggests the same architecture can be used to compute hyperbolic functions. The CORDIC equations are: x i + 1 = x i + y i d i 2 –i y i + 1 = y i + x i d i 2 –i z i + 1 = z i – d i tanh –1 (2 –i ) For rotation mode, d i = –1 if z i < 0, +1 otherwise. For vectoring mode, d i = +1 if y i < 0, –1 otherwise. Note that A n = П (1 – 2 –2i ) 1/2  0.80. n

23 Digital Kommunikationselektronik TNE027 Lecture 3 23 CORDIC Architectures CORDIC state machine See Fig. 2.38 and Fig. 2.39. Fast CORDIC pipeline See Fig. 2.40.


Download ppt "Digital Kommunikationselektronik TNE027 Lecture 3 1 Multiply-Accumulator (MAC) Compute Sum of Product (SOP) Linear convolution y[n] = f[n]*x[n] = Σ f[k]"

Similar presentations


Ads by Google