Model Checking in Digital Systems
Model Checking in Digital Systems
Amit Goel
amitgoel@[Link]
Verification complexity
Exponential
Simulation
States
Emulation
FPGA’s
Formal Verification
2017
Time
Properties
Graph Reachability
Symbolic Model Checking
Proof by Induction
Model Checking
Graph Reachability
Symbolic Model Checking
Proof by Induction
State Machines
State Machines
Example
I = {s2}
I = {s2} s1 s3
s0 s2
s1 s3 s1 s3
s0 s2 s0 s2
s1 s3 s1 s3
s0 s2 s0 s2
s1 s3 s1 s3
s0 s2 s0 s2
T = {(s0,s0), (s0,s1), (s0,s2), (s1,s0), (s1,s1), (s1,s4), (s2,s0), (s2,s2), (s3,s0), (s4,s4)}
s0 s2
Can you reach a state where you cannot exit from and return to any good state?
UT Austin College of ECE - [Link] of Digital Systems, 5th March 2020
State-space Explosion
Example
n n!
4 24
8 40,320
16 20,922,789,888,000
Model Checking
Graph Reachability
Symbolic Model Checking
Proof by Induction
Symbolic Representation of States
s0 00
s1 01
s2 10
s3 11
false {}
x∙¬y {10}
x∙y {11}
y {01, 11}
¬x∙¬y∙x’∙¬y’ {00→10}
01 11 01 11
00 10 00 10
logic x; logic y;
State Variables:
V = {x, y}
always @(posedge clock)
if (reset) begin
Initial (reset) State:
x <= 1'b1;
I(V) = x∙¬y
y <= 1'b0;
end else begin
x <= !y && cx; Transition Functions:
y <= !x && !cx && cy; x’ = ¬y∙cx
end y’ = ¬x∙¬cx∙cy
// Mutex property
assert property (!(x && y)); Property:
endmodule Bad = x∙y
UT Austin College of ECE - [Link] of Digital Systems, 5th March 2020
Synthesized Circuit
x
logic x; logic y;
State Variables: NOT
1 AND
V = {x, y}
always @(posedge clock)
reset
if (reset) begin
Initial (reset) State: cy
x <= 1'b1;
I(V) = x∙¬y NOT
AND
y <= 1'b0;
end else begin cx
x <= !y && cx; Transition Functions:
y <= !x && !cx && cy; x’ = ¬y∙cx
y’ = ¬x∙¬cx∙cy y AND
end NOT
0
// Mutex property
reset
assert property (!(x && y)); Property:
endmodule Bad = x∙y
UT Austin College of ECE - [Link] of Digital Systems, 5th March 2020
Transition Function and Transition Relation
Example
• Transition function: 1
x’ = ¬x ∙ cx
• Transition relation (with input variables): 0,1 1
̃T(x, cx, x’) = (x’ ⟷ ¬x ∙ cx)
• Transition function: 1
x’ = ¬x ∙ cx
• Transition relation (with input variables):
̃T(x, cx, x’) = (x’ ⟷ ¬x ∙ cx)
• Transition Relation (without input variables):
0
T(x, x’) = ∃cx.(x’ ⟷ ¬x ∙ cx)
= (¬x ∣ ¬x’)
• Transition function:
x’ = ¬y∙cx
y’ = ¬x∙¬cx∙cy
• Transition relation (with input variables):
̃T(V, cx, cy, V’) = (x’ ⟷ ¬y ∙ cx) ∧ (y’ ⟷ ¬x∙¬cx∙cy)
• Transition Relation:
T(V, V’) = ∃cx, cy. ̃T(V, cx, cy, V’)
= (¬x∙¬x’ ∣ ¬y∙¬y’ ∣ ¬x’∙¬y’)
x
NOT
logic x; logic y; 1 AND
01 11
always @(posedge clock)
reset
if (reset) begin
cy
x <= 1'b1; AND
NOT
y <= 1'b0;
end else begin cx
x <= !y && cx;
y <= !x && !cx && cy; 00 10
y AND
end NOT
0
// Mutex property
reset
assert property (!(x && y));
endmodule
A x {10,11} SA
B y {01,11} SB
¬A ¬x {00,01} S ∖ SA
Image Computation
• Then F(V) is the set of all states reachable in one step from states in R
Image Computation
R(V) = ¬y 01 11
00 10
• Then F(V) is the set of all states reachable in one step from states in R
Satisfiability Solvers
Example
V T(V,V’)
clock
Initial Bad
Initial Bad
• Badk = I(V0) ∧T(V0,V1) ∧ … ∧ T(Vk-1, Vk) ∧ Bad(Vk)
• Unsatisfiable? No failure in k cycles
• Satisfiable? Satisfying assignment is a k-length counterexample
UT Austin College of ECE - [Link] of Digital Systems, 5th March 2020
Graph Reachability
Symbolic Model Checking
Proof by Induction
Natural Induction
• To Prove:
1 + 2 + … + n = (n * (n+1)) /2
• Base Step:
Show that the equation holds for n = 1
1 = (1 * 2) / 2 = 1
• Induction:
Assume equation holds for n = i,
then show that it holds for n = (i+1)
1+2+…+i = (i*(i+1))/2 // Assumption
1 + 2 + … + i + (i+1) = (i*(i+1))/2 + (i+1)
= (i*(i+1) + 2*(i+1))/2
= ((i+1) * (i+2))/2
V = {x,y,z}
I = x ∙ ¬y ∙ z
010 110 011 111
T = (x’ ⟷ ¬x) ∙ (y’ ⟷ y) ∙ (z ⟷ (x ∣ z))
Bad = x∙y
Good = ¬(x∙y) Not inductive
000 100 001 101
Inductive Invariants
• An inductive invariant for a state machine is any property 𝛷(V) such that:
I(V) 𝛷(V)
𝛷(V) ∧ T(V,V’) 𝛷(V’)
V = {x,y,z}
I = x∙¬y∙z
010 110 011 111
T = (x’ ⟷ ¬x) ∙ (y’ ⟷ y) ∙ (z ⟷ (x ∣ z))
Bad = x∙y
Good = ¬(x∙y) Not inductive
Reach = ¬y∙z Inductive 000 100 001 101
V = {x,y,z}
I = x∙¬y∙z
010 110 011 111
T = (x’ ⟷ ¬x) ∙ (y’ ⟷ y) ∙ (z ⟷ (x ∣ z))
Bad = x∙y
Good = ¬(x∙y) Not inductive
Reach = ¬y∙z Inductive 000 100 001 101
𝛷 = ¬y Inductive
V = {x,y,z}
I = x∙¬y∙z
010 110 011 111
T = (x’ ⟷ ¬x) ∙ (y’ ⟷ y) ∙ (z ⟷ (x ∣ z))
Bad = x∙y
Good = ¬(x∙y) Not inductive
Reach = ¬y∙z Inductive 000 100 001 101
𝛷 = ¬y Inductive
Summary
References
• Model Checking
• E. A. Emerson and E. M. Clarke, “Characterizing Correctness Properties of Parallel Programs as Fixpoints”, Proceedings
of the Seventh International Colloquium on Automata, Languages, and Programming, LNCS, Vol. 85, 1981.
• E.M. Clarke, E. A. Emerson and A. P. Sistla, “Automatic verification of finite-state concurrent systems using temporal
logic specifications,” ACM Transactions on Programming Languages and Systems, Vol. 8, No. 2, April 1986.
• J-P. Queille and J. Sifakis, “Specification and Verification of Concurrent Systems,” CESAR International Symposium on
Programming, LNCS, Vol. 137, 1982
• BDDs and Symbolic Model Checking
• R.E. Bryant, “Graph-Based Algorithms for Boolean Function Manipulation,” IEEE Transactions on Computers, Vol. C -
35, No. 8, August, 1986
• O. Coudert, C. Berthet and J.C. Madre, “Verification of Synchronous Sequential Machines Based on Symbolic
Execution,” International Workshop on Automatic Verification Methods for Finite State Systems, 1989
• J.R. Burch, E. M. Clarke, K. L. McMillan, D. L. Dill, and J. Hwang, “Symbolic model checking: 1020 states and beyond,”
5th Ann. Symposium on Logic in Computer Science, June 1990
UT Austin College of ECE - [Link] of Digital Systems, 5th March 2020
References
References
• Textbooks
• E.M. Clarke, O. Grumberg and D.A. Peled, “Model Checking,” MIT Press, 1999
• T. Kropf, “Introduction to Formal Hardware Verification”, Springer-Verlag, 1999