Download presentation
Presentation is loading. Please wait.
Published byNicholas Gibbs Modified over 9 years ago
1
Verification & Synthesis of Arithmetic Datapaths using Finite Ring Algebra Priyank Kalla Priyank Kalla Electrical and Computer Engineering University of Utah Salt Lake City, UT-84112
2
Research Group Members Graduate Students : Namrata Shekhar – PhDNamrata Shekhar – PhD RTL Verification of Arithmetic Datapaths Sivaram Gopalakrishnan – PhDSivaram Gopalakrishnan – PhD RTL Synthesis of Arithmetic Datapaths Vijay Durairaj – PhD + Chris Condrat – BS/MSVijay Durairaj – PhD + Chris Condrat – BS/MS SAT & SAT-based Decision Procedures Collaborators: Prof. Florian Enescu + BrandonProf. Florian Enescu + Brandon Mathematics & Statistics, Georgia State Univ.
3
Outline Introducing the Problems Equivalence Verification & High-Level SynthesisEquivalence Verification & High-Level Synthesis Applications: Fixed Point Arithmetic, Polynomial Signal Processing, Audio/Video/Multimedia DSPApplications: 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 VerificationVanishing Polynomials, Canonical Forms for Verification Polynomial Reduction + Decomposition for SynthesisPolynomial Reduction + Decomposition for Synthesis Algorithm Design & Experimental Results Open Problems & Challenges : CAD + Algebra
4
The Verification & Synthesis Problems
5
Polynomials over Bit-Vectors? Quadratic filter design for polynomial signal processing y = a 0. x 1 2 + a 1. x 1 + b 0. x 0 2 + b 1. x 0 + c. x 0. x 1
6
Bit-Vector Arithmetic = %2 m Algebra Represent integers as a vector of bits Bit x 0 represents values 0 or 1 Vector X[1:0] = {x 1, x 0 } represents integers 00, 01, 10, 11 (4 values from 0 to 3) Bit-vector of size m : integer values in 0,…, 2 m -1 Vector X[m-1 : 0] represents integers reduced % 2 m + 2-bit 3-bit * 2-bit 4-bit ADDER MULTIPLIER
7
Fixed-Size (m) Data-path: Modeling Control the datapath size: Fixed size bit-vectors ( m ) * * 8-bit 16-bit 32-bit * * 16-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
8
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 If( x[7:0] > 255 ) then x[7:0] = 255; Used in image-processing applications
9
Example: Anti-Aliasing Function F = 1 = 1 = 2√a 2 + b 2 2√x [ Peymandoust et al, TCAD‘03 ] 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 Scale coefficients; Implement as bit-vectors MAC x = a 2 + b 2 coefficients ab x F DFF
10
Example: Anti-Aliasing Function F 1 [15:0], F 2 [15:0], x[15:0] F 1 = 156x 6 + 62724x 5 + 17968x 4 + 18661x 3 + 43593 x 2 + 40244x +13281 F 2 = 156x 6 + 5380x 5 + 1584x 4 + 10469x 3 + 27209 x 2 + 7456x + 13281 F 1 ≠ F 2 ; F 1 [15:0] = F 2 [15:0]; F 1 % 2 16 = F 2 % 2 16 Transform the problem F 1 - F 2 = 57344x 5 + 16384x 4 + 8192x 3 + 16384x 2 + 32768x ≡ 0 % 2 16 F 1 - F 2 : Vanishing polynomial
11
Multiple Word-Length Operands Bit-vector operands with different word-lengths Bit-vector operands with different word-lengths Input variables : {x 1,…, x d } Output variables : f, g Input variables : {x 1,…, x d } Output variables : f, g Input bit-widths: {n 1,…, n d } Output width : m Input bit-widths: {n 1,…, n d } Output width : m Model as polynomial function Model as polynomial function * * 8-bit 12-bit 20-bit 32-bit
12
Example: Digital Image Rejection Unit Y 1 ≠ Y 2 Y 1 ≠ Y 2 Y 1 [15:0] = Y 2 [15:0]Y 1 [15:0] = Y 2 [15:0] Y 1 % 2 16 ≡ Y 2 % 2 16Y 1 % 2 16 ≡ Y 2 % 2 16 input A[11:0], B[7:0]; output Y 1 [15:0], Y 2 [15:0];
13
Previous Work: Function Representations Boolean Representations ( f: B → B ) BDDs, MTBDDs, ADDs 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
14
Previous 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 ( Z 2 m )
15
Previous Work: Symbolic Algebra Galois Field Decomposition of Boolean Functions: GF(2 m ) [Pradhan, 1978 + recent work] Symbolic Algebra Tools : Singular, Macaulay, Maple, Mathematica, ZEN, NTL, CoCoA Polynomial equivalence over R, Q, C, Z p Unique Factorization Domains (UFDs) : Uniquely factorize into irreducibles Match corresponding coefficients to prove equivalence
16
Symbolic Algebra in CAD MODD: DAG representation of polynomials over GF(2 m ) [Pradhan, IWLS 05, DATE 04] Guiding Synthesis engines using Groebner’s basis [De Micheli, TCAD 02] Given polynomial F and Library elements F = h 1 I 1 + …… + h n I n Again, works over UFDs Approximate RTL as polynomials over Reals Theorem Proving [Clarke et al.] HOL + Mathematica = Analytica
17
Why is the Problem Difficult? Z 2 m is a non-UFD f = x 2 + 6x in Z 8 can be factorized as Atypical approach required to prove equivalence f xx+6 f x+2x+4
18
Problem Formulations + Solutions f (x 1, …, x d ) % n ≡ g(x 1, …, x d ) % n Proving equivalence is NP-hard [Ibarra, J. ACM ’83] Vanishing polynomials [ICCD ’05, DATE’06] 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,…, x d ] ? Canonical forms [ICCAD ’05] Unique representations for polyfunctions over Z 2 m Equivalence by coefficient matching Concepts from Hungerbuhler et al. [J. Sm. Not., ‘06 ]
19
Ideal Membership Testing ( f – g ) % 2 m = 0 or ( f – g ) vanishes % 2 m Membership in the Ideal of all Vanishing Polynomials in Z 2 m Grobner's basis? Buchberger's algorithm? Generate the Ideal! Z 2 m [x 1, …, x d ] Z2mZ2m Ideal x x % 2 m h: % 2 m 0 f g f – g ?
20
Ideal Membership Testing in Z p Fermat’s Little Theorem: x p ≡ x (mod p) or x p – x ≡ 0 (mod p) x p –x generates the vanishing ideal in Z p [x] f(x) = 0 % p iff f(x) = (x p -x)g(x) Z p : Principal Ideal Domain This does not follow in Z 2 m Generalize the result from: %p to %p m to % (any integer) n
21
Ideal Membership Testing Generate the ideal of vanishing polynomials % 2 m ? 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] P Q Ideal x x % 2 m h: % 2 m 0 f g f – g ?
22
Results From Number Theory (f-g) % 2 m = 0 means that 2 m | (f-g) 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). SF(2 3 ) = 4, since 2 3 |4! 2 m divides the product of n = SF(2 m ) consecutive numbers
23
Results From Number Theory f ≡ g in Z 2 3 or (f - g) ≡ 0 % 2 3 2 3 |(f - g) in Z 2 3 2 3 |4! 4! divides the product of 4 consecutive numbers A polynomial as a product of 4 consecutive numbers? (x+1) Write (f-g) as a product of SF(2 3 ) = 4 consecutive numbers
24
Results From Number Theory f ≡ g in Z 2 3 or (f - g) ≡ 0 % 2 3 2 3 |(f - g) in Z 2 3 2 3 |4! 4! divides the product of 4 consecutive numbers A polynomial as a product of 4 consecutive numbers? (x+1)(x+2) Write (f-g) as a product of SF(2 3 ) = 4 consecutive numbers
25
Results From Number Theory f ≡ g in Z 2 3 or (f - g) ≡ 0 % 2 3 2 3 |(f - g) in Z 2 3 2 3 |4! 4! divides the product of 4 consecutive numbers A polynomial as a product of 4 consecutive numbers? (x+1)(x+2)(x+3) Write (f-g) as a product of SF(2 3 ) = 4 consecutive numbers
26
Results From Number Theory f ≡ g in Z 2 3 or (f - g) ≡ 0 % 2 3 2 3 |(f - g) in Z 2 3 2 3 |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) Write (f-g) as a product of SF(2 3 ) = 4 consecutive numbers
27
Basis for factorization S 0 (x) = 1 S 1 (x) = (x + 1) S 2 (x) = (x + 1)(x + 2) = Product of 2 consecutive numbers S 3 (x) = (x + 1)(x + 2)(x + 3) = Product of 3 consecutive numbers … S n (x) = (x + n) S n-1 (x) = Product of n consecutive numbers Rule 1: Factorize into atleast S n (x) to vanish, where n = SF(2 m ).
28
Example: Vanishing polynomial 4 th degree polynomial p in Z 2 3 ; SF(2 3 ) = 4 p = x 4 +2x 3 + 3x 2 + 2x p can be written as a product of 4 consecutive numbers. or p = (x+1)(x+2)(x+3)(x+4) = S 4 (x) in Z 2 3. p is a vanishing polynomial.
29
Example: Vanishing polynomial module fixed_bit_width (x, f, g); input [2:0] x; output [2:0] f, g; assign f[2:0] = x 2 + 6x – 3; assign g[2:0] = 5x 2 + 2x + 5; h(x) = f(x) – g(x) = 4x 2 + 4x h(x) ≡ 0 for all values of x in {0,…,7} 4x 2 +4x not equal to (x+1)(x+2)(x+3)(x+4) Required: To show that h(x) is a vanishing polynomial in Z 2 3
30
Constraints on the Coefficient h(x) = 4x 2 + 4x = 4(x+1)(x+2) In Z 2 3, SF(2 3 ) = 4. Product of 4 consecutive numbers: S 4 (x) = (x+1) (x+2) (x+3) (x+4) Rule 2: Coefficient has to be a multiple of b k = 2 m /gcd(k!, 2 m ) Here, Coefficient of h(x) = 4, Degree of h(x) = 2 b 2 = 2 3 /gcd(2!, 2 3 ) = 4 is a multiple of the coefficient
31
Constraints on the Coefficient h(x) = 4x 2 + 4x = 4(x+1)(x+2) compensated by constant In Z 2 3, SF(2 3 ) = 4. Product of 4 consecutive numbers: S 4 (x) = (x+1) (x+2) (x+3) (x+4) missing factors Rule 2: Coefficient has to be a multiple of b k = 2 m /gcd(k!, 2 m ) Here, Coefficient of h(x) = 4, Degree of h(x) = k = 2 b 2 = 2 3 /gcd(2!, 2 3 ) = 4 is a multiple of the coefficient
32
Deciding Vanishing Polynomials n = SF(2 m ), i.e. the least n such that 2 m |n! F n is an arbitrary polynomial in Z 2 m [x] a k is an arbitrary integer b k = 2 m /gcd(k!,2 m ) Polynomial F in Z 2 m vanishes if F = F n S n + Σ n-1 a k b k S k k=0 Rule 1 Rule 2
33
Algorithm Input: poly, 2 m 1. 1. Calculate n = SF(2 m ) 2. 2. k = n: Reduce according to Rule 1 Divide by S n If remainder is zero, F = F n S n, else Continue poly = 4x 2 + 4x in Z 2 3 1. 1. n = SF(2 3 ) = 4 2. 2. k = 4: Divide by S 4 Degree (poly) = 2 < degree(S 4 ) = 4 quo = 0, rem = 4x 2 + 4x F 4 = 0; Continue Example 1 F = F n S n + Σ n-1 a k b k S k k=0
34
Algorithm Input: poly, 2 m 1. 1. Calculate n = SF(2 m ) 2. 2. k = n: Reduce according to Rule 1 Divide by S n If remainder is zero, F = F n S n, else Continue poly = 4x 2 + 4x in Z 2 3 1. 1. n = SF(2 3 ) = 4 2. 2. k = 4: Divide by S 4 Degree (poly) = 2 < degree(S 4 ) = 4 quo = 0, rem = 4x 2 + 4x F 4 = 0; Continue Example 1 F = F n S n + Σ n-1 a k b k S k k=0
35
Algorithm 3. 3. Reduce according to Rule 2. Divide by S n-1 to S 0 Check if quotient is a multiple of b k = 2 m /gcd(k!,2 m ) If remainder is zero, stop. Else, continue 3. 3. k = 3: Divide by S 3 degree (poly) = 2 < degree(S 3 ) = 3 quo= 0, rem = 4x 2 + 4x continue 4. 4. k = 2: Divide by S 2 quo = 4; rem = 0 b 2 = 2 3 /gcd(2!,2 3 ) = 4 a 2 = quo/ b 2 = 1 Є Z Example 1 poly = a 2.b 2.S 2 = 1.4.(x+1)(x+2) ≡ 0 in Z 2 3 F = F n S n + Σ n-1 a k b k S k k=0
36
Algorithm 3. 3. Reduce according to Rule 2. Divide by S n-1 to S 0 Check if quotient is a multiple of b k = 2 m /gcd(k!,2 m ) If remainder is zero, stop. Else, continue 3. 3. k = 3: Divide by S 3 degree (poly) = 2 < degree(S 3 ) = 3 quo= 0, rem = 4x 2 + 4x continue 4. 4. k = 2: Divide by S 2 quo = 4; rem = 0 b 2 = 2 3 /gcd(2!,2 3 ) = 4 a 2 = quo/ b 2 = 1 Є Z Example 1 poly = a 2.b 2.S 2 = 1.4.(x+1)(x+2) ≡ 0 in Z 2 3 F = F n S n + Σ n-1 a k b k S k k=0
37
Example 2 poly = 5x 2 + 3x + 7 in Z 2 3 n = SF(2 3 ) = 4 degree (poly) = 2 < n. Skip Rule 1, try Rule 2 Divide by S 2 quo = 5; rem = 5 + 4x b 2 = 2 3 /gcd(2!,2 3 ) = 4 a 2 = quo/ b 2 = 5/4 is not in Z poly does not satisfy Rule 2 poly is not a vanishing polynomial in Z 2 3
38
Status of our Work - Extensions Multiple Variables: Multiple Variables: Z 2 m [x 1, …, x d ] Given polynomials (f, g) d variablesGiven polynomials (f, g) d variables x = over Z 2 m x = over Z 2 m Prove that (f-g) = 0 % 2 m What if word-lengths are different too? x 1 Z 2 n 1, ……, x d Z 2 n d No problems! Straight-forward extensions of previous concepts Other approach: Canonical forms of poly- functions
39
Polyfunctions over Z 2 m Polynomials over Z 2 m[x 1, …, x d ] Represented by polyfunctions from Z 2 m[x 1, …, x d ] 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 f g Equivalence classes Z 2 m [x 1, …, x d ] Z2mZ2m F2F2 F1F1 G2G2 G1G1
40
Motivating our Approach module fixed_bit_width (x, f, g); input [2:0] x; output [2:0] f, g; assign f[2:0] = 5x 2 + 6x - 3; assign g[2:0] = x 2 + 2x + 5; f (x) = 5x 2 + 6x - 3 = (x 2 + 2x + 5) + (4x 2 + 4x) f (x) = g(x) + V (x) in Z 2 3 V (x) = 4x 2 + 4x ≡ 0 % 2 3 ; for x in {0,…,7} f (x) = g (x) + 0 in Z 2 3 Required: To identify and eliminate such redundant sub-expressions (vanishing)
41
Vanishing Polynomials for Reducibility In Z 2 3, say f (x) = 4x 2 f (x) = f (x) - V(x) Generate V(x) of degree 2 V(x) = 4x 2 + 4x ≡ 0 % 2 3 Reduce by subtraction: 4x 2 f (x) – 4x 2 + 4x V(x) = - 4x = - 4x % 8 = 4x 4x 2 can be reduced to 4x Degree reduction
42
Degree Reduction: Requirement Generate appropriate vanishing polynomial, V(x) f (x) = ax k + a 1 x k-1 + … V(x) = ax k + a 2 x k-1 + … f (x) – V(x) = bx k-1 + … V(x): ax k is the leading term Identify constraints on Degree : k; Coefficient : a f (x) = ax k + … If 2 m |ak!, then V(x) = ak! x + k ≡ 0 % 2 m k = ax k + a 1 x k-1 …..
43
Coefficient Reduction: Example Degree is not always reducible In Z 2 3, f (x) = 6x 2 a = 6, k = 2 8 does not divide 6 × 2! Divide and subtract 6x 2 = 2x 2 + 4x 2 % 2 3 4x 2 can be reduced to 4x f (x) = 2x 2 + 4x : Lower Coefficient
44
Our Approach Say f (x) = a k x k + a k-1 x k-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 …
45
Experimental 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(k d )
46
Results
47
Limitations: 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……
48
Intermediate Signal Truncation a = 127 b = 1 f 1 = 383 c = 255 ≠ a = 127 b = 1 f 2 = 127 c = 255 a [7:0] b [7:0] t 1 [7:0] + c [7:0] + f 1 [8:0] a [7:0] b [7:0] t 2 [7:0] + c [7:0] + f 2 [8:0]
49
Proposed Solution ≠ a [7:0] b [7:0] t 1 [7:0] + c [7:0] + f 1 [8:0] a [7:0] b [7:0] t 2 [7:0] + c [7:0] + f 2 [8:0] Canonize Required: Algorithm for reduction to canonical form over
50
Polynomial Abstraction from RTL If (x > 2b’10) then y = x * x * x Else y = x*x Traditional modeling. Proposed modeling: y as a polyfunction from : Unique representation Issues with the proposed abstraction: Scalability
51
Verification via Simulation?
52
Simulation Vector Generation Simulation Vector Generation f = x 4 + x 2 (specification) f = x 4 + x 2 (specification) x=0, f=0x=0, f=0 x=1, f=2x=1, f=2 x=2, f=4x=2, f=4 x=3, f=2x=3, f=2 x=4, f=0x=4, f=0 x=5, f=2x=5, f=2 x=6, f=4x=6, f=4 x=7, f=2x=7, f=2 Prove f = g over Z 8 via Simulation Prove f = g over Z 8 via Simulation How many vectors to Simulate? Exhaustive Simulation? NO! Simulate only n = SF(2 3 ) = 4 CONSECUTIVE vectors g = 2x 2 (implementation) g = 2x 2 (implementation) x=0, g=0x=0, g=0 x=1, g=2x=1, g=2 x=2, g=0x=2, g=0 x=3, g=2x=3, g=2 x=4, g=0x=4, g=0 x=5, g=2x=5, g=2 x=6, g=0x=6, g=0 x=7, g=2x=7, g=2
53
Applications to Synthesis Datapath size ( m ): 8 bits SF(2 8 ) = 10 Polynomial can be factorized into S 10 (x) F[7:0] = (x+1)(x+2)...(x+10)
54
Polynomial Decomposition F = 8xy 2 + 11y 3 + 9y 2 + 1 F = 8xy 2 + 11y 3 + 9y 2 + 1 X, Y [3:0] are 4-bit vectors (%16) X, Y [3:0] are 4-bit vectors (%16) Synthesize: Area = 320 Synthesize: Area = 320 U = 8x + 3y U = 8x + 3y F = U 3 + U 2 + 1 F = U 3 + U 2 + 1 Synthesize: Area = 181+20 = 201 Synthesize: Area = 181+20 = 201
55
Conclusions 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) % 2 m ≡ g(x) % 2 m is transformed into f(x) - g(x) ≡ 0 % 2 m Ideal Membership Testing, Canonical Forms…. Tremendous scope in high-level synthesis….
56
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.