verifying global convergence of a digital phase …yanpeng/talks/msr2013.pdfverifying global...

32
Verifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia September 27, 2013 Joint work with Jijie Wei, Grace Yu, and Mark Greenstreet This work is funded by the Intel Corporation. Peng et al., UBC Verifying a Digital PLL 1/30

Upload: duongthuy

Post on 14-Apr-2018

228 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Verifying Global Convergence of a DigitalPhase-Locked Loop with Z3

Yan Peng

University of British Columbia

September 27, 2013

Joint work with Jijie Wei, Grace Yu, and Mark Greenstreet

This work is funded by the Intel Corporation.

Peng et al., UBC Verifying a Digital PLL 1/30

Page 2: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Outline

Phase-Locked Loop (PLL) IntroductionVerifying an All-Digital PLL with Z3[DMB08]I General approach for circuit verification with SMT

solverI Global convergence verification for a simplified model

with Lyapunov functionI Limit cycle verification for a discrete recurrence model

Ideas and DiscussionsI ComparisonI ObservationsI Reachability Approach: SpaceExI Conclusions

Peng et al., UBC Verifying a Digital PLL 2/30

Page 3: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

PLL: Thermostat Temperature Control

First order control systemSuppose T stands for current temperature, T0 stands fordesired temperature, then the system can be modelled as

T = −k(T − T0).

Peng et al., UBC Verifying a Digital PLL 3/30

Page 4: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

PLL: Autonomous Cruise Control with Following

Second order control systemSuppose k1 and k2 are both positive, the system can bemodelled as k2S + k1S + S = S0.This system has an equilibrium at S = S0, and the tworoots of k2 λ

2 + k1λ+ 1 both have negative real partswhich make the system stable.

Peng et al., UBC Verifying a Digital PLL 4/30

Page 5: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

PLL: Block Diagram

Phase Detector

Loop Filter

Voltage Controlled Oscillator

Divide by N Counter

Reference Clock

Output Clock

A PLL is a feedback control system that, given an inputreference clock, it outputs a clock at a frequency that’s Ntimes of the input clock frequency.

PLLs are ubiquitous in analog and mixed-signal designs. E.g.frequency multiplication for clock-acquisition in high-speedlinks, modulators and demodulators for wirelesscommunication.

Peng et al., UBC Verifying a Digital PLL 5/30

Page 6: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

PLL: Global Convergence

PLL

Dynamical System

Analog

Always Lock

Digital

Continuous Model

Global Convergence

Recurrence Model

The most essential function of a PLL is to lock at the rightphase and frequency. The quicker a PLL locks the better.

The global convergence problem asks whether a PLL locks nomatter where its initial state is at.

Peng et al., UBC Verifying a Digital PLL 6/30

Page 7: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

PLL: Crossley et al.’s [CNA10]

DCO

BBPFD

0:23

0:14

15:23LPF

DCO

+

− dnup

∆θ

cvPFD

Fref

Fref

Σ0:7

0:3

4:7

∆Σ

FDCO

Fref

Σ DAC −+

Cdecap

F

−(

Centercode

)

÷N

DCO has three control inputs:capacitance setting (digital), supply voltage (linear), phasecorrection (time-difference of digital edges).Uses linear and bang-bang PFD.Integrators are digital.LPF and decap to improve power-supply rejection.

Peng et al., UBC Verifying a Digital PLL 7/30

Page 8: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

PLL: Verified digital PLL

∆Σ

0:7

DCO

4:7BBPFD

0:23

0:14

15:23LPF

DCO

+

− dnup

∆θ

cvPFD

Fref

Fref

Σ0:7

0:3

FDCO

Fref

Σ DAC −+

Cdecap

F

−(

Centercode

)

÷N

We omitted the Delta-Sigma modulator, low-pass filter, andlinear regulator for simplicity.We believe all of these could be included using the samemethods as we’ve used for the rest of the digital PLL.

Peng et al., UBC Verifying a Digital PLL 8/30

Page 9: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Outline

◦ Phase-Locked Loop (PLL) OverviewP Verifying an All-Digital PLL with Z3

I General approach for circuit verification with SMTsolverI Global convergence verification for a simplified model

with Lyapunov functionI Limit cycle verification for a discrete recurrence model

◦ Ideas and DiscussionsB ComparisonB ObservationsB Reachability Approach: SpaceExB Conclusions

Peng et al., UBC Verifying a Digital PLL 9/30

Page 10: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Verification Approach

Circuit and its Function

Circuit Knowledge and Simulation Tests(MATLAB/SPICE)

Property / Specification

DecomposeSome

lemmas

Adjustment

Mathematical Model Theorem

SMT Solver

Proposition and lemmas

ObservationMath & Logic

Final Proof

Peng et al., UBC Verifying a Digital PLL 10/30

Page 11: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Dynamics of the Circuit

v

c

v=

v min

v=

v max

c = cmax

c = cmin

Typical operation of the digital PLLC saturates. C is the “fast-tracking” control.vctrl moves toward equilibrium value.C and vctrl move through a sequence of limit cycles to

maintain phase and frequency lock while centering C.Verification has separate “lemmas” for each of thesephases.

Peng et al., UBC Verifying a Digital PLL 11/30

Page 12: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: Simplified Model

The ODE model:

c = g1 · (fref − 1N

v0+αvc0+βc ) where c ∈ (cmin, cmax )

v = g2 · (c − ccode)

Note: c = 0 when c = cmin or c = cmax

Linear phase path will be handled later, in the recurrencemodel analysis.

Quantization error will be included later.

Peng et al., UBC Verifying a Digital PLL 12/30

Page 13: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: Lyapunov Function

Consider invariant region Q0, target region QT withQT ⊆ Q0. Lyapunov function, Ψ:I ∀x ∈ Q0 −QT . Ψ(x) > 0I ∀x ∈ Q0 −QT . d

dt Ψ(x) < 0For homogeneous linear ODE system x = Ax :I Let P be the solution of AT P + PA = −I. A possible

Lyapunov function becomes Ψ(x) = X T PX .I By construction, P is symmetric. If P is positive

definite, then the system x = Ax globally converges tox = 0

As long as one can find a Lyapunov function for a system,convergence to the desired equilibrium is ensured, nomatter how the Lyapunov function is found.

Peng et al., UBC Verifying a Digital PLL 13/30

Page 14: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: The Full Proof

Translate the system

Derive the Jacobian matrix

at operating point

Calculate P matrix

Form the statement to prove

Z3 checks if the two conditions are satisfied

Z3 solves this linear system readily

Z3 easily proves global convergence when parameters areassigned fixed values and no quantization error is taken intoconsideration.

Peng et al., UBC Verifying a Digital PLL 14/30

Page 15: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: Improve the Model

Z3 easily proves the simple system (just shown)We added details to the model to make it more realisticI Parameters with rangesI Quantization error: we approximate discrete sums in

the real DPLL with integralsI Both ranges and quantization

In all of these, Z3 would run longer than we had patienceSolution: manually simplify terms in the proposedLyapunov functionThe approach remains sound because Z3 checks theLyapunov conditions, it doesn’t matter how we came upwith the Lyapunov function.

Peng et al., UBC Verifying a Digital PLL 15/30

Page 16: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: Adjust the Proof for Z3

Parameters with ranges. Inequality ranges for parameters α,β, v0 and c0.

Strategy: Check where the parameters are used, try simplifynon-linear part. e.g. we replace some of the parameters inthe Jacobian matrix with its nominal value.

Example:Knowing α ≈ 1 and β ≈ 1:

Jac(f, X0) =

g1 fref βc0+βccode

− g1αc0+βccode

g2 0

⇒ Jac(f, X0) =

g1 frefc0+βccode

− g1c0+βccode

g2 0

Z3 happily proved the conditions, again.

Peng et al., UBC Verifying a Digital PLL 16/30

Page 17: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: Adjust the Proof for Z3

Adding quantization error. Quantization error introducesnew variables and inequalities.

Strategy: Noticing symmetry in the formula, transferquantization error in the non-linear term to linear term.

Proposition:Let Err denote quantization error and assume Err is symmetricaround 0: if η ∈ Err then −η ∈ Err as well. We can easily show:

∀x ∈ Q0 − QT .∀η ∈ Err .h(x + η)T Px < 0⇔∀x ∈ (Q0 − QT )⊕ Err

∀η ∈ Err .(x + η ∈ Q0 − QT )⇒ (h(x)T P(x + η) < 0)

The Minkowski sum of two sets, A⊕ B, is the set of elements that can beobtained as the sum of an element from A and an element from B:

A⊕ B = {z | ∃a ∈ A. ∃b ∈ B. z = a + b}

Peng et al., UBC Verifying a Digital PLL 16/30

Page 18: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Global Convergence Proof: Adjust the Proof for Z3

Combination. Combining quantization error and parameterranges together.

Strategy: Further reduce the complexity of our problem bysimplifying non-linear formulas.

Example:Given βc + c0 + βccode > 0

(βc + c0 + βccode)φ(X ) < 0⇒ φ(X ) < 0

Given ccode = 1, c0 ≈ 1, and β ≈ 1,

Jac(f, X0) =

[ g1 frefc0+βccode

− g1c0+βccode

g2 0

]⇒ Jac(f, X0) =

[g1 fref

2 − g12

g2 0

]

Peng et al., UBC Verifying a Digital PLL 16/30

Page 19: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: the Recurrence Model

A limit cycle is an isolated closedtrajectory, for which itsneighbouring trajectories arenot closed they spiral eithertowards or away from the limitcycle.

The recurrence model:c(i + 1) = c(i) + g1sign(φ(i))

v(i + 1) = v(i) + g2(c(i)− ccode)

φ(i + 1) = (1− Kt )φ(i) + 2π(

fdco(i)Nfref

− 1)

where fdco(i) = f01+αv(i)1+βc(i)

Peng et al., UBC Verifying a Digital PLL 17/30

Page 20: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: Simplification with V

Simplified recurrence model:v changes slowly with respect to c and φ. Thus, we can analyse thePLL as having a sequence of limit cycles, where each cycle isdescribed by a recurrence of the form:

c(i + 1) = c(i) + g1sign(φ(i))

φ(i + 1) = (1− Kt )φ(i) + 2π(

fdco(i)Nfref

− 1)

Peng et al., UBC Verifying a Digital PLL 18/30

Page 21: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: Induction Proof - the Theorem

5 0 5 100.015

0.01

0.005

0

0.005

0.01

c1 c2 (2n 1)

c (quantized)

(con

tinuo

us)

TheoremIf for each trajectory going through the upper space, supposefirst point up crossing c-axis is φ(0), and we haveφ(2n − 1) < 0, then the system must be converging towardssome limit cycle.

Peng et al., UBC Verifying a Digital PLL 19/30

Page 22: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: Induction Proof

Induction ProofSuppose (c0, φ0) is the first point up crossing c-axis, and wehave:

c0 = m · g1, m ∈ Z ∧ m ≤ −3

0 ≤ φ0 < 2π(µ

1 + αv0

1 + β(m + 1)g1− 1)

Solve the recurrence:

c(j) = c0 + g1j

φ(j) = γ jφ0 + 2πj−1∑i=0

γ(j−1−i)(µ

1 + αv0

1 + βc(i)− 1)

We want to prove:∀m ≥ 3, φ(2m − 1) < 0

A symmetric argument applies to lower half of the space.

Peng et al., UBC Verifying a Digital PLL 20/30

Page 23: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: Lemma 1 (by induction)

We manually rewrote the inequalities and decomposed theproof into the formula below:

Z3 formula

γ2( 1+αv0

1+β(m−1)g1− 1+αv0

1+βmg1

)+ γ

( 1+αv01+βmg1

− 1+αv01+β(m+1)g1

)+( 1+αv0

1+β(−(n−1)g1+equc )− 1

µ

)1µ− 1+αv0

1+β((n−1)g1+equc )

< γ2−2n

Decompose this formula into two:

new Z3 formula

γ2( 1+αv0

1+β(m−1)g1− 1+αv0

1+βmg1

)+ γ

( 1+αv01+βmg1

− 1+αv01+β(m+1)g1

)+( 1+αv0

1+β(−(n−1)g1+equc )− 1

µ

)1µ

1− 1+αv01+β((n−1)g1+equc )

< 2n

and2n < γ

2−2n

Peng et al., UBC Verifying a Digital PLL 21/30

Page 24: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: Lemma 2 (by induction)

An additional induction proof is provided for proving2n < γ2−2n( where 0 < γ < 0.5 ):

Additional Induction Proof

When k = 4, 8 < γ−6

Suppose when k = n, 2n < γ2−2n stands, then we havewhen k = n + 1, 2(n + 1) < γ2−2(n+1).I Here is an simple illustration showing how Z3 helps

discharge formula to be proved:∵ 2n < γ2−2n

∴ 2nγ−2 < γ−2n

∵ 2n + 2 ≤ 2nγ−2 ⇒ This is the formula for Z3!∴ 2n + 2 < γ−2n

Peng et al., UBC Verifying a Digital PLL 22/30

Page 25: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Limit Cycle Verification: Finding One Limit Cycle

We find one limit cycle by stating what properties should acycle have:

Property of a limit cycle with 6 verticesThe 6 points should satisfy the recurrenceThe next point for the 6th point should be the 1st pointTo make it easier, we specify small target ranges for thepoint positionsWe find in some limit cycles, there must be one point atwhich c = 0(suppose the system is translated to the origin)

Peng et al., UBC Verifying a Digital PLL 23/30

Page 26: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Outline

◦ Phase-Locked Loop (PLL) Overview◦ Verifying an All-Digital Phase-Locked Loop with Z3

I General approach for circuit verification with SMTsolverI Global convergence verification for a simplified model

with Lyapunov functionI Limit cycle verification for a discrete recurrence model

P Ideas and DiscussionsIComparisonIObservationsIReachability Approach: SpaceExIConclusions

Peng et al., UBC Verifying a Digital PLL 24/30

Page 27: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Comparison

Lyapunov function method:Fixed procedure, easyfor automationTake less human effort,much is done in Z3More suitable forcontinuous systemwithout large non-linearpart.

Induction proof method:More flexibility in procedure,not easy for automationTake lots of pencil and paperwork to decompose the proofand takes the human mind tocombine the proofs.Suitable for moresophisticated system,difficulty lies in how to find atheorem to prove theproperty.

Peng et al., UBC Verifying a Digital PLL 25/30

Page 28: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Observations

The part of Z3 wefrequently used in ourproof:I Real arithmeticI Linear and polynomial

arithmeticI Propositional logic:

prove, ImpliesI Very large

propositionalstatement withpolynomials and someinequalities

Things that’ll probablyhelp with our work:I Real and Integer

combined arithmeticI Non-linear arithmetic,

E.g. exponentials,rational functions

I Induction proofI Combining lemmas,

like a theorem prover

Peng et al., UBC Verifying a Digital PLL 26/30

Page 29: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Reachability Approach: SpaceEx

SpaceEx[FLGD+11] is a hybrid-automaton based tool onreachability analysis for safety verification.Build hybrid-automata models for each component:I DCO: 7 modes – linearize for overlapping intervals of

vctrl .I PFD: 1 mode, with self-loops.I C-accumulator: 4 modes – up, down, saturated low,

saturated high.I V-accumulator: 3 modes – normal, saturated low,

saturated high.Product machine has 84 modes.Dynamics of the system lead to transitions betweenmodes.SpaceEx confirms convergence to lock from any initialstate.

Peng et al., UBC Verifying a Digital PLL 27/30

Page 30: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Reachability Approach: SpaceEx - Comparison

The hybrid-automatonapproach very closelyfollowed the structure ofthe digital PLL.I Seems likely to be

more intuitive forreal-world designersand verifiers.

I Verified the digital PLLfor a specific choice ofmodel parameters.

I ”Feels” likemodel-checking.

I Manual decompositioninto lemmas required.

The SMT approach ismore general:I Handles some of the

non-linearities directly.I Verified the digital PLL

with modelparameters in intervalranges.

I ”Feels” like theoremproving.

Peng et al., UBC Verifying a Digital PLL 28/30

Page 31: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

Conclusion

SMT solvers such as Z3 can be extensively adopted in thefield of mixed signal circuit verification and continuousdynamic system verification.SMT approaches are promising for verifying properties ofmixed signal designs, such as proving global convergenceand identifying limit cycle behaviours. These properties areimpossible to verify with traditional simulation.We would like to further automate the verification,especially tracking proof obligations for inductionarguments and showing that SMT-discharged lemmasprove the main result.We would like to better understand the workings of theSMT solver to use it more effectively and possibly extend itto handle wider ranges of problems.

Questions and suggestions are welcome!

Peng et al., UBC Verifying a Digital PLL 29/30

Page 32: Verifying Global Convergence of a Digital Phase …yanpeng/talks/MSR2013.pdfVerifying Global Convergence of a Digital Phase-Locked Loop with Z3 Yan Peng University of British Columbia

References

J. Crossley, E. Naviasky, and E. Alon, An energy-efficientring-oscillator digital pll, Custom Integrated CircuitsConference (CICC), 2010 IEEE, 2010, pp. 1–4.

Leonardo De Moura and Nikolaj Bjørner, Z3: an efficientsmt solver, Proceedings of the Theory and practice ofsoftware, 14th international conference on Tools andalgorithms for the construction and analysis of systems(Berlin, Heidelberg), TACAS’08/ETAPS’08, Springer-Verlag,2008, pp. 337–340.

Goran Frehse, Colas Le Guernic, Alexandre Donze, ScottCotton, Rajarshi Ray, Olivier Lebeltel, Rodolfo Ripado,Antoine Girard, Thao Dang, and Oded Maler, Spaceex:scalable verification of hybrid systems, Proceedings of the23rd international conference on Computer aidedverification (Berlin, Heidelberg), CAV’11, Springer-Verlag,2011, pp. 379–395.

Peng et al., UBC Verifying a Digital PLL 30/30