Lecture 4: Finite State Machines

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

Chapter #8: Finite State Machine Design 8
State-machine structure (Mealy)
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
Give qualifications of instructors: DAP
Lecture 22: Sequential Circuits Today’s topic –Clocks and sequential circuits –Finite state machines 1.
CS 151 Digital Systems Design Lecture 21 Analyzing Sequential Circuits.
1 Lecture 23 More Sequential Circuits Analysis. 2 Analysis of Combinational Vs. Sequential Circuits °Combinational : Boolean Equations Truth Table Output.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
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
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)
ENGIN112 L25: State Reduction and Assignment October 31, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 25 State Reduction and Assignment.
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.
Sequential Logic in Verilog
1 COMP541 State Machines Montek Singh Feb 8, 2012.
EE434 ASIC & Digital Systems
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.
Lecture 9: Sequential Networks: Implementation CSE 140: Components and Design Techniques for Digital Systems Fall 2014 CK Cheng Dept. of Computer Science.
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.
Sequential Circuit: Analysis BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
Analysis and Synthesis of Synchronous Sequential Circuits A “synchronizing” pulse/edge signal (clock) controls the operation of the memory portion of the.
Registers; State Machines Analysis Section 7-1 Section 5-4.
Digital System Design using VHDL

Chapter 3 Computer System Architectures Based on
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.
Introduction to Sequential Logic Design Finite State-Machine Analysis.
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.
Interrupt, again! Lin Zhong ELEC424, Fall 2010.
Logic Design (CE1111 ) Lecture 6 (Chapter 6) Registers &Counters Prepared by Dr. Lamiaa Elshenawy 1.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Chapter 3 Digital Design and Computer Architecture, 2nd Edition
Chapter 3 Digital Design and Computer Architecture: ARM® Edition
Sequential Networks and Finite State Machines
Lecture 4. Sequential Logic #2
© Copyright 2004, Gaetano Borriello and Randy H. Katz
COMP541 Sequential Logic – 2: Finite State Machines
Digital Design Lecture 9
Assistant Prof. Fareena Saqib Florida Institute of Technology
FINITE STATE MACHINES (FSMs)
Sequential Networks and Finite State Machines
Hakim Weatherspoon CS 3410 Computer Science Cornell University
COMP541 State Machines Montek Singh Feb 4, 2010.
CSE 370 – Winter Sequential Logic-2 - 1
Introduction to Sequential Circuits
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
3. Sequential Logic Design
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
CSE 140 Lecture 9 Sequential Networks
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Finite State Machine Continued
CSE 370 – Winter Sequential Logic-2 - 1
Design of Digital Circuits Lecture 7: Sequential Logic Design
Lecture 3: Timing & Sequential Circuits
Presentation transcript:

Lecture 4: Finite State Machines E85 Digital Design & Computer Engineering Lecture 4: Finite State Machines

Lecture 4 Finite State Machines

Synchronous Sequential Logic Design Breaks cyclic paths by inserting registers Registers contain state of the system State changes at clock edge: system synchronized to the clock Rules of synchronous sequential circuit composition: Every circuit element is either a register or a combinational circuit At least one circuit element is a register All registers receive the same clock signal Every cyclic path contains at least one register Two common synchronous sequential circuits Finite State Machines (FSMs) Pipelines

Finite State Machine (FSM) Consists of: State register Stores current state Loads next state at clock edge Combinational logic Computes the next state Computes the outputs

Finite State Machines (FSMs) Next state determined by current state and inputs Two types of finite state machines differ in output logic: Moore FSM: outputs depend only on current state Mealy FSM: outputs depend on current state and inputs

FSM Example Traffic light controller Traffic sensors: TA, TB (TRUE when there’s traffic) Lights: LA, LB

FSM Black Box Inputs: CLK, Reset, TA, TB Outputs: LA, LB

FSM State Transition Diagram Moore FSM: outputs labeled in each state States: Circles Transitions: Arcs

FSM State Transition Diagram Moore FSM: outputs labeled in each state States: Circles Transitions: Arcs

FSM State Transition Table Current State Inputs Next State S TA TB S' S0 X S1 1 S2 S3

FSM Encoded State Transition Table Current State Inputs Next State S1 S0 TA TB S'1 S'0 X 1 State Encoding S0 00 S1 01 S2 10 S3 11 S'1 = S1 xor S0 S'0 = S1S0TA + S1S0TB

FSM Output Table Current State Outputs S1 S0 LA1 LA0 LB1 LB0 1 Output 1 Output Encoding green 00 yellow 01 red 10 LA1 = S1 LA0 = S1S0 LB1 = S1 LB0 = S1S0

FSM Schematic: State Register

FSM Schematic: Next State Logic

FSM Schematic: Output Logic

SystemVerilog Description module trafficFSM(input logic clk, reset, input logic ta, tb, output logic [1:0] la, lb); logic [1:0] state, nextstate, sb; logic tab, tbb, p1, p2; // state register flopr #(2) statereg(clk, reset, nextstate, state); // next state logic not n0(sb[0], s[0]); not n1(sb[1], s[1]); not n2(tab, ta); not n3(tbb, tb); xor x1(nextstate[1], state[0], state[1]); and a1(p1, sb[0], sb[1], tab); and a2(p2, sb[0], s[1], tbb); or o1(nextstate[0], p1, p2); // output logic buf b1(la[1], s[1]); and a3(la[0], s[0], sb[1]); inv n4(lb[1], s[1]); and a4(lb[0], s[0], s[1]); endmodule Multi-input XOR: Odd parity

FSM Timing Diagram

FSM State Encoding Binary encoding: One-hot encoding i.e., for four states, 00, 01, 10, 11 One-hot encoding One state bit per state Only one state bit HIGH at once i.e., for 4 states, 0001, 0010, 0100, 1000 Requires more flip-flops Often next state and output logic is simpler

Moore vs. Mealy FSM Alyssa P. Hacker has a snail that crawls down a paper tape with 1’s and 0’s on it. The snail smiles whenever the last two digits it has crawled over are 01. Design Moore and Mealy FSMs of the snail’s brain.

State Transition Diagrams Mealy FSM: arcs indicate input/output

Moore FSM State Transition Table Encoding S0 00 S1 01 S2 10 Current State Inputs Next State S1 S0 A S'1 S'0 1 S1’ = S0A S0’ = A

Moore FSM Output Table Current State Output S1 S0 Y 1 Y = S1

Mealy FSM State Transition & Output Table Current State Input Next State Output S0 A S'0 Y 1 State Encoding S0 S1 1 S0’ = A Y = S0 A

Moore Mealy

Moore & Mealy Timing Diagram

Factoring State Machines Break complex FSMs into smaller interacting FSMs Example: Modify traffic light controller to have Parade Mode. Two more inputs: P, R When P = 1, enter Parade Mode & Bravado Blvd light stays green When R = 1, leave Parade Mode

Parade FSM Unfactored FSM Factored FSM

Unfactored FSM

Factored FSM

FSM Design Procedure Identify inputs and outputs Sketch state transition diagram Write state transition table Select state encodings For Moore machine: Rewrite state transition table with state encodings Write output table 5. For a Mealy machine: Rewrite combined state transition and output table with state encodings 6. Write Boolean equations for next state and output logic 7. Sketch the circuit schematic