360 likes | 455 Views
Word Level Predicate Abstraction and Refinement for Verifying RTL Verilog. Himanshu Jain Daniel Kroening Natasha Sharygina Edmund Clarke. Carnegie Mellon University. System. Behavioral. Structural/RTL. Gate level (netlists). …………. Introduction. Hardware design. Formal verification
E N D
Word Level Predicate Abstraction and Refinement for Verifying RTL Verilog Himanshu Jain Daniel Kroening Natasha Sharygina Edmund Clarke Carnegie MellonUniversity
System Behavioral Structural/RTL Gatelevel(netlists) ………… Introduction • Hardware design Formal verification support Level of abstraction
Verification support • Languages like Verilog, SystemVerilog, SystemC are close to software • Verification tools must reason about: • Programming languages constructs • Bit-vector semantics (concatenation, extraction) • Concurrency, Objects, Templates
System Behavioral Structural/RTL Gatelevel(netlists) ………… This work Model check
Handling state space explosion • Abstraction for handling state space explosion • Localization reduction [Kurshan ’94] • Tracks values of certain variables (visible) • Predicate Abstraction [Graf and Saidi ’97] • Keeps tracks of certain predicates on data • Captures relationship between variables • Successfully used in software verification
Abstraction-Refinement loop Initial Abstraction Verification No erroror bug found VerilogProgram ModelChecker Abstract model Property holds Counterexample Refinement Simulator Simulation sucessful Abstraction refinement Bug found Spurious counterexample
Our approach • Apply predicate abstraction at RTL Level • Allows abstraction using word-levelpredicates • Example: x < y – z, x = {z,z} • Use a SAT solver for computing abstraction • Semantics of bit-wise operators take into account • Obtaining suitable word level predicates • Syntactic weakest pre-conditions of Verilog statements
Related work • SAT-Based Predicate Abstraction [Wang et al.] • Works at netlist level • Refinement introduces bit-level predicates • Vapor tool [Andraus et al.] • Works on RTL level designs • Abstraction to CLU models (equality of terms, uninterpreted functions, predicates) • Lots of other related work
An example module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Property: AG (x = 100 Ç x = 200) Verilog program
Abstraction-Refinement loop Initial Abstraction Verification No erroror bug found VerilogProgram ModelChecker Abstract model Property holds Counterexample Refinement Simulator Simulation sucessful Abstraction refinement Bug found Spurious counterexample
Predicate Abstraction module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Property: AG (x = 100 Ç x = 200) Initial set of predicates: {x = 100, x = 200} Word Level Transition relation: x’ = y Æ y’ = x Verilog program
Computing abstract transitions Computing Most Precise Abstraction Next state Current state Transition Relation + + <x = 100, x = 200> <x’ = 100, x’ = 200> x’ := y y’ := x
Obtain transitions Computing abstract transitions <p1,p2> 10 00 01 … and so on … 11
10 00 01 11 Abstract Model module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Property: AG (x = 100 or x = 200) Initial set of predicates: {x = 100, x = 200} Failure state Initial state Verilog program
Abstraction-Refinement loop Initial Abstraction Verification No erroror bug found VerilogProgram ModelChecker Abstract model Property holds Counterexample Refinement Simulator Simulation sucessful Abstraction refinement Bug found Spurious counterexample
Model checking module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Abstract Model Initial state Failure state 10 00 01 11 Verilog program
Model checking module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Abstract Model Abstract counterexample Initial state Failure state 10 00 01 11 Verilog program
Abstraction-Refinement loop Initial Abstraction Verification No erroror bug found VerilogProgram ModelChecker Abstract model Property holds Counterexample Refinement Simulator Simulation sucessful Abstraction refinement Bug found Spurious counterexample
<x = 100, x= 200> Simulation module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Abstract counterexample Initial state Failure state 10 00 Verilog program Counterexample is spurious
Abstraction-Refinement loop Initial Abstraction Verification No erroror bug found VerilogProgram ModelChecker Abstract model Property holds Counterexample Refinement Simulator Simulation sucessful Abstraction refinement Bug found Spurious counterexample
Refinement • Let length of spurious counterexample be k • Take weakest pre-condition of property for k steps with respect to transition functions
(y = 100 Ç y = 200) weakest precondition x’ := y y’ := x Holds after one step (x’ = 100 Ç x’ = 200) Refinement spurious counterexample Property New predicates y = 100, y = 200 AG (x = 100 Ç x = 200) length =1 +
New abstraction Initial state 1001 0110 Abstract again module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Property: AG (x = 100 or x = 200) Updated set of predicates: {x = 100, x = 200, y=100, y=200} Model check Verilog program
New abstraction Initial state 1001 0110 Property holds! Model checking module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Property: AG (x = 100 or x = 200) Updated set of predicates: {x = 100, x = 200, y=100, y=200} Verilog program
Result module main (clk) input clk; reg [10:0] x, y; initial x= 100, y= 200; always @ (posedge clk) begin x <= y; y <= x; end endmodule Property: AG (x = 100 or x = 200) Property holds! Verilog program
Making it work in practice • Computation of predicate abstraction • Handling of large no. of predicates With 50 predicates there can be 2100 predicate relationships!!
+ + p1 := x = 100 p2 := x = 200 p3 := y = 100 p4 := y = 200 p’1:= x’ = 100 p’2:= x’ = 200 p’3:= y’ = 100 p’4:= y’ = 200 x’ := y y’ := x Partition + + p’3 := y’ = 100 p’4 := y’ = 200 p1 := x = 100 p2 := x = 200 y’ := x + + p’1 := x’ = 100 p’2 := x’ = 200 p3 := y = 100 p4 := y = 200 x’ := y Predicate Partitioning Next state predicates Transition relation Current state predicates Æ
Predicate Partitioning • Speeds up abstraction computation • Introduces over-approximation • Refinement • Handles over-approximation due to predicate partitioning • Generate new predicates
Refinement by removing spurious transitions Abstract transition: <b1=0, b2=1> ) <b’1=0, b’2=0> Spurious Constrain abstraction [Das and Dill]: : (b1=0 Æ b2=1 Æ b’1=0 Æ b’2=0) Proof of unsatisfiabilty (UNSAT) core: : (b2=1 Æ b’1=0)
<x=1, x=2> <1, 0> <0, 0> Refinement by generating new predicates Identify predicates whose weakest pre-condition needs to be computed Init: x=1, y=2 (x=1) Æ:(x=2) PROOFOF UNSATISFIABILITY x’ := y y’ := x Predicate whose Weakest pre-condition is needed :(x’=1) Æ:(x’=2)
Refinement by generating new predicates Blowup in weakest pre-conditions size Only add atomic predicates ((x < 5) ? (x + 2) : x ) = 2 Add x <5 as a new predicate and run the loop again x’ := (x < 5) ? (x + 2) : x x’ = 2
((x < 5) ? (x + 2) : x ) = 2 x’ := (x < 5) ? (x + 2) : x x’ = 2 A counterexample of same length But now we get a value for x < 5 from abstract counterexample (say true) New predicate x + 2 < 3 x’ := x + 2 simplify
Summary • Verification at RTL level without going to netlists • Predicate abstraction using word-level predicates • Handling large no. of predicates (predicate partitioning) • Weakest pre-conditions for obtaining new predicates • Techniques are completely automatic • VCEGAR • Encouraging results on industrial benchmarks • www.cs.cmu.edu/~modelcheck/vcegar