Title: Verification
1Verification Synthesis of Arithmetic Datapaths
using Finite Ring Algebra
- Priyank Kalla
- Electrical and Computer Engineering
- University of Utah
- Salt Lake City, UT-84112
2Research Group Members
- Graduate Students
- Namrata Shekhar PhD
- RTL Verification of Arithmetic Datapaths
- Sivaram Gopalakrishnan PhD
- RTL Synthesis of Arithmetic Datapaths
- Vijay Durairaj PhD Chris Condrat BS/MS
- SAT SAT-based Decision Procedures
- Collaborators
- Prof. Florian Enescu Brandon
- Mathematics Statistics, Georgia State Univ.
3Outline
- Introducing the Problems
- Equivalence Verification High-Level Synthesis
- Applications Fixed Point Arithmetic, Polynomial
Signal Processing, Audio/Video/Multimedia DSP - Modeling Poly-Functions over Finite Integer
Rings - Previous Work CAD Symbolic Computer Algebra
- Contributions
- Vanishing Polynomials, Canonical Forms for
Verification - Polynomial Reduction Decomposition for
Synthesis - Algorithm Design Experimental Results
- Open Problems Challenges CAD Algebra
4The Verification Synthesis Problems
5Polynomials over Bit-Vectors?
- Quadratic filter design for polynomial signal
processing - y a0 . x12 a1 . x1 b0 . x02 b1 . x0 c
. x0 . x1
6Bit-Vector Arithmetic 2m Algebra
- Represent integers as a vector of bits
- Bit x0 represents values 0 or 1
- Vector X10 x1, x0 represents integers
- 00, 01, 10, 11 (4 values from 0 to 3)
- Bit-vector of size m integer values in 0,, 2m-1
- Vector Xm-1 0 represents integers reduced
2m
2-bit
2-bit
3-bit
4-bit
2-bit
2-bit
ADDER
MULTIPLIER
7Fixed-Size (m) Data-path Modeling
- Control the datapath size Fixed size bit-vectors
(m)
16-bit
16-bit
16-bit
16-bit
- Bit-vector of size m integer values in 0,, 2m-1
8Fixed-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 - g2m
- 2m 2m
- Saturation Arithmetic
- Saturate at overflow
- If( x70 gt 255 ) then x70 255
- Used in image-processing applications
9Example Anti-Aliasing Function
- F 1 1
- 2va2 b2 2vx
- Peymandoust et al, TCAD03
- 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
coefficients
coefficients
a
b
x a2 b2
x
MAC
F
10Example Anti-Aliasing Function
- F1150, F2150, x150
- F1 156x6 62724x5 17968x4 18661x3 43593
x2 - 40244x 13281
- F2 156x6 5380x5 1584x4 10469x3 27209
x2 7456x - 13281
- F1 ? F2 F1150 F2150 F1 216 F2
216 - Transform the problem
- F1 - F2 57344x5 16384x4 8192x3 16384x2
32768x - 0 216
- F1 - F2 Vanishing polynomial
11Multiple Word-Length Operands
- Bit-vector operands with different word-lengths
- Input variables x1,, xd Output variables
f, g - Input bit-widths n1,, nd Output width
m -
- Model as polynomial function
12Example Digital Image Rejection Unit
input A110, B70 output Y1150, Y2150
- Y1 ? Y2
- Y1150 Y2150
- Y1 216 Y2 216
13Previous Work Function Representations
- Boolean Representations (f B ? B)
- BDDs, MTBDDs, ADDs etc.
- Moment Diagrams (f B ? Z)
- BMDs, KBMDs, HDDs etc.
- Canonical DAGs for Polynomials (f Z ? Z)
- Taylor Expansion Diagrams (TEDs)
- Required Representation for f Z2m ? Z2m
14Previous Work Others
- SAT and MILP-based techniques
- Suitable for linear/multi-linear forms
- Word-level ATPG, congruence closure, co-operative
decision procedures - Solve linear congruences under modulo arithmetic
- Theorem-Proving (HOL), term-rewriting
- Abstract away the data-path size using data
independence, symmetry, other abstractions - Here, datapath size (m) defines ring cardinality
(Z2m)
15Previous Work Symbolic Algebra
- Galois Field Decomposition of Boolean Functions
GF(2m) Pradhan, 1978 recent work - Symbolic Algebra Tools Singular, Macaulay,
Maple, Mathematica, ZEN, NTL, CoCoA - Polynomial equivalence over R, Q, C, Zp
- Unique Factorization Domains (UFDs) Uniquely
factorize into irreducibles - Match corresponding coefficients to prove
equivalence
16Symbolic Algebra in CAD
- MODD DAG representation of polynomials over
GF(2m) Pradhan, IWLS 05, DATE 04 - Guiding Synthesis engines using Groebners basis
De Micheli, TCAD 02 - Given polynomial F and Library elements ltI1, ,
Ingt - F h1 I1 hn In
- Again, works over UFDs
- Approximate RTL as polynomials over Reals
- Theorem Proving Clarke et al.
- HOL Mathematica Analytica
17Why is the Problem Difficult?
- Z2m is a non-UFD
- f x2 6x in Z8 can be factorized as
f
f
x
x6
x2
x4
- Atypical approach required to prove equivalence
18Problem Formulations Solutions
- f (x1, , xd) n g(x1, , xd) n
- Proving equivalence is NP-hard Ibarra, J. ACM
83 - Vanishing polynomials ICCD 05, DATE06
- f(x) g(x) 0 2m Zero Equivalence
- An instance of Ideal Membership Testing
- Efficient solutions over fields (Groebners
bases) Z2mx1,, xd ? - Canonical forms ICCAD 05
- Unique representations for polyfunctions over Z2m
- Equivalence by coefficient matching
- Concepts from Hungerbuhler et al. J. Sm. Not.,
06
19Ideal Membership Testing
Z2m
Z2mx1, , xd
- ( f g ) 2m 0 or ( f g ) vanishes 2m
- Membership in the Ideal of all Vanishing
Polynomials in Z2m - Grobner's basis? Buchberger's algorithm?
- Generate the Ideal!
20Ideal Membership Testing in Zp
- Fermats Little Theorem
- x p x (mod p) or
- x p x 0 (mod p)
- x p x generates the vanishing ideal in Zpx
- f(x) 0 p iff f(x) (xp-x)g(x)
- Zp Principal Ideal Domain
- This does not follow in Z2m
- Generalize the result from
- p to pm to (any integer) n
21Ideal Membership Testing
0
Q
P
- Generate the ideal of vanishing polynomials 2m
? - Vanishing Ideal is finitely generated
- Niven et al, Am. Math. Soc., 57
- Need an algorithm for membership testing
- Representative expression for members of this
ideal - Singmaster, J. Num. Th 74
22Results From Number Theory
- (f-g) 2m 0 means that 2m (f-g)
- n! divides a product of n consecutive numbers.
- 4! divides 99 X 100 X 101 X 102
- Find least n such that 2mn!
- Smarandache Function (SF).
- SF(23) 4, since 234!
- 2m divides the product of n SF(2m) consecutive
numbers
23Results From Number Theory
- f g in Z23 or (f - g) 0 23
- 23(f - g) in Z23
- 234!
- 4! divides the product of 4 consecutive numbers
Write (f-g) as a product of SF(23) 4
consecutive numbers
- A polynomial as a product of 4 consecutive
numbers? - (x1)
24Results From Number Theory
- f g in Z23 or (f - g) 0 23
- 23(f - g) in Z23
- 234!
- 4! divides the product of 4 consecutive numbers
Write (f-g) as a product of SF(23) 4
consecutive numbers
- A polynomial as a product of 4 consecutive
numbers? - (x1)(x2)
25Results From Number Theory
- f g in Z23 or (f - g) 0 23
- 23(f - g) in Z23
- 234!
- 4! divides the product of 4 consecutive numbers
Write (f-g) as a product of SF(23) 4
consecutive numbers
- A polynomial as a product of 4 consecutive
numbers? - (x1)(x2)(x3)
26Results From Number Theory
- f g in Z23 or (f - g) 0 23
- 23(f - g) in Z23
- 234!
- 4! divides the product of 4 consecutive numbers
Write (f-g) as a product of SF(23) 4
consecutive numbers
- A polynomial as a product of 4 consecutive
numbers? - (x1)(x2)(x3)(x4)
27Basis for factorization
- S0(x) 1
- S1(x) (x 1)
- S2(x) (x 1)(x 2) Product of 2
consecutive numbers - S3(x) (x 1)(x 2)(x 3) Product of 3
consecutive numbers
-
-
- Sn(x) (x n) Sn-1(x) Product of n
consecutive numbers
Rule 1 Factorize into atleast Sn(x) to vanish,
where n SF(2m).
28Example Vanishing polynomial
- 4th degree polynomial p in Z23 SF(23) 4
- p x4 2x3 3x2 2x
- p can be written as a product of 4 consecutive
numbers. - or p (x1)(x2)(x3)(x4) S4(x) in Z23.
- p is a vanishing polynomial.
29Example Vanishing polynomial
- module fixed_bit_width (x, f, g)
- input 20 x
- output 20 f, g
- assign f20 x2 6x 3
- assign g20 5x2 2x 5
- h(x) f(x) g(x) 4x2 4x
- h(x) 0 for all values of x in 0,,7
- 4x24x not equal to (x1)(x2)(x3)(x4)
- Required To show that h(x) is a vanishing
polynomial in Z23
30Constraints on the Coefficient
- h(x) 4x2 4x 4(x1)(x2)
- In Z23 , SF(23) 4. Product of 4 consecutive
numbers - S4(x) (x1) (x2) (x3) (x4)
-
Rule 2 Coefficient has to be a multiple of bk
2m/gcd(k!, 2m)
- Here, Coefficient of h(x) 4, Degree of h(x)
2 - b2 23/gcd(2!, 23) 4 is a multiple of the
coefficient
31Constraints on the Coefficient
- h(x) 4x2 4x 4(x1)(x2)
- compensated by constant
- In Z23 , SF(23) 4. Product of 4 consecutive
numbers - S4(x) (x1) (x2) (x3) (x4)
- missing factors
Rule 2 Coefficient has to be a multiple of bk
2m/gcd(k!, 2m)
- Here, Coefficient of h(x) 4, Degree of h(x)
k 2 - b2 23/gcd(2!, 23) 4 is a multiple of the
coefficient
32Deciding Vanishing Polynomials
- Polynomial F in Z2m vanishes if
- F FnSn S n-1ak bk Sk
- k0
- Rule 1 Rule 2
- n SF(2m), i.e. the least n such that 2mn!
- Fn is an arbitrary polynomial in Z2mx
- ak is an arbitrary integer
- bk 2m/gcd(k!,2m)
33Algorithm
Example 1
F FnSn S n-1ak bk Sk k0
- Input poly, 2m
- Calculate n SF(2m)
- k n Reduce according to Rule 1
- Divide by Sn
- If remainder is zero, F FnSn, else Continue
- poly 4x2 4x in Z23
- n SF(23) 4
- k 4 Divide by S4
- Degree (poly) 2
- lt degree(S4) 4
- quo 0, rem 4x2 4x
- F4 0 Continue
34Algorithm
Example 1
F FnSn S n-1ak bk Sk k0
- Input poly, 2m
- Calculate n SF(2m)
- k n Reduce according to Rule 1
- Divide by Sn
- If remainder is zero, F FnSn, else Continue
- poly 4x2 4x in Z23
- n SF(23) 4
- k 4 Divide by S4
- Degree (poly) 2
- lt degree(S4) 4
- quo 0, rem 4x2 4x
- F4 0 Continue
35Algorithm
Example 1
F FnSn S n-1ak bk Sk k0
- Reduce according to Rule 2. Divide by Sn-1 to S0
- Check if quotient is a multiple of
- bk 2m/gcd(k!,2m)
- If remainder is zero, stop. Else, continue
- k 3 Divide by S3
- degree (poly) 2 lt degree(S3) 3
- quo 0, rem 4x2 4x continue
- k 2 Divide by S2
- quo 4 rem 0
- b2 23/gcd(2!,23) 4
- a2 quo/ b2 1 ? Z
poly a2.b2.S2 1.4.(x1)(x2) 0 in Z23
36Algorithm
Example 1
F FnSn S n-1ak bk Sk k0
- Reduce according to Rule 2. Divide by Sn-1 to S0
- Check if quotient is a multiple of
- bk 2m/gcd(k!,2m)
- If remainder is zero, stop. Else, continue
- k 3 Divide by S3
- degree (poly) 2 lt degree(S3) 3
- quo 0, rem 4x2 4x continue
- k 2 Divide by S2
- quo 4 rem 0
- b2 23/gcd(2!,23) 4
- a2 quo/ b2 1 ? Z
poly a2.b2.S2 1.4.(x1)(x2) 0 in Z23
37Example 2
- poly 5x2 3x 7 in Z23
- n SF(23) 4
- degree (poly) 2 lt n. Skip Rule 1, try Rule 2
- Divide by S2
- quo 5 rem 5 4x
- b2 23/gcd(2!,23) 4
- a2 quo/ b2 5/4 is not in Z
- poly does not satisfy Rule 2
- poly is not a vanishing polynomial in Z23
38Status of our Work - Extensions
- Multiple Variables Z2mx1, , xd
- Given polynomials (f, g) d variables
- x ltx1, , xdgt over Z2m
- Prove that (f-g) 0 2m
- What if word-lengths are different too?
- x1 ? Z2n1 , , xd ? Z2nd
- No problems!
- Straight-forward extensions of previous concepts
- Other approach Canonical forms of poly-functions
39Polyfunctions over Z2m
f
F2
g
G2
Z2mx1, , xd
Z2m
- Polynomials over Z2mx1, , xd
- Represented by polyfunctions from Z2mx1, , xd
to Z2m - F1 2m F2 2m gt they have the same
underlying polyfunction (f ) - Use equivalence classes of polynomials
- Derive representative for each class Canonical
form
40Motivating our Approach
- module fixed_bit_width (x, f, g)
- input 20 x
- output 20 f, g
- assign f20 5x2 6x - 3
- assign g20 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)
41Vanishing 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
42Degree 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
If 2mak!, then V(x) ak! x k 0 2m
k
axk a1xk-1..
43Coefficient Reduction Example
- Degree is not always reducible
- In Z23, f (x) 6x2
- a 6, k 2
- 8 does not divide 6 2!
- Divide and subtract
- 6x2 2x2 4x2 23
- 4x2 can be reduced to 4x
- f (x) 2x2 4x Lower Coefficient
44Our 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
45Experimental Setup
- Distinct RTL designs are input to GAUT U. de
LESTER - Extract data-flow graphs for RTL designs
- Construct the corresponding polynomial
representations (f, g) - Extract bit-vector size
- Find the difference (f-g) and invoke the
zero-testing algorithm - Reduce f, g to canonical forms.
- Algorithm implemented in MAPLE
- Compare with BMD, SAT and MILP
- Complexity O(kd)
46Results
47Limitations Mathematics versus CAD
- Finite Ring Algebra Cannot DIVIDE!
- Right shift breaks the model
- Overflow arithmetic versus Saturation
- Comparators non-polynomial?
- Internal bit-vectors of arbitrary word-lengths
- Only Yes/No Equivalence? Find bugs too!
- Couple Verification with Simulation!
- Arithmetic interfaced with Boolean
48Intermediate Signal Truncation
a70
b70
c70
a70
b70
c70
?
t170
t270
f180
f280
a 127 b 1 f1 383 c 255
a 127 b 1 f2 127 c 255
49Proposed Solution
a70
b70
c70
a70
b70
c70
?
t170
t270
f180
f280
- Required Algorithm for reduction to canonical
form over
50Polynomial Abstraction from RTL
- If (x gt 2b10)
- then y x x x
- Else y xx
- Traditional modeling
- .
- Proposed modeling y as a polyfunction from
- Unique
representation - Issues with the proposed abstraction
- Scalability
51Verification via Simulation?
52 Simulation Vector Generation
- Prove f g over Z8 via Simulation
- How many vectors to Simulate? Exhaustive
Simulation? - NO! Simulate only n SF(23) 4 CONSECUTIVE
vectors
- f x4 x2 (specification)
- x0, f0
- x1, f2
- x2, f4
- x3, f2
- x4, f0
- x5, f2
- x6, f4
- x7, f2
- g 2x2 (implementation)
- x0, g0
- x1, g2
- x2, g0
- x3, g2
- x4, g0
- x5, g2
- x6, g0
- x7, g2
53Applications to Synthesis
- Datapath size (m) 8 bits
- SF(28) 10
- Polynomial can be
- factorized into S10(x)
- F70 (x1)(x2)...(x10)
54Polynomial Decomposition
- F 8xy2 11y3 9y2 1
- X, Y 30 are 4-bit vectors (16)
- Synthesize Area 320
- U 8x 3y
- F U3 U2 1
- Synthesize Area 18120 201
55Conclusions
- Finite Word-Length Bit-Vector Arithmetic is
Finite Ring Algebra - Computations reduced integer power of 2
- NON-UFDs! Number Theory, Commutative Algebra
- Mathematicians should help us here.
- Techniques to verify equivalence of polynomial
RTL computations - f(x) 2m g(x) 2m is transformed into f(x) -
g(x) 0 2m - Ideal Membership Testing, Canonical Forms.
- Tremendous scope in high-level synthesis.
56Questions?