1 Modeling of Finite State Machines Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

FSM and Efficient Synthesizable FSM Design using Verilog
Finite State Machines (FSMs)
Combinational Logic.
Table 7.1 Verilog Operators.
Hardware Description Language (HDL)
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
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
FSM examples.
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
CS 151 Digital Systems Design Lecture 25 State Reduction and Assignment.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Digital System Design by Verilog University of Maryland ENEE408C.
Embedded Systems Hardware:
Asynchronous FSMs and Verilog. PLD registered output.
Give qualifications of instructors: DAP
Spring 2002EECS150 - Lec15-seq2 Page 1 EECS150 - Digital Design Lecture 15 - Sequential Circuits II (Finite State Machines revisited) March 14, 2002 John.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
Embedded Systems Hardware: Storage Elements; Finite State Machines; Sequential Logic.
ELEN 468 Advanced Logic Design
VII - Finite State Machines © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Finite State Machines Sequential circuits  primitive sequential elements.
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.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 8, 2007.
Sequential Logic in Verilog
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Finite State Machines. Binary encoded state machines –The number of flip-flops is the smallest number m such that 2 m  n, where n is the number of states.
Registers CPE 49 RMUTI KOTAT.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
Register Transfer Level & Design with ASM
Workshop Topics - Outline
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
DLD Lecture 26 Finite State Machine Design Procedure.
Finite State Machine (FSM) Nattha Jindapetch December 2008.
VHDL Discussion Finite State Machines
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
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
Computing Machinery Chapter 4: Finite State Machines.
03/31/031 ECE 551: Digital System Design & Synthesis Lecture Set 8 8.1: Miscellaneous Synthesis (In separate file) 8.2: Sequential Synthesis.
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 9: State Machines & Reset Behavior Spring.
Govt. Engineering College- Gandhinagar. It is all about……  STATE MACHINE.
1 Modeling Synchronous Logic Circuits Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
Pusat Pengajian Kejuruteraan Mikroelektronik EMT 351/4 DIGITAL IC DESIGN Verilog Behavioural Modeling (Part 4) Week #
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.
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure 8.1. The general form of a sequential circuit.
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Supplement on Verilog Sequential circuit examples: FSM
FIGURE 5.1 Block diagram of sequential circuit
HDL Compiler Unsupport (Do NOT use in your verilog code)
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Presentation transcript:

1 Modeling of Finite State Machines Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur

Modeling of Finite State Machines Debdeep Mukhopadhyay IIT Kharagpur

Definition 5 Tuple: (Q,Σ,δ,q 0,F) Q: Finite set of states Σ: Finite set of alphabets δ: Transition function –Qχ Σ  Q q 0 is the start state F is a set of accept states. They are also called final states.

Some Examples 1 What does this FSM do? It accepts the empty string or any string that ends with 0 These set of strings which takes the FSM to its accepting states are often called language of the automaton

Another Example Accepts strings that starts and ends with the same bits

A more complicated example FSM accepts if the running sum of the input strings is a multiple of 3. RESET symbol resets the running sum to 0. q0q0 2 2, 2 q1q1 q2q2 0, 1 1, 0 0 1

Designing FSMs Its an art. Pretend to be an FSM and imagine the strings are coming one by one. Remember that there are finite states. So, you cannot store the entire string, but only crucial information. Also, you do not know when the string ends, so you should always be ready with an answer.

Example Design a FSM which accepts 0,1 strings which has an odd number of 1’s. You require to remember whether there are odd 1’s so far or even 1’s so far even odd

Example Design a FSM that accepts strings that contain 001 as substrings. There are 4 possibilities –No string –seen a 0 –seen a 00 –seen a 001

Answer Note that their may be cases where design of FSMS are not possible. Like design an FSM for strings which has the same number of 0’s and 1’s q q0q q 00 q 001

How to model such FSMs? Simple Model of FSM Next state logic (combinational) Current State Register (sequential) Output logic (combinational) Clock Outputs Inputs

Mealy Machine/Moore Machine Next state logic (combinational) Current State Register (sequential) Output logic (combinational) Clock Mealy Outputs Inputs Next state logic (combinational) Current State Register (sequential) Output logic (combinational) Clock Moore Outputs Inputs Asynchronous Reset

Modeling FSMs using Verilog

Issues State Encoding –sequential –gray –Johnson –one-hot

Encoding Formats NoSequentialGrayJohnsonOne-hot

Comments on the coding styles Binary: Good for arithmetic operations. But may have more transitions, leading to more power consumptions. Also prone to error during the state transitions. Gray: Good as they reduce the transitions, and hence consume less dynamic power. Also, can be handy in detecting state transition errors.

Coding Styles Johnson: Also there is one bit change, and can be useful in detecting errors during transitions. More bits are required, increases linearly with the number of states. There are unused states, so we require either explicit asynchronous reset or recovery from illegal states (even more hardware!) One-hot: yet another low power coding style, requires more no of bits. Useful for describing bus protocols.

Good and Bad FSM FSM State Diagram read write delay read write delay FSM_BAD FSM_GOOD Reset SlowROM

Bad Verilog Clock) begin parameter ST_Read=0,ST_Write=1,ST_Delay=3; integer state; case(state) ST_Read: begin Read=1; Write=0; State=ST_Write; end

Bad Verilog ST_Write: begin Read=0; Write=1; if(SlowRam) State=ST_Delay; else State=ST_Read; end

Bad Verilog ST_Delay: begin Read=0; Write=0; State=ST_Read; end endcase end

Why Bad? No reset. There are unused states in the FSM. Read and Write output assignments also infer an extra flip-flop. No default, latch is inferred. There is feedback logic.

Good verilog Clock) begin if(Reset) CurrentState=ST_Read; else CurrentState=NextState; end

Good verilog or SlowRAM) begin case(CurrentState) ST_Read: begin Read=1; Write=0; NextState=ST_Write; end

Good Verilog ST_Write: begin Read=0; Write=1; if(SlowRAM) NextState=ST_Delay; else NextState=ST_Read; end

Good Verilog ST_Delay: begin Read=0; Write=0; NextState=ST_Read; end default: begin Read=0; Write=0; NextState=ST_Read; end endcase end

One Bad and four good FSMs ST0 ST3 ST1 ST2 Reset Y=1 Y=2 Y=3 Y=4 Control

Bad Verilog Clock or posedge Reset) begin if(Reset) begin Y=1; STATE=ST0; end

Bad verilog else case(STATE) ST0: begin Y=1; STATE=ST1; end ST1: begin Y=2; if(Control) STATE=ST2; else STATE=ST3; ST2: begin Y=3; STATE=ST3; end ST3: begin Y=4; STATE=ST0; end endcase end Output Y is assigned under synchronous always block so extra three latches inferred.

Good FSMs Separate CS, NS and OL Combined CS and NS. Separate OL Combined NS and OL. Separate CS

Next State (NS) or currentstate) begin NextState=ST0; case(currentstate) ST0: begin NextState=ST1; end ST1: begin … … ST3: NextState=ST0; endcase end

Current State (CS) Clk or posedge reset) begin if(Reset) currentstate=ST0; else currentstate=Nextstate; end

Output Logic (OL) begin case(Currentstate) ST0: Y=1; ST1: Y=2; ST2: Y=3; ST3: Y=4; end

CS+NS Clock or posedge reset) begin if(Reset) State=ST0; else case(STATE) ST0: State=ST1; ST1: if(Control) … ST2: … ST3: STATE=ST0; endcase end default not required as it is in edge triggered always statement

CS+NS begin case(STATE) ST0: Y=1; ST1: Y=2; ST2: Y=3; ST3: Y=4; default: Y=1; endcase end default required as it is in combinational always statement

NS+OL or Currentstate) begin case(Currentstate) ST0: begin Y=1; NextState=ST1; end ST1: … ST2: … ST3: … default: … endcase end

NS+OL clock or posedge reset) begin if(reset) Currentstate=ST0; else Currentstate=NextState; end