Hardware Implementations of Fixed-Point Atan2
Total Page:16
File Type:pdf, Size:1020Kb
Hardware Implementations of Fixed-Point Atan2 Hardware Implementations of Fixed-Point Atan2 Florent de Dinechin Matei I¸stoan Universit´ede Lyon, INRIA, INSA-Lyon, CITI-Lab ARITH22 Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 Methods for Computing atan2 in Hardware Yet another arithmetic function . • . that is useful in telecom (to recover the phase of a signal) (12{24 bits of precision) • . and in general for cartesian to polar coordinate transformation • and an interesting function, nonetheless 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 1 0.8 1 0.6 0.8 0.4 x 0.6 0.4 0.2 0.2 y 0 0 Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 2 / 24 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 Common Specification • target function y 1 (x; y) 1 y α = atan2(y; x) f (x; y) = arctan ( ) π x −1 1 x • input: fixed-point format −1 −1 0 1 ky y arctan ( ) = arctan ( ) [ ) kx x • output: fixed-point format and binary angles y (0; 1) π 2 −1 0 1 (−1; 0) π 0 (1; 0) −π x =) [ ) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 3 / 24 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 Common Specification • target function y 1 (x; y) 1 y α = atan2(y; x) f (x; y) = arctan ( ) π x −1 1 x • input: fixed-point format −1 −1 0 1 ky y arctan ( ) = arctan ( ) [ ) kx x • output: fixed-point format and binary angles y (0; 1) π 2 −1 0 1 (−1; 0) π 0 (1; 0) −π x =) [ ) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 3 / 24 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 Common Specification • target function y 1 (x; y) 1 y α = atan2(y; x) f (x; y) = arctan ( ) π x −1 1 x • input: fixed-point format −1 −1 0 1 ky y arctan ( ) = arctan ( ) [ ) kx x • output: fixed-point format and binary angles y (0; 1) π 2 −1 0 1 (−1; 0) π 0 (1; 0) −π x =) [ ) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 3 / 24 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 Common Specification • target function y 1 (x; y) 1 y α = atan2(y; x) f (x; y) = arctan ( ) π x −1 1 x • input: fixed-point format −1 −1 0 1 ky y arctan ( ) = arctan ( ) [ ) kx x • output: fixed-point format and binary angles y (0; 1) π 2 −1 0 1 (−1; 0) π 0 (1; 0) −π x =) [ ) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 3 / 24 Target platform: FPGAs (Field Programmable Gate Arrays) Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 A Meaningful Comparison 3 different methods for evaluating atan2 in hardware • same accuracy specification: f (x; y) computed with last-bit accuracy (faithful rounding) • same implementation effort Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 4 / 24 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 A Meaningful Comparison 3 different methods for evaluating atan2 in hardware • same accuracy specification: f (x; y) computed with last-bit accuracy (faithful rounding) • same implementation effort Target platform: FPGAs (Field Programmable Gate Arrays) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 4 / 24 Hardware Implementations of Fixed-Point Atan2 Introduction: Methods for computing Atan2 Hello FPGAs! Island-style homogeneous FPGAs Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 5 / 24 Hardware Implementations of Fixed-Point Atan2 CORDIC First Method: An Unrolled CORDIC 8 < x0 = x y0 = y : α0 = 0 8 −i xi+1 = xi − 2 si yi < −i yi+1 = yi + 2 si xi −i : αi+1 = αi − si arctan 2 8 p 2 2 < xn −! K x + y yn −! 0 : y αi −! arctan x Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 6 / 24 =) p = w − 1 − dlog2"w−1e bits for the xi and yi datapath • we can stop updating xi when 2i − 1 > p (unrolled operator) =) gα = 1 + dlog2((w − 1) × 0:5)e guard bits for the αi datapath Hardware Implementations of Fixed-Point Atan2 CORDIC CORDIC Iteration: Datapath Implementation Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 7 / 24 =) p = w − 1 − dlog2"w−1e bits for the xi and yi datapath • we can stop updating xi when 2i − 1 > p (unrolled operator) =) gα = 1 + dlog2((w − 1) × 0:5)e guard bits for the αi datapath Hardware Implementations of Fixed-Point Atan2 CORDIC CORDIC Iteration: Datapath Implementation Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 7 / 24 =) gα = 1 + dlog2((w − 1) × 0:5)e guard bits for the αi datapath Hardware Implementations of Fixed-Point Atan2 CORDIC CORDIC Iteration: Accurate Datapath Implementation =) p = w − 1 − dlog2"w−1e bits for the xi and yi datapath • we can stop updating xi when 2i − 1 > p (unrolled operator) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 7 / 24 Hardware Implementations of Fixed-Point Atan2 CORDIC CORDIC Iteration: Accurate Datapath Implementation =) p = w − 1 − dlog2"w−1e bits for the xi and yi datapath • we can stop updating xi when 2i − 1 > p (unrolled operator) =) gα = 1 + dlog2((w − 1) × 0:5)e guard bits for the αi datapath Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 7 / 24 Hardware Implementations of Fixed-Point Atan2 CORDIC Hello, again, FPGAs! Current heterogeneous FPGAs Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 8 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Polynomial Approximations Polynomial approximation, and their derivatives (bipartite etc.): • the straight-forward solution for implementing univariate functions • problem: area asymptotically exponential in the input width... for a bivariate function, we double the input width. • solutions: - range reduction? - multiple consecutive one-input functions? Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 9 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Polynomial Approximations Polynomial approximation, and their derivatives (bipartite etc.): • the straight-forward solution for implementing univariate functions • problem: area asymptotically exponential in the input width... for a bivariate function, we double the input width. • solutions: - range reduction? - multiple consecutive one-input functions? Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 9 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Polynomial Approximations Polynomial approximation, and their derivatives (bipartite etc.): • the straight-forward solution for implementing univariate functions • problem: area asymptotically exponential in the input width... for a bivariate function, we double the input width. • solutions: - range reduction? - multiple consecutive one-input functions? Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 9 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan 1 The x and arctan (x) Functions y 1 arctan ( ) = arctan (y × ) x x reciprocal function arctangent function Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 10 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Range Reductions { Symmetry and Parity y x y π jxj arctan = − − arctan x 2 jyj Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 11 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Range Reductions { Scaling 2s y y arctan = arctan jxj jyj 2s x x bitwise OR y 1 LZC s = 1 s s = 2 s = 0 ShiftX ShiftY normalized s = 3 domain xr yr 0 x 0 1 Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 12 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan 1 The x and arctan (x) Functions { Reduced Domain reciprocal function on [0:5; 1) arctangent function on [0; 1) Now we can evaluate them with tables, or multipartite tables, or polynomial approximators, etc. (all available as faithful FloPoCo operators) Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 13 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Reciprocal-Multiply-Arctangent Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 14 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Reciprocal-Multiply-Arctangent Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 14 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Reciprocal-Multiply-Arctangent Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 14 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Reciprocal-Multiply-Arctangent: Datapath Dimensioning −w Goal: minimize architecture cost, such that j"total j < ulp = 2 1 1 j"total j < 3 j"recipj + 3 j"mult j + j"atanj Florent de Dinechin, Matei I¸stoan Hardware Implementations of Fixed-Point Atan2 ARITH22 14 / 24 Hardware Implementations of Fixed-Point Atan2 Recip-Mult-Atan Delays, Delays, Delays Florent de Dinechin, Matei I¸stoan Hardware Implementations