Finite State Machine Continued

Slides:



Advertisements
Similar presentations
Sequential Logic Design
Advertisements

ENGIN112 L23: Finite State Machine Design Procedure October 27, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 23 Finite State Machine.
Chapter #8: Finite State Machine Design Contemporary Logic Design
Modeling Computation Chapter 13.
Chapter 4 Gates and Circuits.
CS105 Introduction to Computer Concepts GATES and CIRCUITS
Digital Techniques Fall 2007 André Deutz, Leiden University
Chapter 4 Gates and Circuits.
Chapter #8: Finite State Machine Design 8
Lecture 13: Sequential Circuits
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
A. Abhari CPS2131 Sequential Circuits Most digital systems like digital watches, digital phones, digital computers, digital traffic light controllers and.
Sequential Circuits1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
Circuits require memory to store intermediate data
Lecture 22: Sequential Circuits Today’s topic –Clocks and sequential circuits –Finite state machines 1.
FSMs 1 Computer Organization I September 2009 © McQuain, Feng & Ribbens Motivation Combinational logic functions can be represented, and defined,
Our First Real System.
Computer ArchitectureFall 2007 © October 1st, 2007 Majd F. Sakr CS-447– Computer Architecture.
Basic Register Typically, we store multi-bit items
Computer ArchitectureFall 2008 © September 17th, 2008 Majd F. Sakr CS-447– Computer Architecture.
1 Lecture 14: FSM and Basic CPU Design Today’s topics:  Finite state machines  Single-cycle CPU Reminder: midterm on Tue 10/24  will cover Chapters.
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic CMOS logic elements Combinational logic elements and design.
11/10/ :53:59 AMweek12-3.ppt1 Intelligent Traffic Controller We want to use a finite state machine to control the traffic lights at an intersection.
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Introduction to Sequential Logic Design Finite State-Machine Design.
Introduction to State Machine
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Latches & Flip-Flops.
Lecture 5. Sequential Logic 2 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education & Research.
DLD Lecture 26 Finite State Machine Design Procedure.
1 Finite State Machines (FSMs) Now that we understand sequential circuits, we can use them to build: Synchronous (Clocked) Finite State Machines Finite.
Modern VLSI Design 4e: Chapter 5 Copyright  2008 Wayne Wolf Topics n Sequential machine implementation: –clocking. n Sequential machine design.
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Digital System Design using VHDL

1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Finite State Machine. Clock Clock cycle Sequential circuit Digital logic systems can be classified as combinational or sequential. – Combinational circuits.
Mealy and Moore Machines Lecture 8 Overview Moore Machines Mealy Machines Sequential Circuits.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
1 Lecture 13: Sequential Circuits, FSM Today’s topics:  Sequential circuits  Finite state machines  Single-cycle CPU Reminder: midterm on Tue 10/20.
Finite State Machines Mealy machine inputs Outputs next state function
Digital Design - Sequential Logic Design
Lecture 4. Sequential Logic #2
Clocks A clock is a free-running signal with a cycle time.
Motivation Combinational logic functions can be represented, and defined, by truth tables. Sequential logic function cannot, because their behavior depends.
Synchronous Sequential Circuit Design
Sequential Circuits Most digital systems like digital watches, digital phones, digital computers, digital traffic light controllers and so on require.
Assistant Prof. Fareena Saqib Florida Institute of Technology
Lecture 13: Sequential Circuits, FSM
Lecture 13: Sequential Circuits, FSM
Introduction to Sequential Circuits
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Finite State Machines.
ECE 352 Digital System Fundamentals
Counters.
ECE 352 Digital System Fundamentals
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
EGR 2131 Unit 12 Synchronous Sequential Circuits
ECE 352 Digital System Fundamentals
Finite State Machine Continued
Clocks A clock is a free-running signal with a cycle time.
Presentation transcript:

Finite State Machine Continued

In class exercise Design a 2-bit up-down counter with a control signal U. If U=0, count down, else count up.

Combinational and Sequential Circuit Digital logic systems can be classified as combinational or sequential. Combinational circuits can be completely described by the truth table. Sequential systems contain state stored in memory elements internal to the system. Their behavior depends both on the set of inputs supplied and on the contents of the internal memory, or state of the system. Thus, a sequential system cannot be described with a truth table. Instead, a sequential system is described as a finite-state machine (or often just state machine).

Clock cycle

Finite State Machines A finite state machine has a set of states and two functions called the next-state function and the output function The set of states correspond to all the possible combinations of the internal storage If there are n bits of storage, there are 2n possible states The next state function is a combinational logic function that given the inputs and the current state, determines the next state of the system 11/10/2007 11:52:10 AM week12-3.ppt

Finite State Machines The output function produces a set of outputs from the current state and the inputs There are two types of finite state machines In a Moore machine, the output only depends on the current state While in a Mealy machine, the output depends both the current state and the current input We are only going to deal with the Moore machine. These two types are equivalent in capabilities 11/10/2007 11:52:34 AM week12-3.ppt

Implementing an FSM Outputs Implement transition functions Inputs 4/10/2017 Outputs Implement transition functions Inputs Current state D Q Next state 11/10/2007 11:55:38 AM week12-3.ppt CDA3100 week12-3.ppt

Intelligent Traffic Controller We want to use a finite state machine to control the traffic lights at an intersection of a north-south route and an east-west route We consider only the green and red lights We want the lights to change no faster than 30 seconds in each direction So we use a 0.033 Hz clock 11/10/2007 11:53:59 AM week12-3.ppt

Intelligent Traffic Controller There are two output signals NSlite: When the signal is asserted, the light on the north-south route is green; otherwise, it should be red EWlite: When the signal is asserted, the light on the east-west route is green; otherwise, it should be red 11/10/2007 11:54:14 AM week12-3.ppt

Intelligent Traffic Controller There are two inputs NScar: Indicates that there is at least one car that is over the detectors placed in the roadbed in the north-south road EWcar: Indicates that there is at least one car that is over the detectors placed in the roadbed in the east-west road 11/10/2007 11:54:22 AM week12-3.ppt

Intelligent Traffic Controller The traffic lights should only change from one direction to the other only if there is a car waiting in the other direction Otherwise, the light should continue to show green in the same direction 11/10/2007 11:54:32 AM week12-3.ppt

Intelligent Traffic Controller Here we need two states NSgreen: The traffic light is green in the north-south direction EWgreen: The traffic light is green in the east-west direction 11/10/2007 11:54:40 AM week12-3.ppt

Graphical Representation EWCar=0, NSCar=0 or 1 NSCar=0, EWCar=0 or 1 NSCar=1, EWCar=0 or 1 NSgreen EWgreen EWCar=1, NSCar=0 or 1 11/10/2007 11:55:01 AM week12-3.ppt

Next State Function and Output Function 11/10/2007 11:54:47 AM week12-3.ppt

State Assignment We need to assign state numbers to the states In this case, we can assign NSgreen to state 0 and EWgreen to state 1 Therefore we only need 1 bit in the state register 11/10/2007 11:55:05 AM week12-3.ppt

Combinational Logic for Next State Function 11/10/2007 11:55:12 AM week12-3.ppt

Implementing Intelligent Traffic Controller 11/15/2007 2:38:31 PM week12-5.ppt

Four Steps to Build a Finite State Machine Step 1 – State diagram and state table There are no set procedures and diagrams. Application dependent Choose a state to be the starting state when power is turned on the first time A state diagram can be represented by a graph or by a table 11/15/2007 2:38:32 PM week12-5.ppt

Four Steps to Build a Finite State Machine Step 2 – State assignment Assign a unique binary number to each state Rewrite the state table using the assigned number for each state Step 3 – Combinational logic for next state function and output function Step 4 - Implementation 11/15/2007 2:38:32 PM week12-5.ppt

FSM The state is updated at the edge of the clock cycle The next state is computed once every clock.

Finite State Machine for a Vending Machine 4/10/2017 Finite State Machine for a Vending Machine Build a custom controller for a vending machine. We could use a general purpose processor, but we might save money with a custom controller. Take coins, give drinks CDA3100 week12-5.ppt

Inputs and Outputs Inputs: coin trigger refund button drink selectors 4/10/2017 Inputs and Outputs Inputs: drink selectors coin trigger refund button Outputs: drink release latches Coin refund latch CDA3100 week12-5.ppt

Specifications Sells only two kinds of drinks, A,B. (For now, assume all drinks are available in the machine.) All drinks are $0.50. Accepts quarters only. If you put in more than $0.50, consider it as $0.50. Will respond to refund button. If pressed, release all quarters. If the current amount of money is less than $0.50 Will not respond to select buttons. If the current amount of money is $0.50 Will respond to select buttons. If SA is pressed, release drink A, if SB is pressed, release drink B. Then, take in all the money.

Controller Outputs Suppose the latch to be used to build the vending machine is controlled by one bit. It will be closed if the control signal is 0. If the control signal is 1 for a duration of one clock cycle, it will open for a period of time sufficient to allow things stored to fall through; after that, if the control signal is 0, it will be closed. If it is 1, it will stay open until the control signal returns to 0. Controller outputs are: L_A, L_B, L_RF, L_TK. These are signals to control the latches. L_A=1, the latch for drink A opens, and drink A will fall out. L_B=1, the latch for drink B opens, and drink B will fall out. L_RF=1, the latch for coin refund opens, and coins will fall out. L_TK = 1, the latch for coin take opens, and coins will fall from the temporarily storing place to the inside of the machine. Based on the specification of the latches, we need to set the control signals to be 1 for one clock.

Inputs Inputs include some buttons: SA, SB, RF. SA = 1 when the user is pressing the select A button, else it is 0 SB = 1 when the user is pressing the select B button, else it is 0 RF = 1 when the user is pressing the refund button, else it is 0 Inputs also include CIS (coin insert). When a coin is falling in, CIS is 1 for one clock cycle (from one falling edge to the next falling edge). It is 0 all other time.

Design How to design this controller, given the specifications and the inputs and the outputs? Is this a stateless controller, or a controller with states?

State To tell if a controller has states or not, the simplest way is to check if the controller’s output is relevant to what happened in the past. If it is relevant, it has state; otherwise it does not. The vending machine controller has state, because the controller’s response to the same input (e.g., SA) is different depending on the number of quarters inserted.

Identifying the States We need at least three states to remember how many quarters we have got. S0: The initial state. Got 0 quarters. S1: Got 1 quarter. S2: Got 2 quarters.

State Diagram S0 S1 CIS = 1 S2

State Diagram When got $0.50, if the user presses select button, should release drink, take money, and go back to state S0. But is this diagram correct? S0 S1 S2 CIS = 1 SA = 1

State Diagram Not complete – we haven’t take action yet. When the SA is pressed, the controller should change some output signal – not shown in the diagram S0 S1 S2 CIS = 1 SA = 1

Change the output The output to be changed, clearly, is the L_A and L_TK. By the specification, we should let them be 1 for one clock cycle. clk SA L_A L_TK

Other options Can we just let the latch be controlled by the SA button, meaning that the latch is open when SA is pressed? If we do this, I will just get free drinks. So the latch has to be determined by the states somehow. Can we just say that the latch is open if in state S2 and when SA is pressed? When in state S2, if SA is pressed, the next state is not S2 – the overlapping time may not be enough because SA can become 1 at arbitrary time.

The Action State For SA To ensure that the control signal stays high for one clock cycle, we need another state. In S3, L_A = 1 L_TK = 1 S0 S1 S3 S2 CIS = 1 SA = 1 automatic

The complete diagram CIS = 1 RF = 1 S0 S1 SA = 1 SB = 1 automatic S3 S3: L_A=1, L_TK=1 S4: L_B=1, L_TK=1 S3 S2 S5: L_RF=1 S4 S5