Example: A vending machine

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

Generalized FSM model: Moore and Mealy

Example: vending machine

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

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

Digital Logic Design. Midterm #2

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

Adders allow computers to add numbers 2-bit ripple-carry adder

CPE100: Digital Logic Design I

Sequential Circuit Design

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

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

15.1 Elimination of Redundant States

Design at the Register Transfer Level

Lecture 10: Synchronous Sequential Circuits Design

Module 10: Sequential Circuit Design

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

EGR224 F 18 Assignment #4

Finite State Machine (FSM)

CprE 281: Digital Logic

FYSE420 DIGITAL ELECTRONICS

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

ALU, Latches and Flip-Flops

Timing Constraints in Sequential Designs. 63 Sources: TSR, Katz, Boriello & Vahid

Symbolic State Minimization

Digital Logic Design. Midterm #2

CSE370: Introduction to Digital Design

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

Digital Logic Design - Chapter 5

CprE 281: Digital Logic

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

EECS150 - Digital Design Lecture 23 - FSMs & Counters

CprE 281: Digital Logic

EE141- Spring 2007 Digital Integrated Circuits

Sequential logic and design

CPE100: Digital Logic Design I

EE 209 Spiral 1 Exam Solutions Name:

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

ECE 341. Lecture # 3

Lecture 7: Logic design. Combinational logic circuits

Digital Design. Sequential Logic

Digital Electronics Sequential Logic

Analysis of clocked sequential networks

Sequential Circuit Analysis

Sequential vs. Combinational

Models for representing sequential circuits

Welcome to EECS 150: Components and Design Techniques for Digital Systems

Fundamentals of Digital Design

Welcome to EECS 150: Components and Design Techniques for Digital Systems

Synchronous Sequential Circuit Design. Digital Computer Design

CPE100: Digital Logic Design I

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

Sample Test Paper - I

Sequential Logic Circuits

Digital Circuits ECS 371

Synchronous Sequential Circuit Design

Sequential Synchronous Circuit Analysis

Chapter 7. Synchronous Sequential Networks. Excitation for

EE 209 Logic Cumulative Exam Name:

Time Allowed 3:00 hrs. April, pages

ECE380 Digital Logic. Synchronous sequential circuits

Midterm review session tomorrow 4:15 EEB125 Midterm 2 in class (45min long, starts at 10:35am) Today Abi bigger example: Hungry Robot Ant in Maze

Lecture 10: Sequential Networks: Timing and Retiming

Lecture 14: State Tables, Diagrams, Latches, and Flip Flop

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

Sequential Logic Worksheet

CSE140: Digital Logic Design Registers and Counters

State and Finite State Machines

CS61C : Machine Structures

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

Computers also need devices capable of Storing data and information Performing mathematical operations on such data

State & Finite State Machines

Digital Circuits and Systems

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

CS61C : Machine Structures

State Graphs FSMs. Page 1

Lecture 17: Designing Sequential Systems Using Flip Flops

Different encodings generate different circuits

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

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

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

Chapter 4. Sequential Logic Circuits

Equivalence Checking of Sequential Circuits

ELCT201: DIGITAL LOGIC DESIGN

Introduction EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 6: Sequential Logic 3 Registers & Counters 5/9/2010

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

CE1911 LECTURE FSM DESIGN PRACTICE DAY 1

12. Finite State Machine Design

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

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

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

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

L10 State Machine Design Topics

ELE2120 Digital Circuits and Systems. Tutorial Note 9

ECE 2300 Digital Logic & Computer Organization

Chapter 14 Sequential logic, Latches and Flip-Flops

CSE140: Design of Sequential Logic

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

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

Transcription:

Lecture 22 Logistics HW8 due Monday (6/2), HW9 due Friday (6/6) Ant extra credit due 6/6 Take home extra credit final handed out 6/6 Final exam 6/9 8:30am Review? Last lecture Simplification Today State encoding One-hot encoding Output encoding 1 Example: A vending machine 15 cents for a cup of coffee oesn t take pennies or quarters Reset oesn t provide any change Coin Sensor FSM-design procedure 1. State diagram 2. state-transition table 3. State minimization 4. State encoding 5. ext-state logic minimization 6. Implement the design Vending Machine FSM Clock Open Release Mechanism 2

A vending machine: State minimization 0 5 Reset 10 + present inputs next output state t state t open 0 0 0 0 0 0 1 5 0 1 0 10 0 1 1 5 0 0 5 0 0 1 10 0 1 0 15 0 1 1 10 0 0 10 0 0 1 15 0 1 0 15 0 1 1 15 15 1 15 [open] symbolic state table 3 A vending machine: State encoding present state inputs next state output Q1 Q0 1 0 open 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 1 4

A vending machine: Logic minimization 1 Q1 0 0 1 1 0 1 1 1 X X X X 1 1 1 1 Q0 0 Q1 0 1 1 0 1 0 1 1 X X X X 0 1 1 1 Q0 Open Q1 0 0 1 0 0 0 1 0 X X 1 X 0 0 1 0 Q0 1 = Q1 + + Q0 0 = Q0 + Q0 + Q1 + Q1 OPE = Q1 Q0 5 A vending machine: Implementation 6

State encoding Assume n state bits and m states 2 n! / (2 n m)! possible encodings Example: 3 state bits, 4 states, 1680 possible state assignments Want to pick state encoding strategy that results in optimizing your criteria FSM size (amount of logic and number of FFs) FSM speed (depth of logic and fan-in/fan-out) FSM ease of design or debugging 7 State-encoding strategies o guarantee of optimality An intractable problem Most common strategies Binary (sequential) number states as in the state table Random computer tries random encodings Heuristic rules of thumb that seem to work well e.g. Gray-code try to give adjacent states (states with an arc between them) codes that differ in only one bit position One-hot use as many state bits as there are states Output use outputs to help encode states Hybrid mix of a few different ones (e.g. One-hot + heuristic) 8

One-hot encoding One-hot: Encode n states using n flip-flops Assign a single 1 for each state Example: 0001, 0010, 0100, 1000 Propagate a single 1 from one flip-flop to the next All other flip-flop outputs are 0 The inverse: One-cold encoding Assign a single 0 for each state Example: 1110, 1101, 1011, 0111 Propagate a single 0 from one flip-flop to the next All other flip-flop outputs t are 1 almost one-hot encoding (modified one-hot encoding) Use no-hot (000 0) for the initial (reset state) Assumes you never revisit the reset state till reset again. 9 One-hot encoding (con t) Often the best/convenient approach for FPGAs FPGAs have many flip-flops raw FSM directly from the state diagram + One product term per incoming arc - Complex state diagram complex design - Many states many flip flops 10

Example: A vending machine again 15 cents for a cup of coffee oesn t take pennies or quarters Reset oesn t provide any change Coin Sensor FSM-design procedure 1. State diagram 2. state-transition table 3. State minimization 4. State encoding 5. ext-state logic minimization 6. Implement the design Vending Machine FSM Clock Open Release Mechanism 11 One-hot encoded transition table present state inputs next state output Q 3 Q 2 Q 1 Q 0 3 2 1 0 open Reset ' ' 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 ' ' 1 1 0 0 1 0 0 0 0 0 1 0 0 5 0 1 0 1 0 0 0 1 0 1 0 0 0 0 1 1 10 ' ' 01 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 + 1 0 1 0 0 0 0 15 1 1 [open] 1 1 0 0 0 1 0 0 0 1 12

esigning from the state diagram ' ' ' ' Reset 0 5 10 ' ' 0 = Q 0 1 = Q 0 +Q 1 2 = Q 0 + Q 1 + Q 2 3 = Q 1 + Q 2 + Q 2 + Q 3 OPE = Q 3 + 15 [open] 1 13 Output encoding Reuse outputs as state bits Why create new functions when you can use outputs? Bits from state assignments are the outputs for that state Take outputs directly from the flip-flops Inputs Combinational Logic Outputs State Inputs Storage Elements State Outputs ad hoc - no tools Yields small circuits for most FSMs 14

Vending machine --- already in output encoding form ' ' ' ' Reset 0 5 10 ' ' 0 = Q 0 1 = Q 0 +Q 1 2 = Q 0 + Q 1 + Q 2 3 = Q 1 + Q 2 + Q 2 + Q 3 OPE = Q 3 + 15 [open] 1 15 Example: igital combination lock An output-encoded FSM Punch in 3 values in sequence and the door opens If there is an error the lock must be reset After the door opens the lock must be reset Inputs: sequence of number values, reset Outputs: door open/close new value reset clock open/ 16

Separate data path and control esign datapath first Control has 2 outputs After the state diagram Mux control to datapath Before the state encoding Lock open/ value C1 C2 C3 4 4 4 multiplexer 4 4 comparator mux control new controller reset clock open/ 17 raw the state diagram ERR start not not not S0 S1 S2 S3 mux=c1 mux=c2 mux=c3 open 18

esign the datapath value C1 C2 C3 4 4 4 multiplexer 4 4 comparator mux control value i C1 i C2 i C3 i mux control Choose simple control 3-wire mux for datapath Control is 001, 010, 100 Open/ bit for lock state Control is 0/1 19 Output encode the FSM FSM outputs Mux control is 100, 010, 001 Lock control is 0/1 State are: S0, S1, S2, S3, or ERR Can use 3, 4, or 5 bits to encode Have 4 outputs, so choose 4 bits Encode mux control and lock control in state bits Lock control is first bit, mux control is last 3 bits S0 = 0001 (lock, mux first code) S1 = 0010 (lock, mux second code) S2 = 0100 (lock, mux third code) S3 = 1000 (lock open) ERR = 0000 (error, lock ) 20

FSM has 4 state bits and 2 inputs... Output encoded! Outputs and state bits are the same How do we minimize the logic? FSM has 4 state bits and 2 inputs (, new) 6-variable kmap? otice the state assignment is close to one-hot ERR state (0000) is only deviation Is there a clever design we can use? 21 Encode 4 state bits ERR start mux=c1 not not not S0 S1 S2 S3 open mux=c2 mux=c3 0 = Q 0 1 = Q 0 E + Q 1 2 = Q 1 E + Q 2 3 = Q 2 E + Q 3 Can we encode the ERR state with reset/preset of flipflops? 22

Answer: Yes! ERR start mux=c1 not not not S0 S1 S2 S3 open mux=c2 mux=c3 0 = Q 0 1 = Q 0 E + Q 1 2 = Q 1 E + Q 2 3 = Q 2 E + Q 3 Preset 0 = start Preset 1,2,3 = 0 Reset 0 = start (E + (Q 0 +Q 1 +Q 2 +Q 3 ) ) Reset 1,2,3 = start + (E + (Q 0 +Q 1 +Q 2 +Q 3 ) ) 23 0 = Q 0 1 = Q 0 E + Q 1 2 = Q 1 E + Q 2 3 = Q 2 E + Q 3 Preset 0 = start Preset 1,2,3 = 0 Reset 0 = start (E + (Q 0 +Q 1 +Q 2 +Q 3 ) ) Reset 1,2,3 = start + (E + (Q 0 +Q 1 +Q 2 +Q 3 ) ) 24

FSM design FSM-design procedure 1.State diagram 2. state-transition table 3. State minimization 4. State encoding 5. ext-state logic minimization 6. Implement the design 25