equivalence verification of polynomial datapaths with fixed-size bit-vectors using finite ring...

34
Equivalence Verification of Polynomial Equivalence Verification of Polynomial Datapaths with Fixed-Size Bit-Vectors Datapaths with Fixed-Size Bit-Vectors using Finite Ring Algebra using Finite Ring Algebra Namrata Shekhar Namrata Shekhar 1 , Priyank Kalla , Priyank Kalla 1 , Florian , Florian Enescu Enescu 2 , , Sivaram Gopalakrishnan 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

Post on 21-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Equivalence Verification of Polynomial Equivalence Verification of Polynomial Datapaths with Fixed-Size Bit-Vectors using Datapaths with Fixed-Size Bit-Vectors using

Finite Ring AlgebraFinite Ring Algebra

Namrata ShekharNamrata Shekhar1, Priyank Kalla, Priyank Kalla1, Florian Enescu, Florian Enescu2, ,

Sivaram GopalakrishnanSivaram Gopalakrishnan1

1Department of Electrical and Computer Engineering,University of Utah, Salt Lake City, UT-84112.

2Department of Mathematics and Statistics,Georgia State University, Atlanta, GA-30303

OutlineOutline Overall Verification ProblemOverall Verification Problem

• Our Focus: Equivalence Verification of Fixed-size Our Focus: Equivalence Verification of Fixed-size Arithmetic DatapathsArithmetic Datapaths

Problem ModelingProblem Modeling

• Polynomial Functions over Finite Integer RingsPolynomial Functions over Finite Integer Rings

Limitations of Previous WorkLimitations of Previous Work Approach and ContributionsApproach and Contributions

• Canonical form for Polynomials over Finite RingsCanonical form for Polynomials over Finite Rings

Algorithm Design and Experimental Verification RunsAlgorithm Design and Experimental Verification Runs Results, Conclusions & Future WorkResults, Conclusions & Future Work

The Equivalence Verification ProblemThe Equivalence Verification Problem

MotivationMotivation

Quadratic filter design for polynomial signal processing

y = a0 . x12 + a1 . x1 + b0 . x0

2 + b1 . x0 + c . x0 . x1

Fixed-Size (m) Data-path: ModelingFixed-Size (m) Data-path: Modeling

Control the datapath size: Fixed size bit-vectors (m)

* *

8-bit

8-bit

16-bit32-bit

* *

8-bit

8-bit

8-bit8-bit

Bit-vector of size m: integer values in 0,…, 2m-1

Fixed-size (m) bit-vector

arithmetic

Polynomials reduced %2m

Algebra over the ring Z2m

Fixed-Size Data-path: ImplementationFixed-Size Data-path: Implementation

Signal Truncation

• Keep lower order m-bits, ignore higher bits

• f % 2m ≡ g % 2m

Fractional Arithmetic with rounding

• Keep higher order m-bits, round lower order bits

• f - f %2m ≡ g - g%2m

2m 2m

Saturation Arithmetic• Saturate at overflow

• Used in image-processing applications

Example: Anti-Aliasing FunctionExample: Anti-Aliasing Function

F = 1 = 1 = 2√a2 + b2 2√x [Peymandoust et al, TCAD‘03]

Expand into Taylor series

• F ≈ 1 x6 – 9 x5 + 115 x4

64 32 64 – 75 x3 + 279 x2 – 81 x

16 64 32 + 85 64

Scale coefficients; Implement

as bit-vectors

MAC

x = a2 + b2

coefficients coefficients

a b

x

F

DFF

Example 1: Anti-Aliasing FunctionExample 1: Anti-Aliasing Function

F1[15:0], F2[15:0], x[15:0]

F1 = 156x6 + 62724x5 + 17968x4 + 18661x3 + 43593 x2

+ 40244x +13281

F2 = 156x6 + 5380x5 + 1584x4 + 10469x3 + 27209 x2 + 7456x

+ 13281

F1 ≠ F2 ; F1[15:0] = F2[15:0]

To Prove: F1 % 216 ≡ F2 % 216

• F1 ≡ F2 in Z2m[x1, …, xd]

Previous Work: Function RepresentationsPrevious 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: Z2m → Z2m

SAT, MILP, Word-level ATPG, …

Theorem-Proving (HOL), term-rewriting

• Works when datapath size can be abstracted away

Previous Work: Symbolic AlgebraPrevious 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?Why is the Problem Difficult?

Z2m is a non-UFD

• f = x2 + 6x in Z8 can be factorized as

Atypical approach required to prove equivalence

f

x+6

f

x+4 x+2x

Proposed SolutionProposed Solution

f (x1, …, xd) % n ≡ g(x1, …, xd) % n

• Proving equivalence is NP-hard

Vanishing polynomials [ICCD ‘05]

• f(x) – g(x) ≡ 0 % 2m : Zero Equivalence

• An instance of Ideal Membership Testing

• Efficient solutions over fields (Groebner’s bases): Z2m[x1,…, xd] ?

Canonical forms: Current focus

• Unique representations for polyfunctions over Z2m

• Equivalence by coefficient matching

• Concepts from Hungerbuhler et al. [To appear J. Sm. Not., ‘06 ]

Polyfunctions over Polyfunctions over ZZ22mm

Polynomials over Z2m[x1, …, xd]

• Represented by polyfunctions from Z2m[x1, …, xd] to Z2m

F1 % 2m ≡ F2 % 2m => they have the same underlying polyfunction (f )

Use equivalence classes of polynomials

• Derive representative for each class: Canonical form

f

g

Equivalence classes

Z2m[x1, …, xd] Z2m

F2

F1

G2

G1

Motivating our ApproachMotivating our Approachmodule fixed_bit_width (x, f, g);

input [2:0] x;

output [2:0] f, g;

assign f[2:0] = 5x2 + 6x - 3;

assign g[2:0] = x2 + 2x + 5;

f (x) = 5x2 + 6x - 3 = (x2 + 2x + 5) + (4x2 + 4x) • f (x) = g(x) + V (x) in Z23

V (x) = 4x2 + 4x ≡ 0 % 23 ; for x in {0,…,7}• f (x) = g (x) + 0 in Z23

Required: To identify and eliminate such redundant sub-expressions(vanishing)

Vanishing polynomials: RequirementVanishing polynomials: Requirement

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)

Z2m

Set of all Vanishing

polynomials

f

g

Z2m[x1, …, xd]

0

h: % 2m

Vanishing Polynomials for ReducibilityVanishing Polynomials for Reducibility

In Z23, say f (x) = 4x2

• f (x) = f (x) - V(x)

• Generate V(x) of degree 2

• V(x) = 4x2 + 4x ≡ 0 % 23

Reduce by subtraction: • 4x2 f (x)

– 4x2 + 4x V(x)= - 4x = - 4x % 8 = 4x

• 4x2 can be reduced to 4x

• Degree reduction

Coefficient Reduction: ExampleCoefficient Reduction: Example

Degree is not always reducible

In Z23, f (x) = 6x2

• a = 6

• k = 2

Divide and subtract

• 6x2 = 2x2 + 4x2 % 23

• 4x2 can be reduced to 4x f (x) = 2x2 + 4x : Lower Coefficient

Our ApproachOur Approach

Say f (x) = akxk + ak-1xk-1 + …+ a0

• 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: RequirementDegree Reduction: Requirement Generate appropriate vanishing polynomial , V(x) f (x) = axk + a1xk-1 + …

V(x) = axk + a2xk-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 TheoryResults 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 2m|n!

• Smarandache Function (SF) of 2m = n

• SF(23) = 4, since 23|4!

2m divides the product of n = SF(2m) consecutive numbers

Use SF(2m) to generate vanishing polynomial V(x)

Results From Number TheoryResults From Number Theory

V (x) ≡ 0 % 23

• 23| V (x) in Z23

• 23| 4! , since SF(23) = 4

• 4! divides the product of 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

Write V(x) as a product of SF(23) = 4 consecutive numbers

Constraints on the CoefficientConstraints on the Coefficient

In Z23 , SF(23) = 4. Product of 4 consecutive numbers:

• (x+1) (x+2)

missing factors

V (x) = 4x2 + 4x = (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 2m|ak!, then V(x) = ak! x + k ≡ 0 % 2m k

= axk + a1xk-1…..

(x+3) (x+4)

4

Example: Vanishing PolynomialExample: Vanishing Polynomial

Consider f (x) = 4x2 in Z23

• a = 4

• k = 2

• V (x) = ?

Rule 1: 2m|a·k! => 23 | 4·2!

• V (x) = a·k! x + k = 4. 2! x + 2 = 4. 2! (x+2) (x+1) k 2 2!

= 4x2 + 4x ≡ 0 % 23

• f (x) = 4x2

V(x) = - 4x2 + 4x = - 4x = - 4x % 8 = 4x

Coefficient Reduction: RequirementCoefficient Reduction: Requirement

Define v2(k!) = {max x Є N: 2x| k!}

• number-of-factors-2 in k!

• v2(4!) = v2(4 * 3 * 2* 1) = 3

Rule 1: 2m| a·k!• Number-of-factors-2 in a·k! ≥ m or

• v2(a·k!) ≥ m

If 2m does not divide a·k!

• v2(a·k!) < m

• v2(k!) < m and a < 2m- v2(k!)

Rule 2: Coefficient (a) has to be in the range {0, …, 2m- v2(k!)-1}

Constraint on coefficient

Constraint on degree

Notation: Multivariate PolynomialsNotation: Multivariate Polynomials

Given d variables x = <x1, …, xd>

with degrees k = <k1, …, kd>

Replace in Rule 1 and Rule 2

• xk = ∏di=1 xi

ki

• k! = ∏di=1

ki!

• x = ∏di=1 xi

k ki

• v2(k!) = ∏d v2(ki!)

Use lexicographic term ordering for variables

UniquenessUniqueness

Theorem: Any polynomial F in Z2m can be uniquely

written as

F = F = ΣΣ kkЄЄNNd d ααk k xxkk

d is the number of variables

αk Є {0, …, 2m- v2(k!)-1} is the coefficient

v2(k!) < m

Reduction ProcedureReduction Procedure

Given a monomial f (x) = a·xk

Degree reduction: Determine if 2m| a·k!

• If yes, generate V(x) of with a·xk as the leading term

• f (x) = f (x) – V(x) If 2m| a·k!, check if coefficient (a) is in {0, …, 2m- v2(k!)-1}

• If not, perform division according to

a·xk = q. 2m- v2(k!)·xk + r·xk

Degree reducible Reduced form

r < 2m- v2(k!)

1. Reducing 6x2y

2. 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: ReductionExample: Reduction

Given poly = 6x2y + 4xy in Z23

3. Coefficient Reduction:• v2(k!) = v2(2!·1!) = 1

• Range = {0, …, 2m- v2(k!) – 1} = {0,…, 3}

• a = 6 > 3; Can reduce coefficient

• 6x2y = 4x2y + 2x2y

• Degree reduction for 4x2y: Rule 1: 23 | (4· 2! ·1!) 4x2y – 4 . 2!·1! x + 2 y + 1 = 4xy

2 1

4. poly = (4xy + 2x2y) + 4xy ≡ 2x2y in Z23

Example: ReductionExample: Reduction

Given poly = 6x2y + 4xy in Z23

Experimental SetupExperimental 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

ResultsResults

1

10

100

1000

PSK

Anti-Alia

s Funct

ion

Cubic F

ilter

Degre

e-4

Filter

Savitz

y-Gola

y Filt

er

MIB

ENCH

Horner

Poly

1

Horner

Poly

2

Horner

Poly

3

Poly U

nopt.

Vanis

hing P

oly.

Our Approach (< 30 s)

BDD-VIS

BMD

SAT-Zchaff

Conclusions & Future WorkConclusions & Future Work

Technique to verify equivalence of multivariate polynomial RTL

computations Fixed-size bit-vector arithmetic is polynomial algebra over the finite

integer ring, Z2m

f (x1,…, xd) % 2m ≡ g (x1, …, xd) % 2m 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?Questions?

ComparisonComparison

1

10

100

Anti-Alia

s Funct

ion

Horner

Poly

1

Horner

Poly

2

Horner

Poly

3

Poly U

nopt.

Vanis

hing P

oly.

Our Approach (< 30 s)

Approach 2