Equivalence Checking of Sequential Circuits

Similar documents
Finite-State Model Checking

Fundamental Algorithms for System Modeling, Analysis, and Optimization

ESE535: Electronic Design Automation. Today. Motivation. FSM Equivalence. Question. Cornerstone Result. Sequential Verification

Computational Boolean Algebra. Pingqiang Zhou ShanghaiTech University

Lecture 10: Synchronous Sequential Circuits Design

EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

EECS150 - Digital Design Lecture 23 - FSMs & Counters

1 Algebraic Methods. 1.1 Gröbner Bases Applied to SAT

Review for B33DV2-Digital Design. Digital Design

Overview. Discrete Event Systems Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for?

Chapter 4. Sequential Logic Circuits

FSM model for sequential circuits

Sequential Synchronous Circuit Analysis

Digital Logic and Design (Course Code: EE222) Lecture 19: Sequential Circuits Contd..

Building a Computer Adder

Sequential Logic Circuits

Introduction to Embedded Systems

Multi-Level Logic Optimization. Technology Independent. Thanks to R. Rudell, S. Malik, R. Rutenbar. University of California, Berkeley, CA

CE1911 LECTURE FSM DESIGN PRACTICE DAY 1

Example: vending machine

Boolean Algebra, Gates and Circuits

Sequential Equivalence Checking - I

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec 09 Counters Outline.

Notes for Lecture 3... x 4

Every time has a value associated with it, not just some times. A variable can take on any value within a range

CPE100: Digital Logic Design I

CprE 281: Digital Logic

Chapter 2 Combinational Logic Circuits

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary

Ch 7. Finite State Machines. VII - Finite State Machines Contemporary Logic Design 1

UC Berkeley College of Engineering, EECS Department CS61C: Representations of Combinational Logic Circuits

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process

Logic and Boolean algebra

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

Example: A vending machine

Binary Decision Diagrams

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

Finite State Machine. By : Ali Mustafa

Chapter 2 Combinational Logic Circuits

Time Allowed 3:00 hrs. April, pages

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving III & Binary Decision Diagrams. Sanjit A. Seshia EECS, UC Berkeley

Lecture 2: Symbolic Model Checking With SAT

211: Computer Architecture Summer 2016

L10 State Machine Design Topics

6. Finite State Machines

Sequential Logic (3.1 and is a long difficult section you really should read!)

ENGG 1203 Tutorial. Solution (b) Solution (a) Simplification using K-map. Combinational Logic (II) and Sequential Logic (I) 8 Feb Learning Objectives

Notes for Lecture 3... x 4

Binary Decision Diagrams and Symbolic Model Checking

CS294: Pseudorandomness and Combinatorial Constructions September 13, Notes for Lecture 5

Lecture notes on Turing machines

Sequential logic and design

EECS150 - Digital Design Lecture 19 - Combinational Logic Circuits : A Deep Dive

CS 21 Decidability and Tractability Winter Solution Set 3

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

Introduction to Karnaugh Maps

Umans Complexity Theory Lectures

Lecture 8: Complete Problems for Other Complexity Classes

EECS150 - Digital Design Lecture 16 Counters. Announcements

CPE100: Digital Logic Design I

ECE 2300 Digital Logic & Computer Organization

Models of Sequential Systems

Undecidability and Rice s Theorem. Lecture 26, December 3 CS 374, Fall 2015

COE 202: Digital Logic Design Sequential Circuits Part 3. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Z = F(X) Combinational circuit. A combinational circuit can be specified either by a truth table. Truth Table

Chapter 5 Synchronous Sequential Logic

Sequential Circuit Analysis

CSC9R6 Computer Design. Practical Digital Logic

CS 172: Computability and Complexity. Introduction and Course Overview. Sanjit A. Seshia EECS, UC Berkeley

Sanjit A. Seshia EECS, UC Berkeley

CS/COE1541: Introduction to Computer Architecture. Logic Design Review. Sangyeun Cho. Computer Science Department University of Pittsburgh

Mathematical Logic Part Three

Logic Design. Chapter 2: Introduction to Logic Circuits

Finite-state machines (FSMs)

Fundamentals of Digital Design

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

1 Locally computable randomized encodings

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 7 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

CSE140: Components and Design Techniques for Digital Systems. Midterm Information. Instructor: Mohsen Imani. Sources: TSR, Katz, Boriello & Vahid

Sequential Circuit Design

S C F F F T T F T T S C B F F F F F T F T F F T T T F F T F T T T F T T T

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

14.1. Unit 14. State Machine Design

( c) Give logic symbol, Truth table and circuit diagram for a clocked SR flip-flop. A combinational circuit is defined by the function

Lecture 6: Manipulation of Algebraic Functions, Boolean Algebra, Karnaugh Maps

Digital Logic Design. Midterm #2

CHAPTER1: Digital Logic Circuits Combination Circuits

Combinational Logic. Review of Combinational Logic 1

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

Appendix A: Digital Logic. Principles of Computer Architecture. Principles of Computer Architecture by M. Murdocca and V. Heuring

MC9211 Computer Organization

Week-I. Combinational Logic & Circuits

ENGG 1203 Tutorial_9 - Review. Boolean Algebra. Simplifying Logic Circuits. Combinational Logic. 1. Combinational & Sequential Logic

Combinational Logic. Course Instructor Mohammed Abdul kader

COE 202: Digital Logic Design Sequential Circuits Part 3. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

CS61c: Representations of Combinational Logic Circuits

Transcription:

Equivalence Checking of Sequential Circuits Sanjit Seshia EECS UC Berkeley With thanks to K. Keutzer, R. Rutenbar 1 Today s Lecture What we know: How to check two combinational circuits for equivalence What we need: Checking equivalence of sequential circuits E.g., a circuit and its retimed version Today s lecture is about using Boolean function manipulation & BDDs for doing this Basics Sequential equivalence checking: the problem Algorithms S. Seshia 2 1

Recap: Cofactors A Boolean function F of n variables x 1, x 2,, x n F : {0,1} n {0,1} Cofactors of F: F x1 (x 2,, x n ) =? F x1 (x 2,, x n ) =? S. Seshia 3 Two Operations on Cofactors Given: F(x 1,, x n ) Define 1. C(x 2,, x n ) = F x1. F x1 2. S(x 2,, x n ) = F x1 + F x1 Consensus Smoothing What do C and S look like in terms of the ON-sets of F x1 and F x1? S. Seshia 4 2

Example F(a,b,c) = ab + bc + ac F a = b + c F a = bc C(b,c) =? S(b,c) =? S. Seshia 5 Quantification Consensus also called universal quantification C(x 2,, x n ) = F x1. F x1 = x 1 F(x 1, x 2,, x n ) ( for all x 1 ) Smoothing also called existential quantification S(x 2,, x n ) = F x1 + F x1 = x 1 F(x 1, x 2,, x n ) ( there exists x 1 ) S. Seshia 6 3

Back to Equivalence Checking... S. Seshia 7 Equivalence Checking: Simple Case Combinational logic Combinational logic Combinational logic ``specification Combinational logic Combinational logic Combinational logic implementation S. Seshia 8 4

Retimed circuits a b 0 1 d q a b 0 1 d q s s Circuits are equivalent but it is not possible to show that they are equivalent using Boolean equivalence S. Seshia 9 Encoding Problems Some logic specifications are symbolic rather than binary-valued e.g. specification for an ALU Symbol Operation ADD + SUB - XOR Exclusive-OR INC Increment Can assign any binary op code to the symbolic values, so long as they are different S. Seshia 10 5

Different State Encodings Circuit 1 Symbol Operation ADD 00 SUB 01 XOR 10 INC 11 Circuit 2 Symbol Operation ADD 11 SUB 10 XOR 00 INC 01 Different state encodings make circuits no longer amenable to combinational logic equivalence checking S. Seshia 11 Different Encodings x 32 alu_out x 32 alu_out y 32 2 y 32 2 ALU ``ADD s on 00 ALU ``ADD s on 11 S. Seshia 12 6

A Fresh Look at Equivalence Checking Given: Two sequential circuits, with same inputs and outputs But state bits might differ Let s view this problem mathematically ( formally ): A combinational circuit is a Boolean function. A sequential circuit is a S. Seshia 13 What s in a Finite-State Machine (FSM)? FF? Next State logic Next state inputs Output logic outputs S. Seshia 14 7

Finite-state machine (FSM) Equivalence Equivalence checking problem: Given: 2 FSMs, with same inputs/outputs To check: The output behavior of both machines is identical over all time points, starting from a common initial / reset state for every sequence of inputs S. Seshia 15 Visualizing the Problem FSM 1 inputs outputs = Always 1? FSM 2 Q1. What goes inside the boxes? Q2. How can we decide if the output is always 1? S. Seshia 16 8

What goes in the boxes From the finite-state machine description, we write Boolean equations that describe 1. Next state as a function of present state & inputs 2. Output as a function of present state & inputs Most often this is how the system is most easily described S. Seshia 17 Example: FSM1 pq = 00 pq = 01 x=0 A/0 B/0 x=0 Denote next state encoding as p + q + and output as z p + (x, p, q) =? pq + p x C/0 D/1 pq = 10 pq = 11 q + (x, p, q) =? p x + p q z(x, p, q) =? pq S. Seshia 18 9

Example: FSM 2 (different state encoding) abcd = 1000 abcd = 0100 x=0 x=0 A/0 B/0 Denote next state encoding as a + b + c + d + and output as z a + (x, a, b, c, d) =? C/0 D/1 abcd = 0010 abcd = 0001 b + (x, a, b, c, d) =? c + (x, a, b, c, d) =? d + (x, a, b, c, d) =? NOTE: We never start with a state graph like the one above WHY? z(x, a, b, c, d) = d S. Seshia 19 Back to the Problem inputs FSM 1 p + = pq + p x q + = p x + p q z = pq a + = d b + = ax + bx c + = ax + c d + = bx z = d outputs FSM 2 Q1. What goes inside the boxes? Q2. How can we decide if the output is always 1? S. Seshia 20 = Always 1? 10

Rephrasing the Problem Is the output always 1? Can the output ever be 0? Solved using reachability analysis Is there a state that the combined FSM can reach such that the output is 0? S. Seshia 21 Performing Reachability Analysis 3 Main ideas: 1. Represent sets as Boolean functions Use BDDs 2. Represent FSMs symbolically FSM = set of states and set of transitions FSM can be encoded using BDDs 3. Perform Symbolic Reachability Analysis Start in initial state Compute set of states reachable from initial state in 1, 2, 3, clock ticks This computation must terminate WHY? S. Seshia 22 11

1. Sets as Boolean functions A Boolean function F of n variables x1, x2,, xn F : {0,1}n {0,1} can be represented as set Mapped to 0 Mapped to 1 Similarly, for a set of size <= 2 n, you can encode each element as a string of <= n bits Each string can be viewed as a minterm View the set as the ON-SET of a Boolean function S. Seshia 23 Set Operations as Boolean Operations A B =? A B =? A B =? Is A empty? S. Seshia 24 12

2. Symbolic Encoding of FSM FSM is Set of states Each state is a minterm This is what we want to compute! Set of transitions To compute set of reachable states, we first need a way of encoding transitions WHY NOT just enumerate all the states by repeatedly evaluating equations, starting from an initial state? S. Seshia 25 Encoding Transitions Define a new function, δ, called the transition relation δ (current state s, input x, next state s + ) = 1 if we can go to s + from s on x = 0 otherwise i.e. δ encodes all legal transitions ( edges in the state graph) S. Seshia 26 13

Example of δ pq = 00 pq = 01 x=0 A/0 B/0 x=0 Denote next state encoding as p + q + and output as z δ(p, q, x, p +, q + ) C/0 D/1 pq = 10 p + = pq + p x q + = p x + p q z = pq pq = 11 δ(0, 0, 0, 0, 1) =? δ(1, 1, 1, 1, 1) =? How to construct δ? Pick an edge & encode it x=0 A/0 B/0 Add a term into the SOP for δ for that edge δ = p q x p q + There s an easier way S. Seshia 27 3. Reachability Analysis Given: 1. A minterm corresponding to initial state R 0 2. δ To find: All states reachable from R 0 in 1, 2, 3, clock ticks Strategy: Denote set of states reachable from R 0 in k (or less) clock ticks as R k Express R k as a function of R k-1 and δ and solve recurrence relation Remember: Every set is represented as a Boolean function (BDD) S. Seshia 28 14

What s the initial state? START pq = 00 pq = 01 A/0 x=0 B/0 x=0 abcd = 1000 abcd = 0100 x=0 x=0 A/0 B/0 C/0 D/1 pq = 10 pq = 11 C/0 D/1 abcd = 0010 abcd = 0001 Start state for combined FSM is pqabcd = 001000 = R 0 S. Seshia 29 Computing R k, k >= 1 What s the relation between R k and R k+1? (think in terms of sets) R k+1 R k s x s + S. Seshia 30 15

Computing R k, k >= 1 To get from R k to R k+1 there must be some triple (s, x, s + ) such that: 1. s R k 2. s + R k+1 3. δ(s, x, s + ) = 1 R k+1 R k s x s + S. Seshia 31 Looking at it another way Suppose I gave you a s + and asked you whether it was in R k+1, i.e.: Is R k+1 (s + ) = 1? Can you phrase the answer to this question in terms of R k and δ? (say in English) Either 1. s + is in R k, i.e., R k (s + ) = 1 Or 2. There exist current state s and input x such that: R k (s) = 1 δ(s, x, s + ) = 1 S. Seshia 32 16

Writing out an equation for R k+1 R k+1 (s + ) = R k (s + ) + s, x { R k (s). δ(s, x, s + ) } Either 1. s + is in R k, i.e., R k (s + ) = 1 Or 2. There exist current state s and input x such that: R k (s) = 1 δ(s, x, s + ) = 1 S. Seshia 33 Computing R k Start with R 0 Repeatedly compute R k+1 as: R k+1 (s + ) = R k (s + ) + s, x { R k (s). δ(s, x, s + ) } Note: everything is represented as a Boolean function When do we stop? S. Seshia 34 17

Termination When R k and R k+1 are the same Why is this guaranteed to happen? R k+1 R k s x s + S. Seshia 35 Recap of Reachability Analysis 1. Compute start state R 0 2. Compute expression for δ 3. Repeatedly compute R k until termination criterion is true 4. Resulting R k for largest k is the set of all states reachable from R 0 S. Seshia 36 18

Sequential Equivalence Checking 1. Connect the two FSMs to form combined FSM 2. Compute combined start state R 0 3. Compute expression for δ 4. Repeatedly compute R k until termination criterion is true 5. Resulting R k for largest k is the set of all states reachable from R 0 6. Check if any of these states can generate output 0 (showing that the two FSM outputs are different) S. Seshia 37 Summary Sequential equivalence checking can be done using FSM reachability analysis In practice, very computationally intensive Memory intensive: BDDs can grow quite big Currently limited to a few hundred state bits Scaling this up is an active area of research New techniques based on SAT solving are available S. Seshia 38 19