1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.

Slides:



Advertisements
Similar presentations
ENGIN112 L23: Finite State Machine Design Procedure October 27, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 23 Finite State Machine.
Advertisements

COMP541 State Machines – II: Verilog Descriptions
Finite State Machines (FSMs)
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.
Circuits require memory to store intermediate data
Sequential Circuit Analysis & Design Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals Dr. Aiman H. El-Maleh.
Sequential Circuit Design
ECE 331 – Digital System Design
1 CS 140 Lecture 9 Sequential Networks Professor CK Cheng CSE Dept. UC San Diego.
ECE C03 Lecture 101 Lecture 10 Finite State Machine Design Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Give qualifications of instructors: DAP
1 COMP541 State Machines Montek Singh Feb 6, 2007.
Sequential Circuit Design
Overview Sequential Circuit Design Specification Formulation
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 8, 2007.
9/15/09 - L22 Sequential Circuit Design Copyright Joanne DeGroat, ECE, OSU1 Sequential Circuit Design Creating a sequential circuit to address a.
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
Lecture 8: Sequential Networks and Finite State Machines CSE 140: Components and Design Techniques for Digital Systems Fall 2014 CK Cheng Dept. of Computer.
Digital Computer Design Fundamental
Chapter 5 - Part Sequential Circuit Design Design Procedure  Specification  Formulation - Obtain a state diagram or state table  State Assignment.
1 COMP541 State Machines Montek Singh Feb 8, 2012.
EE434 ASIC & Digital Systems
Lecture 5 Key Locker using FPGA 2007/10/05 Prof. C.M. Kyung.
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Lecture 18 More Moore/Mealy machines.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 5 – Sequential Circuits Part 2 – Sequential.
Introduction to Sequential Logic Design Finite State-Machine Design.
CPEN Digital System Design Chapter 5 - Sequential Circuits Sequential Circuit Design C. Gerousis © Logic and Computer Design Fundamentals, 4 rd Ed.,
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 5 – Sequential Circuits Logic and Computer.
1 CSE370, Lecture 19 Lecture 19 u Logistics n Lab 8 this week to be done in pairs íFind a partner before your lab period íOtherwise you will have to wait.
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
Introduction to State Machine
Review of Digital Logic Design Concepts OR: What I Need to Know from Digital Logic Design (EEL3705)
Lecture 9: Sequential Networks: Implementation CSE 140: Components and Design Techniques for Digital Systems Fall 2014 CK Cheng Dept. of Computer Science.
Lecture 6 Coffee Vending Machine using FPGA
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.
Registers; State Machines Analysis Section 7-1 Section 5-4.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 11, 2010.
Digital System Design using VHDL

1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Sequential Circuit Design Section State Machines Design Procedure 1.Specification- obtain (produce) problem description 2.Formulation - Obtain.
State Diagrams Tuesday, 12 September State diagram Graphical representation of a state table. –Provides the same information as a state table. –A.
Sequential Networks and Finite State Machines
4.
Lecture 4. Sequential Logic #2
Sequential Circuit Design
COMP541 Sequential Logic – 2: Finite State Machines
Sequential Networks and Finite State Machines
Buttons and Debouncing Finite State Machine
KU College of Engineering Elec 204: Digital Systems Design
COMP541 State Machines Montek Singh Feb 4, 2010.
KU College of Engineering Elec 204: Digital Systems Design
Introduction to Sequential Circuits
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Lecture 20 Logistics Last lecture Today HW6 due Wednesday
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
CSE 140 Lecture 9 Sequential Networks
EGR 2131 Unit 12 Synchronous Sequential Circuits
Lecture 4: Finite State Machines
Presentation transcript:

1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016

Lab 7 Preview Buttons and Debouncing 2

Lab Preview: Buttons and Debouncing  Mechanical switches “bounce” vibrations cause them to go to 1 and 0 a number of times vibrations cause them to go to 1 and 0 a number of times  called “chatter” hundreds of times! hundreds of times!  We want to do 2 things: “Debounce”: Any ideas? “Debounce”: Any ideas? Synchronize with clock Synchronize with clock  i.e., only need to look at it at the next +ve edge of clock  Think about (for Lab): What does it mean to “press the button”? Think carefully!! What does it mean to “press the button”? Think carefully!! What if button is held down for a long time? What if button is held down for a long time? 3

Today’s Topics  State Machines How to design machines that go through a sequence of events How to design machines that go through a sequence of events  “sequential machines” Basically: Close the feedback loop in this picture: Basically: Close the feedback loop in this picture: 4

What is sequential logic?  Anything that is not combinational has a cycle of gates has a cycle of gates output cannot be determined solely by the current inputs output cannot be determined solely by the current inputs i.e., has state i.e., has state  But: Not all sequential circuits are useful e.g., 3-inverter loop e.g., 3-inverter loop  is sequential because of feedback  but not controllable by a clock  Synchronous sequential logic: a useful form follows a specific template follows a specific template 5

Synchronous Sequential Logic  Flip-flops/registers contain the system’s state state changes only at clock edge state changes only at clock edge  so system is synchronized to the clock all flip-flops receive the same clock signal (important!) all flip-flops receive the same clock signal (important!) every cyclic path must contain a flip-flop every cyclic path must contain a flip-flop

Synchronous Sequential Logic  Flip-flops/registers contain the system’s state state changes only at clock edge state changes only at clock edge  so system is synchronized to the clock all flip-flops receive the same clock signal (important!) all flip-flops receive the same clock signal (important!) every cyclic path must contain a flip-flop every cyclic path must contain a flip-flop

Examples  Some of these are synchronous sequential circuits, but some are not! Which ones? 8

Two common types  Two common types of synchronous sequential circuits: Finite State Machines (FSMs) Finite State Machines (FSMs) Pipelines Pipelines 9

Finite State Machine (FSM)  Consists of: State register that State register that  holds the current state  updates it to the “next state” at clock edge Combinational logic (CL) that Combinational logic (CL) that  computes the next state –using current state and inputs  computes the outputs –using current state (and maybe inputs)

More and Mealy FSMs  Two types of finite state machines differ in the output logic: Moore FSM: Moore FSM:  outputs depend only on the current state Mealy FSM: Mealy FSM:  outputs depend on the current state and the inputs can convert from one form to the other can convert from one form to the other  Mealy is more general, more expressive  In Both: Next state is determined by current state and inputs Next state is determined by current state and inputs

Moore and Mealy FSMs 12

FSM Example 1 13

Traffic Light Controller  Traffic light controller Traffic sensors: T A, T B (TRUE when there’s traffic) Traffic sensors: T A, T B (TRUE when there’s traffic) Lights: L A, L B Lights: L A, L B

FSM Black Box  Inputs: CLK, Reset, T A, T B CLK, Reset, T A, T B  Outputs: L A, L B

FSM Specification  When reset, L A is green and L B is red  As long as traffic on Academic (T A high), keep L A green  When T A goes low, sequence to traffic on Bravado  Follow same algorithm for Bravado  Let’s say clock period is 5 sec (time for yellow light) 16

States  What sequence do the traffic lights follow? Reset  State 0, L A is green and L B is red Reset  State 0, L A is green and L B is red Next (on board)? Next (on board)? 17

State Transition Diagram  Moore FSM: outputs labeled in each state outputs labeled in each state states: circles states: circles transitions: arcs transitions: arcs

State Transition Table  state graph encoded into a tabular format

“Encoded” State Transition Table  Symbolic states assigned bit codes codes can be arbitrarily chosen codes can be arbitrarily chosen  some are better than others (  “optimal state coding”)

After Input and Output Encoding  Inputs and outputs assigned bit codes again, codes can be arbitrarily chosen again, codes can be arbitrarily chosen  again, some are better than others

FSM Schematic: State Register

Next State Logic

Output Logic

FSM Timing Diagram: Study carefully!

26 Design Procedure  Step-by-step procedure: given FSM description: codify it into a state diagram or table given FSM description: codify it into a state diagram or table assign codes to the states, inputs and outputs assign codes to the states, inputs and outputs derive Boolean equations and implement derive Boolean equations and implement  Or, write Verilog and compile the compiler follows the above steps the compiler follows the above steps uses algorithms for optimal coding of states/inputs/outputs uses algorithms for optimal coding of states/inputs/outputs uses algorithms for optimal Boolean implementation uses algorithms for optimal Boolean implementation

FSM Example 2 27

28 A Sequence Recognizer  Circuit has input, X, and output, Z  Recognizes sequence 1101 on X Specifically: Specifically:  if X has been 110 and next bit is 1, make Z high

29 How to Design States  States remember past history Clearly must remember we have seen 110 when next 1 comes along Clearly must remember we have seen 110 when next 1 comes along Tell me one necessary state for this example…? Tell me one necessary state for this example…?

30 Beginning State  Start state: let’s call it A if 1 appears on input, move to next state B if 1 appears on input, move to next state B output remains at 0 output remains at 0 Input / Output

31 Second 1  New state, C  To reach C, must have seen 11

32 Next a 0  If 110 has been received, go to D  Next 1 will generate a 1 on output Z

33 What else?  What happens to arrow on right? Must go to some state. Where? Must go to some state. Where?

34 What Sequence?  Here we have to interpret the problem statement  We have just seen 01 Is this beginning of new 1101? Is this beginning of new 1101? Or do we need to start over w/ another 1? Or do we need to start over w/ another 1?  Let us say that it is the beginning of a new run…

35 Cover every possibility  Must cover every possibility out of every state For every state: X = 0 or 1 For every state: X = 0 or 1 You fill in all the cases You fill in all the cases

36 Fill in

37 Full Answer

38 State Minimization  Do we need all those states? Some may be redundant Some may be redundant  How to use as few states as possible?  State minimization is a well-studied problem Is a tough problem (NP-complete) Is a tough problem (NP-complete)  but pretty good algorithms exist  exact and approximate Out of the scope of this course Out of the scope of this course

FSM implementation  Do yourself: State transition table State transition table State encoding State encoding Truth tables Truth tables Boolean equations and gate-level implementation Boolean equations and gate-level implementation 39

40Reading  Read entire 3.3 and 3.4