Lecture 8: Sequential Networks and Finite State Machines

Similar documents
CSE 140: Components and Design Techniques for Digital Systems. Lecture 9: Sequential Networks: Implementation

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

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

Finite State Machine. By : Ali Mustafa

Lecture 10: Synchronous Sequential Circuits Design

Sequential Synchronous Circuit Analysis

CSE140: Digital Logic Design Registers and Counters

Lecture (08) Synchronous Sequential Logic

Lecture 7: Sequential Networks

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

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

EEE2135 Digital Logic Design

Fundamentals of Digital Design

Clocked Synchronous State-machine Analysis

Synchronous Sequential Logic

Lecture 10: Sequential Networks: Timing and Retiming

Analysis and Design of Sequential Circuits: Examples

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

Chapter 4 Part 2 Sequential Circuits

Finite State Machine (FSM)

Synchronous Sequential Logic Part I. BME208 Logic Circuits Yalçın İŞLER

CSE 140 Lecture 11 Standard Combinational Modules. CK Cheng and Diba Mirza CSE Dept. UC San Diego

Sequential logic and design

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

Logical design of digital systems

Chapter 5 Synchronous Sequential Logic

ELCT201: DIGITAL LOGIC DESIGN

Digital Circuits and Systems

Lecture 17: Designing Sequential Systems Using Flip Flops

ALU, Latches and Flip-Flops

ELE2120 Digital Circuits and Systems. Tutorial Note 9

Problem Set 9 Solutions

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output of

Synchronous Sequential Logic Part I

Chapter 15 SEQUENTIAL CIRCUITS ANALYSIS, STATE- MINIMIZATION, ASSIGNMENT AND CIRCUIT IMPLEMENTATION

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

Synchronous Sequential Circuit Design. Digital Computer Design

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

FSM model for sequential circuits

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

Memory Elements I. CS31 Pascal Van Hentenryck. CS031 Lecture 6 Page 1

Sequential Logic Circuits

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

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

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

Topic 8: Sequential Circuits

EECS150 - Digital Design Lecture 23 - FSMs & Counters

6 Synchronous State Machine Design

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

CSE 140: Components and Design Techniques for Digital Systems

Models for representing sequential circuits

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

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

(Boolean Algebra, combinational circuits) (Binary Codes and -arithmetics)

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

CE1911 LECTURE FSM DESIGN PRACTICE DAY 1

Chapter 4. Sequential Logic Circuits

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

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

CS61C : Machine Structures

ELCT201: DIGITAL LOGIC DESIGN

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

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

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

CS61C : Machine Structures

CprE 281: Digital Logic

14.1. Unit 14. State Machine Design

Philadelphia University Student Name: Student Number:

Different encodings generate different circuits

Digital Logic Design - Chapter 4

Lecture 3 Review on Digital Logic (Part 2)


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

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

10/12/2016. An FSM with No Inputs Moves from State to State. ECE 120: Introduction to Computing. Eventually, the States Form a Loop

Chapter 6 Introduction to state machines

Homework #4. CSE 140 Summer Session Instructor: Mohsen Imani. Only a subset of questions will be graded

Lecture 4: Four Input K-Maps

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

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

Example: vending machine

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

Digital Design. Sequential Logic

CPE100: Digital Logic Design I

Mealy & Moore Machines

Sequential Circuit Design

EGR224 F 18 Assignment #4

Sequential Circuit Analysis

COEN 312 DIGITAL SYSTEMS DESIGN - LECTURE NOTES Concordia University

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

FYSE420 DIGITAL ELECTRONICS

EE 209 Logic Cumulative Exam Name:

Counters. We ll look at different kinds of counters and discuss how to build them

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

Topic 8: Sequential Circuits. Bistable Devices. S-R Latches. Consider the following element. Readings : Patterson & Hennesy, Appendix B.4 - B.

Digital Control of Electric Drives

Sequential vs. Combinational

14:332:231 DIGITAL LOGIC DESIGN

Digital Logic Design - Chapter 5

CS221: Digital Design. Dr. A. Sahu. Indian Institute of Technology Guwahati

Transcription:

Lecture 8: Sequential Networks and Finite State Machines CSE 140: Components and Design Techniques for Digital Systems Spring 2014 CK Cheng, Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego 1

Sequential Networks Y A B C D Combinational X S(t) CLK CLK 1. Components F-Fs 2. Specification 3. Implementation: Excitation Table CLK 2

Specification Combinational Logic Truth Table Boolean Expression Logic Diagram (No feedback loops) Sequential Networks: State Diagram (Memory) State Table and Excitation Table Characteristic Expression Logic Diagram (FFs and feedback loops) 3

Specification: Finite State Machine Input Output Relation State Diagram (Transition of States) State Table Excitation Table (Truth table of FF inputs) Boolean Expression Logic Diagram 4

Specification: Examples Transition from circuit to finite state machine representation Netlist => State Table => State Diagram => Input Output Relation Example 1: a circuit with D Flip Flops Example 2: a circuit with other Flip Flops 5

Building Sequential Circuits and describing their behavior 6

What we will learn: 1. Given a sequential circuit, describe its behavior over time 2. Given the behavior of a sequential circuit, implement the circuit Sequential Circuit: Wall-E How does Wall-E behave? 7

What does it mean to describe the behavior of a sequential circuit Specify how the output of the circuit changes as a function of inputs and the state of the circuit 8

PI Q: What is the difference between the state of a circuit and its output? A. The output is independent of the state B. The output and state are the same thing C. The state is special type of output that is fed back into the circuit D. The state is input information that is independent of previous outputs 9

State: What is it? Why do we need it? Symbol/ Circuit Behavior over time Free running 2 bit Counter CLK Q 0 time Q 1 What is the expected output of the counter over time? 11

State: What is it? Why do we need it? Symbol/ Circuit Behavior over time 2 bit Counter CLK t 1 t 2 time PI Q: At time t 1, what information is needed to produce the output of the counter at the next rising edge of the clock (i.e t 2 )? A. All the outputs of the counter until t 1 B. The initial output of the counter at time t=0 C. The output of the counter at current time t 1 D. We cannot determine the output of the counter at t 2 prior to t 2 12

State: What is it? Why do we need it? The state is distilled output information that tells us everything we need to know to produce the next output. That is why it is fed back into the circuit. In the case of the 2-bit counter the output (i.e. the current count) is also the state of the counter. But we could have had other outputs that were not part of the state. E.g. A signal that indicated whether the current count is greater than 2. 13

Finite State Machines: Describing circuit behavior over time Symbol/ Circuit Diagram that depicts behavior over time 2 bit Counter 14

State Diagrams: Describing circuit behavior over time PI Q: What information is not explicitly indicated in the state diagram? State diagram of the 2 bit counter A. The input to the circuit B. The output of the circuit C. The time when state transitions occur D. The current state of the circuit. E. The next state of the circuit. S 3 S 0 S 2 S 1 Finite State Machine 15

Implementing the 2 bit counter S 0 Current state Next State S 0 S 1 S 3 S 1 S 1 S 2 S 2 S 3 S 3 S 0 S 2 State Diagram Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1) State Table 16

Implementing the 2 bit counter S 0 Current state Next State S 0 S 1 S 3 S 1 S 1 S 2 S 2 S 3 S 3 S 0 S 2 State Diagram Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1) 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 State Table 17

Implementing the 2 bit counter Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1) 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 State Table PI Q: To obtain the outputs Q 0 (t+1) and Q 1 (t+1) from the inputs Q 1 (t) and Q 0 (t) we need to use: A. Combinational logic B. Some other logic 18

Implementing the 2 bit counter Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1) 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 State Table Q 0 (t) Q 1 (t) Q 0 (t+1) Q 1 (t+1) PI Q: What is wrong with the 2-bit counter implementation shown above A. The combinational circuit is incorrect B. The circuit state changes correctly but continuously rather than at the rising edge of the clock signal C. The output of the circuit is unreliable because inputs can get corrupted 19

Implementing the 2 bit counter Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1) 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 State Table Q 0 (t+1) = Q 0 (t) Q 1 (t+1) = Q 0 (t) Q 1 (t) + Q 0 (t) Q 1 (t) Q 0 (t) Q 1 (t) We store the current state using D-flip flops so that: The inputs to the combinational circuit don t change while the next output is being computed The transition to the next state only occurs at the rising edge of the clock D D Q Q Q Q CLK Implementation of 2-bit counter 20

Implementing the 2 bit counter Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1) 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 State Table Q 0 (t+1) = Q 0 (t) Q 1 (t+1) = Q 0 (t) Q 1 (t) + Q 0 (t) Q 1 (t) Q D Q 0 (t) Q Q D Q Q 1 (t) CLK Implementation of 2-bit counter PI Q: When did we fix our choice of flip flops in the design process? A. When we drew the state diagram B. When we wrote down the state table C. When wrote the characteristic expression D. When we implemented the circuit from the characteristic expression 21

Generalized Model of Sequential Circuits Y X S(t) CLK 22

Modified 2 bit counter x(t) Q 0 (t) Q 1 (t) Q D Q Q D Q CLK Q 0 (t) Q 1 (t) y(t) 23

Modified 2 bit counter x(t) Q 0 (t) Q 1 (t) Q D Q Q D Q CLK Q 0 (t) Q 1 (t) y(t) Characteristic Expression: y(t) = Q 0 (t+1) = Q 1 (t+1) = 24

Modified 2 bit counter x(t) Q 0 (t) Q 1 (t) Q D Q Q D Q CLK Q 0 (t) Q 1 (t) y(t) y(t) = Q 1 (t)q 0 (t) Q 0 (t+1) = D 0 (t) = x(t) Q 0 (t) Q 1 (t+1) = D 1 (t) = x(t) (Q 0 (t) + Q 1 (t)) 25

Netlist! State Table! State Diagram! Input Output Relation Characteristic Expression: y(t) = Q 1 (t)q 0 (t) Q 0 (t+1) = D 0 (t) = x(t) Q 0 (t) Q 1 (t+1) = D 1 (t) = x(t) (Q 0 (t) + Q 1 (t)) State table input PS x=0 x=1 State Assignment input PS x=0 x=1 0 0 0 1 1 0 1 1 S 0 S 1 S 2 S 3 Q 1 (t) Q 0 (t) (Q 1 (t+1) Q 0 (t+1), y(t)) Present State Next State, Output 26

Netlist! State Table! State Diagram! Input Output Relation State table input PS 0 0 0 1 1 0 1 1 y(t) = Q 1 (t)q 0 (t) Q 0 (t+1) = D 0 (t) = x(t) Q 0 (t) Q 1 (t+1) = D 1 (t) = x(t) (Q 0 (t) + Q 1 (t)) x=0 x=1 01, 0 00, 0 10, 0 00, 0 11, 0 00, 0 00, 1 00, 1 Q 1 (t) Q 0 (t) Q 1 (t+1) Q 0 (t+1), y(t) Present State Next State, Output State Assignment Let: S 0 = 00 S 1 = 01 S 2 = 10 S 3 = 11 input PS S 0 S 1 S 2 S 3 x=0 x=1 S 1, 0 S 0, 0 S 2, 0 S 0, 0 S 3, 0 S 0, 0 S 0, 1 S 0, 1 Remake the state table using symbols instead of binary code, e.g. 00 27

Netlist! State Table! State Diagram! Input Output Relation input PS x=0 x=1 S 0 S 1 S 2 S 3 S 0 S 1 S 2 S 3 S 1, 0 S 0, 0 S 2, 0 S 0, 0 S 3, 0 S 0, 0 S 0, 1 S 0, 1 Given inputs and initial state, derive output sequence Time 0 1 2 3 4 5 Input 0 1 0 0 0 - State S0 Output 28

Netlist! State Table! State Diagram! Input Output Relation 1/0 1/0 1/0 S 0 0/0 S 1 0/0 S 2 0/0 S 3 (0 or 1)/1 Example: Given inputs and initial state, derive output sequence x/y input PS Time 0 1 2 3 4 5 Input 0 1 0 0 0 - State S0 S1 S0 S1 S2 S3 Output 0 0 0 0 0 1 S 0 S 1 S 2 S 3 x=0 x=1 S 1, 0 S 0, 0 S 2, 0 S 0, 0 S 3, 0 S 0, 0 S 0, 1 S 0, 1 29

Example 3 Circuit with T Flip-Flops X T 0 T 1 T T Q Q Q Q Q 0 Q 1 y y(t) = Q 1 (t)q 0 (t) T 0 (t) = x(t) Q 1 (t) T 1 (t) = x(t) + Q 0 (t) 37

Logic Diagram => Excitation Table => State Table y(t) = Q 1 (t)q 0 (t) T 0 (t) = x(t) Q 1 (t) T 1 (t) = x(t) + Q 0 (t) Q 0 (t+1) = T 0 (t) Q 0 (t)+t 0 (t)q 0 (t) Q 1 (t+1) = T 1 (t) Q 1 (t)+t 1 (t)q 1 (t) Excitation Table: Truth table of the F-F inputs id Q 1 (t) Q 0 (t) x T 1 (t) T 0 (t) Q 1 (t+1) Q 0 (t+1) y 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 2 0 1 0 1 0 1 1 0 3 0 1 1 1 0 1 1 0 4 1 0 0 0 0 1 0 0 5 1 0 1 1 1 0 1 0 6 1 1 0 1 0 0 1 1 7 1 1 1 1 1 0 0 1 38

Excitation Table: iclicker In excitation table, the inputs of the flip flops are used to produce A. The present state B. The next state 39

Excitation Table =>State Table => State Diagram id Q 1 (t) Q 0 (t) x T 1 (t) T 0 (t) Q 1 (t+1) Q 0 (t+1) y 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 2 0 1 0 1 0 1 1 0 3 0 1 1 1 0 1 1 0 4 1 0 0 0 0 1 0 0 5 1 0 1 1 1 0 1 0 6 1 1 0 1 0 0 1 1 7 1 1 1 1 1 0 0 1 State Assignment S0 00 S1 01 S2 10 S3 11 PS\Input X=0 X=1 S0 S1 S2 S3 40

Excitation Table =>State Table => State Diagram id Q 1 (t) Q 0 (t) x T 1 (t) T 0 (t) Q 1 (t+1) Q 0 (t+1) y 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 2 0 1 0 1 0 1 1 0 3 0 1 1 1 0 1 1 0 4 1 0 0 0 0 1 0 0 5 1 0 1 1 1 0 1 0 6 1 1 0 1 0 0 1 1 7 1 1 1 1 1 0 0 1 State Assignment S0 00 S1 01 S2 10 S3 11 PS\Input X=0 X=1 S0 S0,0 S2,0 S1 S3,0 S3,0 S2 S2,0 S1,0 S3 S1,1 S0,1 S0 S1 S3 S2 41

Excitation Table =>State Table => State Diagram id Q 1 (t) Q 0 (t) x T 1 (t) T 0 (t) Q 1 (t+1) Q 0 (t+1) y 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 2 0 1 0 1 0 1 1 0 3 0 1 1 1 0 1 1 0 4 1 0 0 0 0 1 0 0 5 1 0 1 1 1 0 1 0 6 1 1 0 1 0 0 1 1 7 1 1 1 1 1 0 0 1 PS\Input X=0 X=1 S0 S0,0 S2,0 S1 S3,0 S3,0 S2 S2,0 S1,0 S3 S1,1 S0,1 0/0 1/1 S0 S1 S3 1/0 State Assignment S0 00 S1 01 S2 10 S3 11 1/0 S2 0/0 0/1 0, 1/0 42

Netlist! State Table! State Diagram! Input Output Relation PS\Input X=0 X=1 S0 S0,0 S2,0 S1 S3,0 S3,0 S2 S2,0 S1,0 S3 S1,0 S0,1 Example: Output sequence 0/0 1/1 S0 S1 S3 1/0 1/0 S2 0/1 0, 1/0 0/0 Time 0 1 2 3 4 5 Input 0 1 1 0 1 - State S0 Output 43

Netlist! State Table! State Diagram! Input Output Relation PS\Input X=0 X=1 S0 S0,0 S2,0 S1 S3,0 S3,0 S2 S2,0 S1,0 S3 S1,0 S0,1 Example: Output sequence 0/0 1/1 S0 S1 S3 1/0 1/0 S2 0/1 0, 1/0 0/0 Time 0 1 2 3 4 5 Input 0 1 1 0 1 - State S0 S0 S2 S1 S3 S0 Output 0 0 0 0 1 0 44

Implementation State Diagram => State Table => Logic Diagram Canonical Form: Mealy and Moore Machines Excitation Table Truth Table of the F-F Inputs Boolean algebra, K-maps for combinational logic Examples Timing 45

Canonical Form: Mealy and Moore Machines x(t) Combinational Logic y(t) CLK x(t) C2 y(t) x(t) C1 CLK C1 CLK C2 y(t) 46

Canonical Form: Mealy and Moore Machines Mealy Machine: y i (t) = f i (X(t), S(t)) Moore Machine: y i (t) = f i (S(t)) s i (t+1) = g i (X(t), S(t)) x(t) C1 C2 y(t) x(t) C1 C2 y(t) CLK Mealy Machine S(t) CLK Moore Machine S(t) 47