Formal Verification: How Do I Know If My Circuit Works? Simulation Formal Verification: Prove It Works
Formal Verification: How Do I Know If My Circuit Works? Simulation Formal Verification: Prove It Works
Sequential Verification
Prove finite-state machine can’t get into bad state, can’t
deadlock, etc
L L
a a
t t
c Combinational Logic c
h h
e e
s s
Combinational
verification: prove
thisCS
works
150 - Spring 2008 – Lec #23 –
Verification - 8
Combinational Verification Problem
Formal Statement:
Given Circuit C and Reference Circuit R, does C compute the
same function as R?
Key: we can usually describe what a circuit does very simply
Complexity comes from making it fast, compact, etc
For example: given a carry-bypass adder C, does it compute
the same function as a (simple) ripple-carry adder R?
Two Approaches: Canonical Form and Satisfiability
Decision Decision
Tree for Tree for
f|A=1 f|A=0
B B
C C C C
1 0
1 0 0 1 0 1
B B
Identical
C C C C
1 0
1 0 0 1 0 1
B B
Identical
C C C C
1 0
1 0 0 1 0 1
A
Reduced, Ordered
Binary Decision
B B Diagram of function
for f = A B C
Canonical Form
C C Often Small
“Most important
computer science
structure of last 20
1 0 years”
CS 150 - Spring 2008 – Lec #23 –
Verification - 16
BDD Applications
Formal Verification
Canonical form for circuit
Represent sets of states in finite state machine
Low-power circuitry
Each edge becomes AND gate
Each node becomes OR
Output is “1” terminal
At most one transition per simulation
Simulation
Compile circuit into BDD
Compile BDD into code
Number of instructions to simulate circuit = number of variables in
BDD
1 Bdd
=
1 1 Bdd
= Bdd
0 Bdd
= Bdd
0 Bdd 0
=
A op A
=
BDD BDD
for for
f op g|A=1 f op g|
CS 150 - Spring 2008 – A=0Lec #23 –
Verification - 20
Key to Efficiency
Kept a hash table (var, low, high)
If var, low, high already in table returned stored
function
Kept each function at most once
A A
B B
+
C C
1 0 1 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 22
Example: a’b’c + ab’c’
= B
0 + B
C
C
1 0
1 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 23
Example: f = a’b’c + ab’c’
B
B
+ =
C
C
1 0
1 0 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 24
Example: a’b’c + ab’c’
B B
C C
1 0 1 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 25
Example: a’b’c + ab’c’
A A A
B B B
B
+ =
C C
C C
1 0 1 0 1 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 26
Example: a’bc’ + abc
A A A
B B B
B
+ =
C C
C C
1 0 1 0 1 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 27
Example: f = a’b’c + ab’c’ + a’bc’ + abc
A
A A
B B
B B B B
+ =
C C
C C C C
1 0
1 0 1 0
CS 150 - Spring 2008 – Lec #23 –
Verification - 28
BDD’s For Verification
A
A
B B
B B
C C
C C
1 0
1 0
C is identical to R only
when out == 0 (no inputs
X, Y, Z that makes out
CS 150 - Spring1) 2008 – Lec #23 –
Verification - 31
Example: Verification of f = A B C
Specification of
f=ABC
Implementation
of f = A B C
CS 150 - Spring 2008 – Lec #23 –
Verification - 32
Example: Verification of f = A B C
Implementation
Implementation
Specification
Don’t-care
CS 150 - Spring 2008 – Lec #23 –
Verification - 36
Solving the SAT problem
Assert 1 on the output
Trace implications back to inputs
No contradiction => error, input vector found
Contradiction: Circuit works
SAT is NP-complete (first NP-Complete problem;
Cook’s paper was called “Complexity of Theorem-
Proving Procedures)
But extensively studied
Current best heuristics (Malik, Princeton) up to 5000
variables…
CS 150 - Spring 2008 – Lec #23 –
Verification - 37
Finite State Machine Verification
Does my finite-state machine work?
In the limit, proves the whole design works
(Any design is just one big FSM)
In general, this is too hard – prove things about pieces at a time
“Works” is too complicated and ill-formed a question to prove
We mean multiple properties
How can we say “video feed displays properly” mathematically?
Need to pose questions we can answer
E.G. Prove when we get an init message we always respond with an
ack
B C G
D E F
R3 = R2 = R* = {A,
B, C, D, E, F}
G is unreachable!
Dy y’
x’ Bx
D
B
y
x
J
I
(Bx)’
(Dy)’ CS 150 - Spring 2008 – Lec #23 –
Verification - 48
Example
D
A
y
y’
x’
C
B
x
CS 150 - Spring 2008 – Lec #23 –
Verification - 49
Form the single Machine and prove it!
States are pairs of states from the original machines
Transitions are legal transitions from the original
machines
Thing to prove:
(I, J) is unreachable
{A, B} x {C, D} are unreachable
E. G., (A, D) is unreachable
x y •xy’ to (I,C)
I J
B,C B,D B,J
A,C A,D
A,J