Sequential Logic Optimization. Optimization in Context. Algorithmic Approach to State Minimization. Finite State Machine Optimization

Similar documents
Example: vending machine

Boolean cubes EECS150. Mapping truth tables onto cubes. Simplification. The Uniting Theorem. Three variable example

Synchronous Sequential Circuit Design. Dr. Ehab A. H. AL-Hialy Page 1

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

EECS150 - Digital Design Lecture 23 - FSMs & Counters

Example: A vending machine

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

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

The Design Procedure. Output Equation Determination - Derive output equations from the state table

Ch 9. Sequential Logic Technologies. IX - Sequential Logic Technology Contemporary Logic Design 1

L10 State Machine Design Topics

Digital Design. Sequential Logic

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Sequential logic and design

Let s now begin to formalize our analysis of sequential machines Powerful methods for designing machines for System control Pattern recognition Etc.

Different encodings generate different circuits

Finite State Machine (FSM)

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

Synchronous Sequential Circuit Design

15.1 Elimination of Redundant States

CSE 140 Midterm 2 Tajana Simunic Rosing. Spring 2008

14.1. Unit 14. State Machine Design

Lecture 10: Synchronous Sequential Circuits Design

Sequential Circuit Design

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

Synchronous Sequential Circuit Design. Digital Computer Design

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value

EGR224 F 18 Assignment #4

CPE100: Digital Logic Design I

BER KELEY D AV IS IR VINE LOS AN GELES RIVERS IDE SAN D IEGO S AN FRANCISCO

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BENG (HONS) ELECTRICAL & ELECTRONICS ENGINEERING EXAMINATION SEMESTER /2017

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

Review. EECS Components and Design Techniques for Digital Systems. Lec 06 Minimizing Boolean Logic 9/ Review: Canonical Forms

Total time is: 1 setup, 2 AND, 3 XOR, 1 delay = (1*1) + (2*2) + (3*3) + (1*1) = 15ns

EECS150 - Digital Design Lecture 17 - Sequential Circuits 3 (Counters)

EEE2135 Digital Logic Design

Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS

Principles of Computer Architecture. Appendix B: Reduction of Digital Logic. Chapter Contents

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

ENGG 1203 Tutorial _03 Laboratory 3 Build a ball counter. Lab 3. Lab 3 Gate Timing. Lab 3 Steps in designing a State Machine. Timing diagram of a DFF

Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

Chapter 6. Synchronous Sequential Circuits

Models for representing sequential circuits

CS137: Electronic Design Automation. Today. Input Encoding. Output Encoding. State Encoding. Finite-State Machine. Encoding

5 State Minimisation. university of applied sciences hamburg. Digital Systems. Prof. Dr. J. Reichardt Prof. Dr. B. Schwarz

CprE 281: Digital Logic

For smaller NRE cost For faster time to market For smaller high-volume manufacturing cost For higher performance

FSM model for sequential circuits

ASYNCHRONOUS SEQUENTIAL CIRCUITS

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

State Graphs FSMs. Page 1

Present Next state Output state w = 0 w = 1 z A A B 0 B A C 0 C A C 1

Fundamentals of Computer Systems

Finite State Machine. By : Ali Mustafa

Mealy & Moore Machines

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Instructor: Mohsen Imani. Slides from Tajana Simunic Rosing

Sequential Synchronous Circuit Analysis

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Chapter 5 Synchronous Sequential Logic

EECS150 - Digital Design Lecture 16 Counters. Announcements

Reg. No. Question Paper Code : B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER Second Semester. Computer Science and Engineering

Final Exam. ECE 25, Spring 2008 Thursday, June 12, Problem Points Score Total 90

Digital Electronics Sequential Logic

CE Optimized State Machines

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

CPE100: Digital Logic Design I

6 Synchronous State Machine Design

CprE 281: Digital Logic

Lecture (08) Synchronous Sequential Logic

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

Programmable Logic Devices

Fundamentals of Computer Systems

EECS150 - Digital Design Lecture 15 SIFT2 + FSM. Recap and Outline

Clocked Synchronous State-machine Analysis

ELEC Digital Logic Circuits Fall 2014 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10)

Department of Electrical and Computer Engineering University of Wisconsin Madison. Fall Final Examination

Lecture 17: Designing Sequential Systems Using Flip Flops

Fundamentals of Digital Design

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

Department of Electrical and Computer Engineering University of Wisconsin Madison. Fall Midterm Examination CLOSED BOOK

Synchronous Sequential Logic

COMBINATIONAL LOGIC FUNCTIONS

Clocked Sequential Circuits UNIT 13 ANALYSIS OF CLOCKED SEQUENTIAL CIRCUITS. Analysis of Clocked Sequential Circuits. Signal Tracing and Timing Charts

FSM Optimization. Counter Logic Diagram Q1 Q2 Q3. Counter Implementation using RS FF 10/13/2015

Section 3: Combinational Logic Design. Department of Electrical Engineering, University of Waterloo. Combinational Logic

Digital Logic Design - Chapter 5

FYSE420 DIGITAL ELECTRONICS

Generalized FSM model: Moore and Mealy

Sequential Equivalence Checking - I

Spiral 2-1. Datapath Components: Counters Adders Design Example: Crosswalk Controller

CprE 281: Digital Logic

Lecture 8: Sequential Networks and Finite State Machines

Logical design of digital systems

Last lecture Counter design Finite state machine started vending machine example. Today Continue on the vending machine example Moore/Mealy machines

Topic 8: Sequential Circuits

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

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

Analysis of clocked sequential networks

Digital Control of Electric Drives

Transcription:

Sequential Logic Optimization! State Minimization " Algorithms for State Minimization! State, Input, and Output Encodings " Minimize the Next State and Output logic Optimization in Context! Understand the word specification! Draw a picture! Derive a state diagram and Symbolic State Table! Determine an implementation approach (e.g., gate logic, ROM, FPGA, etc.)! Perform STATE MINIMIZATION! Perform STATE ASSIGNMENT! Map Symbolic State Table to Encoded State Tables for implementation (INPUT and OUTPUT encodings)! You can specify a specific state assignment in your Verilog code through parameter settings CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 1 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 2 Finite State Machine Optimization! State Minimization " Fewer states require fewer state bits " Fewer bits require fewer logic equations! Encodings: State, Inputs, Outputs " State encoding with fewer bits has fewer equations to implement # However, each may be more complex " State encoding with more bits (e.g., one-hot) has simpler equations # Complexity directly related to complexity of state diagram " Input/output encoding may or may not be under designer control Algorithmic Approach to State Minimization! Goal identify and combine states that have equivalent behavior! Equivalent States: " Same output " For all input combinations, states transition to same or equivalent states! Algorithm Sketch " 1. Place all states in one set " 2. Initially partition set based on output behavior " 3. Successively partition resulting subsets based on next state transitions " 4. Repeat (3) until no further partitioning is required # states left in the same set are equivalent " Polynomial time procedure CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 3 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 4 State Minimization Example! Sequence Detector for 0 or 0 0/0 S1 0/0 1/0 S0 S3 S4 S5 S6 1/0 1/0 1/0 1/0 0/0 0/1 0/0 0/1 Input Next State Output Sequence Present State =0 =1 =0 =1 Reset S0 S1 S2 0 0 0 S1 S3 S4 0 0 1 S2 S5 S6 0 0 S3 S0 S0 0 0 S4 S0 S0 1 0 S5 S0 S0 0 0 S6 S0 S0 1 0 1/0 S2 0/0 1/0 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 5 Method of Successive Partitions Input Next State Output Sequence Present State =0 =1 =0 =1 Reset S0 S1 S2 0 0 0 S1 S3 S4 0 0 1 S2 S5 S6 0 0 S3 S0 S0 0 0 S4 S0 S0 1 0 S5 S0 S0 0 0 S6 S0 S0 1 0 ( S0 S1 S2 S3 S4 S5 S6 ) ( S0 S1 S2 S3 S5 ) ( S4 S6 ) ( S0 S1 S2 ) ( S3 S5 ) ( S4 S6 ) ( S0 ) ( S1 S2 ) ( S3 S5 ) ( S4 S6 ) CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 6 S1 is equivalent to S2 S3 is equivalent to S5 S4 is equivalent to S6

Minimized FSM! State minimized sequence detector for 0 or 0 Input Next State Output Sequence Present State =0 =1 =0 =1 Another Example! 4-Bit Sequence Detector: output 1 after each 4-bit input sequence consisting of the binary strings or Reset S0 S1' S1' 0 0 0 + 1 S1' S3' S4' 0 0 0 S3' S0 S0 0 0 1 S4' S0 S0 1 0 0/0 S0 /0 S1 1/0 7 States reduced to 4 States 3 bit encoding replaced by 2 bit encoding S3 S4 /0 0/1 1/0 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 7 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 8 State Transition Table! Group states with same next state and same outputs Iterate the Row Matching Algorithm S S 7 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 9 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - Iterate One Last Time Final Reduced State Machine S 3 S 4 15 states (min 4 FFs) reduced to 7 states (min 3 FFs) CS 150 - Spring 27 Lec #21: Seq Logic Optimization - CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 12

More Complex State Minimization! Multiple input example S0 S1 [1] S2 S3 [1] S4 [1] S5 inputs here present next state output state S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S4 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 symbolic state transition table CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 13 Minimized FSM! Implication Chart Method " Cross out incompatible states based on outputs " Then cross out more cells if indexed chart entries are already crossed out S1 S2 S3 S4 S5 S0-S1 S1-S3 S2-S2 S3-S4 S0-S0 S1-S1 S2-S2 S3-S5 S0-S1 S3-S0 S1-S4 S4-S5 S1-S0 S3-S1 S2-S2 S4-S5 present next state output state S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S4 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 present next state output state S0' S0' S1 S2 S3' 1 S1 S0' S3' S1 S3' 0 S2 S1 S3' S2 S0' 1 S3' S1 S0' S0' S3' 0 S0-S1 S1-S1 S3-S4 S0-S4 S1-S0 S4-S0 S4-S5 S5-S5 minimized state table S0 S1 S2 S3 S4 (S0==S4) (S3==S5) CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 14 Minimizing Incompletely Specified FSMs Minimizing States May Not Yield Best Circuit! Equivalence of states is transitive when machine is fully specified! But its not transitive when don't cares are present e.g., state output S0 0 S1 is compatible with both S0 and S2 S1 1 but S0 and S2 are incompatible S2 1! No polynomial time algorithm exists for determining best grouping of states into equivalent sets that will yield the smallest number of final states! Example: edge detector - outputs 1 when last two input changes from 0 to 1 [1] Q 1 Q 0 Q + 1 Q + 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 0 Q 1 + = (Q 1 xor Q 0 ) Q 0 + = Q 1 Q 0 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 15 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 16 Another Implementation of Edge Detector! "Ad hoc" solution - not minimal but cheap and fast [1] State Assignment! Choose bit vectors to assign to each symbolic state " With n state bits for m states there are 2 n! / (2 n m)! [log n <= m <= 2 n ] " 2 n codes possible for 1st state, 2 n 1 for 2nd, 2 n 2 for 3rd, " Huge number even for small values of n and m # Intractable for state machines of any size # Heuristics are necessary for practical solutions " Optimize some metric for the combinational logic # Size (amount of logic and number of FFs) # Speed (depth of logic and fanout) # Dependencies (decomposition) CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 17 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 18

State Assignment Strategies! Possible Strategies " Sequential just number states as they appear in the state table " Random pick random codes " One-hot use as many state bits as there are states (bit=1 > state) " Output use outputs to help encode states " Heuristic rules of thumb that seem to work in most cases! No guarantee of optimality another intractable problem One-hot State Assignment! Simple " Easy to encode, debug! Small Logic Functions " Each state function requires only predecessor state bits as input! Good for Programmable Devices " Lots of flip-flops readily available " Simple functions with small support (signals its dependent upon)! Impractical for Large Machines " Too many states require too many flip-flops " Decompose FSMs into smaller pieces that can be one-hot encoded! Many Slight Variations to One-hot " One-hot + all-0 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 19 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 20 State Maps and Counting Bit Changes Bit Change Heuristic S 0 0 1 S 1 S 2 S 3 S 4 S0 -> S1: 2 1 S0 -> S2: 3 1 S1 -> S3: 3 1 S2 -> S3: 2 1 S3 -> S4: 1 1 S4 -> S1: 2 2 Total: 13 7 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 21 Adjacency Heuristics for State Assignment! Adjacent codes to states that share a common next state " Group 1's in next state map a I Q Q + O i a c j i b c k I Q Q + O i a b j k a c l c = i * a + i * b! Adjacent codes to states that share a common ancestor state " Group 1's in next state map a i / j k / l b = i * a c = k * a! Adjacent codes to states that have a common output behavior " Group 1's in output map I Q Q + O j = i * a + i * c a i a b j b = i * a i c d j d = i * c CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 22 i / j b b i / j c b i / k c c i / j d Heuristics for State Assignment Heuristics for State Assignment Successor/Predecessor Heuristics! High Priority: S 3 and S 4 share common successor state (S 0 )! Medium Priority: S 3 and S 4 share common predecessor state (S 1 )! Low Priority: " 0/0: S 0, S 1, S 3 " 1/0: S 0, S 1, S 3, S 4 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 23 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 24

Another Example Example Continued High Priority: S 3, S 4 S 7, S Medium Priority: S 1, S 2 2 x S 3, S 4 S 7, S Low Priority: 0/0: S 0, S 1, S 2, S 3, S 4, S 7 1/0: S 0, S 1, S 2, S 3, S 4, S 7, S! Choose assignment for S0 = 0! Place the high priority adjacency state pairs into the State Map! Repeat for the medium adjacency pairs! Repeat for any left over states, using the low priority scheme Two alternative assignments at the left CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 25 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 26 Why Do These Heuristics Work?! Attempt to maximize adjacent groupings of 1 s in the next state and output functions General Approach to Heuristic State Assignment! All current methods are variants of this " 1) Determine which states attract each other (weighted pairs) " 2) Generate constraints on codes (which should be in same cube) " 3) Place codes on Boolean cube so as to maximize constraints satisfied (weighted sum)! Different weights make sense depending on whether we are optimizing for two-level or multi-level forms! Can't consider all possible embeddings of state clusters in Boolean cube " Heuristics for ordering embedding " To prune search for best embedding " Expand cube (more state bits) to satisfy more constraints CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 27 CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 28 Output-Based Encoding! Reuse outputs as state bits - use outputs to help distinguish states " Why create new functions for state bits when output can serve as well " Fits in nicely with synchronous Mealy implementations Inputs Present State Next State Outputs C TL TS ST H F 0 HG HG 0 0 HG HG 0 1 1 HG HY 1 0 HY HY 0 1 HY FG 1 1 0 FG FG 0 0 FG FY 1 1 FG FY 1 0 FY FY 0 1 FY HG 1 HG = ST H1 H0 F1 F0 + ST H1 H0 F1 F0 Output patterns are unique to states, we do not HY = ST H1 H0 F1 F0 + ST H1 H0 F1 F0 need ANY state bits implement 5 functions FG = ST H1 H0 F1 F0 + ST H1 H0 F1 F0 (one for each output) instead of 7 (outputs plus HY = ST H1 H0 F1 F0 + ST H1 H0 F1 F0 2 state bits) CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 29 Current State Assignment Approaches! For tight encodings using close to the minimum number of state bits " Best of random seems to be adequate (averages as well as heuristics) " Heuristic approaches are not even close to optimality " Used in custom chip design! One-hot encoding " Easy for small state machines " Generates small equations with easy to estimate complexity " Common in FPGAs and other programmable logic! Output-based encoding " Ad hoc - no tools " Most common approach taken by human designers " Yields very small circuits for most FSMs CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 30

Sequential Logic Implementation Summary! Implementation of sequential logic " State minimization " State assignment! Implications for programmable logic devices " When logic is expensive and FFs are scarce, optimization is highly desirable (e.g., gate logic, PLAs, etc.) " In ilinx devices, logic is bountiful (4 and 5 variable TTs) and FFs are many (2 per CLB), so optimization is not so crucial an issue as in other forms of programmable logic " This makes sparse encodings like One-Hot worth considering CS 150 - Spring 27 Lec #21: Seq Logic Optimization - 31