Equivalence Verification of Polynomial Datapaths with FixedSize BitVectors
Equivalence Verification of Polynomial Datapaths with Fixed-Size Bit-Vectors using Finite Ring Algebra Namrata Shekhar 1, Priyank Kalla 1, Florian Enescu 2, Sivaram Gopalakrishnan 1 1 Department of Electrical and Computer Engineering, University of Utah, Salt Lake City, UT-84112. 2 Department of Mathematics and Statistics, Georgia State University, Atlanta, GA-30303
Outline Ø Overall Verification Problem • Our Focus: Equivalence Verification of Fixed-size Arithmetic Datapaths Ø Problem Modeling • Polynomial Functions over Finite Integer Rings Ø Limitations of Previous Work Ø Approach and Contributions • Canonical form for Polynomials over Finite Rings Ø Algorithm Design and Experimental Verification Runs Ø Results, Conclusions & Future Work
The Equivalence Verification Problem
Motivation Ø Quadratic filter design for polynomial signal processing Ø y = a 0. x 12 + a 1. x 1 + b 0. x 02 + b 1. x 0 + c. x 0. x 1
Fixed-Size (m) Data-path: Modeling Ø Control the datapath size: Fixed size bit-vectors (m) 16 -bit 8 -bit Ø * 32 -bit * 8 -bit * * Bit-vector of size m: integer values in 0, …, 2 m-1 Fixed-size (m) bit-vector arithmetic Polynomials reduced %2 m Algebra over the ring Z 2 m
Fixed-Size Data-path: Implementation Ø Signal Truncation • Keep lower order m-bits, ignore higher bits • f % 2 m ≡ g % 2 m Ø Fractional Arithmetic with rounding • Keep higher order m-bits, round lower order bits • f - f %2 m ≡ g - g%2 m 2 m 2 m Ø Saturation Arithmetic • Saturate at overflow • Used in image-processing applications
Example: Anti-Aliasing Function Ø F= 1 = 2√a 2 + b 2 2√x [Peymandoust et al, TCAD‘ 03] Ø coefficients a b Expand into Taylor series • F ≈ 1 x 6 – 9 x 5 + 115 x 4 64 32 64 – 75 x 3 + 279 x 2 – 81 x 16 64 32 + 85 64 Ø coefficients Scale coefficients; Implement as bit-vectors x = a 2 + b 2 x MAC DFF F
Example 1: Anti-Aliasing Function Ø F 1[15: 0], F 2[15: 0], x[15: 0] Ø F 1 = 156 x 6 + 62724 x 5 + 17968 x 4 + 18661 x 3 + 43593 x 2 + 40244 x +13281 Ø F 2 = 156 x 6 + 5380 x 5 + 1584 x 4 + 10469 x 3 + 27209 x 2 + 7456 x + 13281 Ø F 1 ≠ F 2 ; F 1[15: 0] = F 2[15: 0] Ø To Prove: F 1 % 216 ≡ F 2 % 216 • F 1 ≡ F 2 in Z 2 m[x 1, …, xd]
Previous Work: Function Representations Ø Boolean Representations (f: B → B): BDDs, ZBDDs etc. Ø Moment Diagrams (f: B → Z): BMDs, K*BMDs, HDDs etc. Ø Canonical DAGs for Polynomials (f: Z → Z) • Taylor Expansion Diagrams (TEDs) Ø Required: Representation for f: Z 2 m → Z 2 m Ø SAT, MILP, Word-level ATPG, … Ø Theorem-Proving (HOL), term-rewriting • Works when datapath size can be abstracted away
Previous Work: Symbolic Algebra Ø Symbolic Algebra Tools: Singular, Macaulay, Maple, Mathematica, Zen, Dagwood etc. • Polynomial representations: Sparse, Dense, Recursive, Straight-line programs, DAGs, etc. • Polynomial equivalence over R, Q, C, Zp • Unique Factorization Domains (UFDs) : Uniquely factorize into irreducibles • Match corresponding irreducibles to prove equivalence
Why is the Problem Difficult? Ø Z 2 m is a non-UFD • f = x 2 + 6 x in Z 8 can be factorized as f x+6 x+4 x+2 Ø Atypical approach required to prove equivalence
Proposed Solution Ø f (x 1, …, xd) % n ≡ g(x 1, …, xd) % n • Proving equivalence is NP-hard Ø Vanishing polynomials [ICCD ‘ 05] • f(x) – g(x) ≡ 0 % 2 m : Zero Equivalence • An instance of Ideal Membership Testing • Efficient solutions over fields (Groebner’s bases): Z 2 m[x 1, …, xd] ? Ø Canonical forms: Current focus • Unique representations for polyfunctions over Z 2 m • Equivalence by coefficient matching • Concepts from Hungerbuhler et al. [To appear J. Sm. Not. , ‘ 06 ]
Polyfunctions over Z 2 m Equivalence classes F 1 F 2 f G 1 G 2 g Z 2 m[x 1, …, xd] Ø Z 2 m Polynomials over Z 2 m[x 1, …, xd] • Represented by polyfunctions from Z 2 m[x 1, …, xd] to Z 2 m Ø F 1 % 2 m ≡ F 2 % 2 m => they have the same underlying polyfunction (f ) Ø Use equivalence classes of polynomials • Derive representative for each class: Canonical form
Motivating our Approach module fixed_bit_width (x, f, g); input [2: 0] x; output [2: 0] f, g; assign f[2: 0] = 5 x 2 + 6 x - 3; assign g[2: 0] = x 2 + 2 x + 5; Ø f (x) = 5 x 2 + 6 x - 3 = (x 2 + 2 x + 5) + (4 x 2 + 4 x) • f (x) = g(x) + V (x) in Z 23 Ø V (x) = 4 x 2 + 4 x ≡ 0 % 23 ; for x in {0, …, 7} • f (x) = g (x) + 0 in Z 23 Ø Required: To identify and eliminate such redundant (vanishing) sub-expressions
Vanishing polynomials: Requirement Set of all Vanishing polynomials h: % 2 m 0 f g Z 2 m[x 1, …, xd] Z 2 m Ø Generate vanishing expressions V(x) • Test if f (x) = g (x) + V(x) • f (x) = f (x) – V(x) Ø Challenge: Infinite number of vanishing polynomials Ø Required: To generate V(x) specific to given f (x)
Vanishing Polynomials for Reducibility Ø Ø In Z 23, say f (x) = 4 x 2 • f (x) = f (x) - V(x) • Generate V(x) of degree 2 • V(x) = 4 x 2 + 4 x ≡ 0 % 23 Reduce by subtraction: • 4 x 2 f (x) – 4 x 2 + 4 x V(x) = - 4 x % 8 = 4 x • 4 x 2 can be reduced to 4 x • Degree reduction
Coefficient Reduction: Example Ø Degree is not always reducible Ø In Z 23, f (x) = 6 x 2 • a=6 • k=2 Ø Divide and subtract • 6 x 2 = 2 x 2 + 4 x 2 % 23 • 4 x 2 can be reduced to 4 x Ø f (x) = 2 x 2 + 4 x : Lower Coefficient
Our Approach Ø Say f (x) = akxk + ak-1 xk-1 + …+ a 0 • In decreasing lexicographic order Ø Required: f (x) in reduced, minimal, unique form • Check if degree can be reduced • Check if coefficient can be reduced • Perform corresponding reductions • Repeat for all monomials …
Degree Reduction: Requirement Generate appropriate vanishing polynomial , V(x) Ø f (x) = axk + a 1 xk-1 + … V(x) = axk + a 2 xk-1 + … f (x) – V(x) = bxk-1 + … Ø Ø V(x): axk is the leading term Identify constraints on • Degree : k • Coefficient : a Use concepts from number theory
Results From Number Theory Ø n! divides a product of n consecutive numbers • 4! divides 99 X 100 X 101 X 102 Ø Find least n such that 2 m|n! • Smarandache Function (SF) of 2 m = n • SF(23) = 4, since 23|4! Ø 2 m divides the product of n = SF(2 m) consecutive numbers Ø Use SF(2 m) to generate vanishing polynomial V(x)
Results From Number Theory Ø V (x) ≡ 0 % 23 • 23| V (x) in Z 23 • 23| 4! , since SF(23) = 4 • 4! divides the product of 4 consecutive numbers Write V(x) as a product of SF(23) = 4 consecutive numbers Ø A polynomial as a product of 4 consecutive numbers? • (x+1)(x+2)(x+3)(x+4) = 4! x + 4 ≡ 0 % 23 4
Constraints on the Coefficient Ø In Z 23 , SF(23) = 4. Product of 4 consecutive numbers: • (x+1) (x+2) (x+3) (x+4) missing factors Ø V (x) = 4 x 2 + 4 x = 4 (x+1)(x+2) ≡ 0 % 23 compensated by constant Ø 4(x+1)(x+2) = 4· 2!· x + 2 2 Ø f (x) = axk + … Rule 1: If 2 m|ak!, then V(x) = ak! x + k ≡ 0 % 2 m k = axk + a 1 xk-1…. .
Example: Vanishing Polynomial Ø Consider f (x) = 4 x 2 in Z 23 • a=4 • k=2 • V (x) = ? Ø Rule 1: 2 m|a·k! => 23 | 4· 2! • V (x) = a·k! x + k = 4. 2! x + 2 = 4. 2! (x+2) (x+1) k 2 2! = 4 x 2 + 4 x ≡ 0 % 23 • f (x) = 4 x 2 V(x) = - 4 x 2 + 4 x = - 4 x % 8 = 4 x
Coefficient Reduction: Requirement Ø Define v 2(k!) = {max x Є N: 2 x| k!} • number-of-factors-2 in k! • v 2(4!) = v 2(4 * 3 * 2* 1) = 3 Ø Rule 1: 2 m| a·k! • Number-of-factors-2 in a·k! ≥ m or • v 2(a·k!) ≥ m Constraint Ø If 2 m does not divide a·k! • v 2(a·k!) < m • v 2(k!) < m and a < 2 m- v 2(k!) on degree Constraint on coefficient Rule 2: Coefficient (a) has to be in the range {0, …, 2 m- v 2(k!)-1}
Notation: Multivariate Polynomials Ø Given d variables x = <x 1, …, xd> with degrees k = <k 1, …, kd> Ø Replace in Rule 1 and Rule 2 • xk = ∏di=1 xiki • k! = ∏di=1 ki! • x = ∏di=1 xi k ki • v 2(k!) = ∏d v 2(ki!) Ø Use lexicographic term ordering for variables
Uniqueness Ø Theorem: Any polynomial F in Z 2 m can be uniquely written as F = Σ kЄNd αk xk Ø d is the number of variables Ø αk Є {0, …, 2 m- v 2(k!)-1} is the coefficient Ø v 2(k!) < m
Reduction Procedure Ø Given a monomial f (x) = a·xk Ø Degree reduction: Determine if 2 m| a·k! • If yes, generate V(x) of with a·xk as the leading term • f (x) = f (x) – V(x) Ø If 2 m| a·k!, check if coefficient (a) is in {0, …, 2 m- v 2(k!)-1} • If not, perform division according to a·xk = q. 2 m- v 2(k!)·xk + r·xk Degree reducible Reduced form r < 2 m- v 2(k!)
Example: Reduction Given poly = 6 x 2 y + 4 xy in Z 23 1. 2. Reducing 6 x 2 y Degree Reduction: • a = 6; • k! = kx!. ky! = 2!1! = 2 • 23 does not divide (a ·k! ) = 12; • Degree reduction not possible • Perform coefficient reduction
Example: Reduction Given poly = 6 x 2 y + 4 xy in Z 23 3. 4. Coefficient Reduction: • v 2(k!) = v 2(2!· 1!) = 1 • • Range = {0, …, 2 m- v (k!) – 1} = {0, …, 3} • 6 x 2 y = 4 x 2 y + 2 x 2 y • Degree reduction for 4 x 2 y: n Rule 1: 23 | (4· 2! · 1!) n 4 x 2 y – 4. 2!· 1! x + 2 y + 1 = 4 xy 2 1 2 a = 6 > 3; Can reduce coefficient poly = (4 xy + 2 x 2 y) + 4 xy ≡ 2 x 2 y in Z 23
Experimental Setup Ø Distinct RTL designs are input to GAUT [U. de LESTER, ‘ 04] Ø Extract data-flow graphs for RTL designs Ø Construct the corresponding polynomial representations (f, g) • Extract bit-vector size Ø Reduce f and g to canonical form • Equivalence check by coefficient matching Ø Algorithm implemented in MAPLE • Complexity: O(kd); where k is the total degree and d is the number of variables Ø Compare with BDD, BMD and SAT
Results
Conclusions & Future Work Ø Ø Ø Technique to verify equivalence of multivariate polynomial RTL computations Fixed-size bit-vector arithmetic is polynomial algebra over the finite integer ring, Z 2 m f (x 1, …, xd) % 2 m ≡ g (x 1, …, xd) % 2 m is proved by reduction to canonical form Ø Efficient algorithm to determine unique representations Ø Future Work involves extensions for - • Multiple Word-length Implementations [DATE ‘ 06] • Verification of Rounding and Saturation Arithmetic
Questions?
Comparison
- Slides: 34