FSM Design and Optimisation.ppt

download FSM Design and Optimisation.ppt

of 45

Transcript of FSM Design and Optimisation.ppt

  • 8/10/2019 FSM Design and Optimisation.ppt

    1/45

    NDG on FSM FPGA Based System Design 1

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    Finite State Machine (FSM) A Digital Circuit, in general, can be subdivided into two

    parts:Combinational part A circuit whose output is a function of its

    current inputs onlySequential part A circuit whose output is a function of its current

    inputs plus the past inputs [requires memory elements such as latchesor flip-flops]

    FSM is a mathematical abstraction of a Sequential CircuitA System - comprising of inputs, outputs, and states while modeling

    time as discrete instants at which inputs or outputs can changeSynchronous FSM when states and output transitions are

    synchronized with a clock (positive or negative edge)Asynchronous FSM - when states and output transitions can occur

    at any time in response to input changes

  • 8/10/2019 FSM Design and Optimisation.ppt

    2/45

    NDG on FSM FPGA Based System Design 2

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM ModelsMealy Model Contains three components:

    State Memory to store the current state S(t) State Transition Function to determine the next state

    S(t+1) depending upon the current state S(t) and the input X(t) Output Function which generates the output Y(t) as

    function of the current state S(t) and the input X(t)

    Fig-01: Mealy Model of FSM

  • 8/10/2019 FSM Design and Optimisation.ppt

    3/45

    NDG on FSM FPGA Based System Design 3

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Models Contd Moore Model Similar to Mealy Model except that Output

    Function which generates the output Y(t) as function of thecurrent state S(t) only.

    Both Mealy and Moore Models can be mapped into each otherMealy Machines usually have fewer state variables (memory

    elements)- Widely used in Engineering Applications Moore Machines are simpler to analyze mathematically

    Fig-02: Moore Model of FSM

  • 8/10/2019 FSM Design and Optimisation.ppt

    4/45

    NDG on FSM FPGA Based System Design 4

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Models Contd A Problem with Mealy Machine (as shown in Fig-01)

    Output may have glitches. So, a slightly modified version ofMealy Machine is more commonly used .

    Fig-03: Mealy FSM with Registered Output

    All Digital Systems can be viewed as networks ofFSMs ?

  • 8/10/2019 FSM Design and Optimisation.ppt

    5/45

    NDG on FSM FPGA Based System Design 5

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Models Contd Autonomous FSM Special FSM having no inputs, e.g. LFSRCommunicating FSMs Two or more FSMs interacting with

    each other

    Fig-04: Communicating FSMs

  • 8/10/2019 FSM Design and Optimisation.ppt

    6/45

    NDG on FSM FPGA Based System Design 6

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps1. Understand the Specifications2. Problem Definition Using State Diagram and/or State Table3. State Minimization Removal of redundant internal states

    4. State Assignment Assigning binary codes to the states5. Determination of State Transition Function and OutputFunction Equations6. Logic Equation Minimization7. Design Mapping to a given Technology or Device

    Steps 3, 4 and 6 are Optimization Problems valuablebut not necessary steps

  • 8/10/2019 FSM Design and Optimisation.ppt

    7/45

    NDG on FSM FPGA Based System Design 7

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd Step-1: Understanding the Specifications

    A Simple Vending Machine Design Example: [a] Accepts 1 or 2Rupees Coins [b] Delivers a Pak-Cola bottle of drink costing

    Rupees 3 [c] Provides change where applicable

    CLOCK

    COINSRs. 1 Coin

    Rs. 2 Coin

    Input Conditioning FSMOutputDrivers

    Vend

    Change

    Drink / Change

    Fig-05: A Vending Machine Model

  • 8/10/2019 FSM Design and Optimisation.ppt

    8/45

    NDG on FSM FPGA Based System Design 8

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd

    Step-2: State DiagramRepresentation

    Each State is represented as a circlewith output arrows

    Next to the arrow, input and outputsare given

    For Vending Machine, FSM remains instate S0 until there is some coin, eitherof Rs. 1 or Rs. 2 inserted.

    Upon such an event, depending uponthe coin type, it switches to another state

    FSM should not activate the Vend /Change driver unless the credit equals orexceed the Rs. 3

    A state transition diagram can bedrawn as shown in Fig-07(Next Slide) Fig-06: Notation used in State Diagram Representation

    State Name

    Description

    00/00Inputs: Rs. 1: Rs. 2 Outputs: Vend: Change

    S0Idle

    01/00 10/00

  • 8/10/2019 FSM Design and Optimisation.ppt

    9/45

    NDG on FSM FPGA Based System Design 9

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    Fig-07: State Diagram Representation of Vending Machine

    FSM Design Steps Contd Step-2: State Diagram Representation Let us Complete it

    S0

    S1 S2

    S3 S4 S5 S6

    S7 S8

    Inputs/Outputs = Rs.2:Rs.1/Vend:Change

  • 8/10/2019 FSM Design and Optimisation.ppt

    10/45

    NDG on FSM FPGA Based System Design 10

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd Step-3: State Minimization

    Equivalent States: Two states are said to be equivalent if theyhave identical next states and outputs.

    Fig-08: State Minimization Step-03 [a] Cyclic State Diagram of VM [b] Reduced FSM for VM

    S0

    S1

    S3

    S2

    00/00

    00/00

    00/00

    00/00

    Reset

    [a]

    S0

    S1

    S2

    00/00

    00/0000/00

    Reset

    01/00

    10/10

    01/00

    10/00

    10/11

    01/10

    Inputs/Outputs=Rs.2:Rs.1/Vend:Change

    [b]

  • 8/10/2019 FSM Design and Optimisation.ppt

    11/45

    NDG on FSM FPGA Based System Design 11

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd Step-3: State Minimization Contd Addition of Invalid State(s) due to State Assignment (Binary Codes)

    Fig-09: Final Reduced FSM for VM

    S0

    S1

    S2

    00/00

    00/0000/00

    01/0010/10

    01/00

    10/00

    10/11

    01/10

    Inputs/Outputs=Rs.2:Rs.1/Vend:Change

    S3

    xx/00

  • 8/10/2019 FSM Design and Optimisation.ppt

    12/45

    NDG on FSM FPGA Based System Design 12

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd Step-4: State Assignment and State Transition TableTable-01: State Transition Table for Vending Machine

    Current State Inputs = Rs.2:Rs.1 Next State Outputs= Vend:Change

    S0 00 S0 00S0 01 S1 00S0 10 S2 00S1 00 S1 00S1 01 S2 00S1 10 S0 10S2 00 S2 00S2 01 S0 10S2 10 S0 11S3 XX S0 00

    Table-02: Compact State Transition Table for VM

    00 01 11 10 S0 S0, 00 S1, 00 S0, 00 S2, 00

    S1 S1, 00 S2, 00 S0, 00 S0, 10S2 S2, 00 S0, 10 S0, 00 S0, 11S3 S0, 00 S0, 00 S0, 00 S0, 00

    Input s = Rs. 2: Rs. 1

    C u r r e n

    t S t a t e

  • 8/10/2019 FSM Design and Optimisation.ppt

    13/45

    NDG on FSM FPGA Based System Design 13

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd Step-4: State Assignment and State Transition Table

    Step-5: Determination of Logical Equations

    Table-02: Compact State Transition Table for VM

    00 01 11 10S0 S0, 00 S1, 00 S0, 00 S2, 00S1 S1, 00 S2, 00 S0, 00 S0, 10S2 S2, 00 S0, 10 S0, 00 S0, 11S3 S0, 00 S0, 00 S0, 00 S0, 00

    Input s = Rs. 2: Rs. 1

    C u r r e n

    t S t a t e

    00 01 11 1000 00, 00 01, 00 00, 00 10, 0001 01, 00 10, 00 00, 00 00, 1010 10, 00 00, 10 00, 00 00, 1111 00, 00 00, 00 00, 00 00, 00

    Inpu ts = Rs. 2: Rs. 1

    Table-03: Compact State Transition Table for

    s1(next) = /s1*/s0*Rs.2*/Rs.1 + /s1*s0*/Rs.2*Rs.1 + s1*/s0*/Rs.2*/Rs.1

    s0(next) = /s1*/s0*/Rs.2*Rs.1 + /s1*s0*/Rs.2*/Rs.1

    Vend = s1*/s0*Rs.2 + s1*/s0*Rs.1 + /s1*s0*Rs.2*/Rs.1

    Change = s1*/s0*Rs.2*/Rs.1

    ?

  • 8/10/2019 FSM Design and Optimisation.ppt

    14/45

    NDG on FSM FPGA Based System Design 14

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Steps Contd Step-6-7: Simplification of Logic Equations and

    Hardware ImplementationUse of K Maps or Other Methods

    Implementation is Technology Dependent

    Combinational LogicGates

    Rs. 2

    Rs. 1

    Clock

    Vend

    Change

    Fig-10: Implementation of VM FSM

  • 8/10/2019 FSM Design and Optimisation.ppt

    15/45

    NDG on FSM FPGA Based System Design 15

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Example Huffman CodecUsed for JPEG/MPEG CompressionRelies on known probability of a set of fixed symbols

    Fig-11: Huffman Tree Developed based on Symbol Frequency

    Table-04: Symbols with TheirBinary Code and Frequency

  • 8/10/2019 FSM Design and Optimisation.ppt

    16/45

    NDG on FSM FPGA Based System Design 16

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Design Example Huffman Codec Contd Huffman Decoder Circuit Implementation as FSM

    Fig-11: Huffman Decoder FSM State Diagram and FSM Implementation

  • 8/10/2019 FSM Design and Optimisation.ppt

    17/45

    NDG on FSM FPGA Based System Design 17

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM OptimizationThree Ways to Optimize the HW Complexity of FSM

    State Minimization State Assignment

    Logic Equation MinimizationState Minimization Methods

    State Merging by Observation State Partitioning Application of Implication Tables

    State Merging by Observation Vending Machine Example Bit Sequence Detector

  • 8/10/2019 FSM Design and Optimisation.ppt

    18/45

    NDG on FSM FPGA Based System Design 18

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o t e s -

    D S D - 0

    6

    FSM Optimization Contd State Merging by Observation

    Bit Sequence Detector A Circuit that generates an outputZ = 1 when it detects a bit sequence from a serial data input D

    as 001, 010, 100, or 111.

    S3 and S6 ar e Equivalent , and so are S4 and S5.Eliminate S5 and S6

    Fig-12: Bit Sequence Detector [a] State Diagram [b] State Table

  • 8/10/2019 FSM Design and Optimisation.ppt

    19/45

    NDG on FSM FPGA Based System Design 19

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Merging by Observation Contd

    Bit Sequence Detector after State Minimization

    Fig-13: Minimal State Bit Sequence Detector [a] Stat Table [b] State Diagram

  • 8/10/2019 FSM Design and Optimisation.ppt

    20/45

    NDG on FSM FPGA Based System Design 20

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Partitioning

    An FSM Example

    Best Solution for this FSM takes only 5 States ?

    Fig- 14: State Table for FSM of StatePartitioning Example

  • 8/10/2019 FSM Design and Optimisation.ppt

    21/45

    NDG on FSM FPGA Based System Design 21

    B set is unacceptable as itsNext State sets, for both input0 and 1, do not belong to anyother single set of states

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Partitioning Contd

    An FSM ExampleStep-1: State Partitioning by Outputs Divide the states into

    sets with identical outputs

    Step-2: State Partitioning with Next States For states ineach set, find their next states separately

  • 8/10/2019 FSM Design and Optimisation.ppt

    22/45

    NDG on FSM FPGA Based System Design 22

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Partitioning Contd

    An FSM ExampleStep-3: Repartitioning based on Next States After Step-2, two

    things have happened: next state group for C (input = 0) now belongs toB2, however, next state group for A (input = 1) now belongs to no singlestate group, so, A partition has become invalid

    NOW all the next state groupings belongto some single state partition/group.

    WHAT is Final Partitioning ?

  • 8/10/2019 FSM Design and Optimisation.ppt

    23/45

    NDG on FSM FPGA Based System Design 23

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Partitioning Contd

    An FSM ExampleFinally We got a State Partitioning Where

    Next outputs are the same for each state in the same statepartition/groupAND

    Next states are the same for each state in the sameset/group

    Final Optimized FSM has got onlyFive States.!

  • 8/10/2019 FSM Design and Optimisation.ppt

    24/45

    NDG on FSM FPGA Based System Design 24

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    Self-study Exercise: Application ofImplication Table: Easy to Computerizeand Suitable for Larger FSMOptimization

    FSM Optimization Contd

  • 8/10/2019 FSM Design and Optimisation.ppt

    25/45

    NDG on FSM FPGA Based System Design 25

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Assignment

    Assigning Unique Binary Codes to the States of a MinimizedFSM

    State Minimization has a Unique Technology-IndependentSolution, however, State Assignment Depends on Technology such as PLA, ROM, PAL, logic gates Type of storage circuit, D-latches or FF

    For a FSM of r Rows (States), with n-bit State Variables, AllPossible Permutations are

    N = 2n

    ! / (2n

    -r)! Many, among above Assignments, are just Rearrangements,according to McCluskey, Number of Distinct Assignments isReduced to

    ND = (2 n -1)! / (2 n-r)!* n!

  • 8/10/2019 FSM Design and Optimisation.ppt

    26/45

    NDG on FSM FPGA Based System Design 26

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Assignment Contd

    Even the number given by McCluskey is still very large

    Very Complex Problem, called Intractable or np-Complete .Such a problem usually have no optimal solution but somesolution based on heuristics (thumb rules or simple rules)

    Aim here would be to have Rules that provide maximumnumber of 1s in adjacent cells of next -state truth table forbetter k-map reduction

  • 8/10/2019 FSM Design and Optimisation.ppt

    27/45

    NDG on FSM FPGA Based System Design 27

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Assignment Contd

    Rule-1: States with the same next state for a given inputcondition should be assigned codes differing in one (binary) bitposition only. For Example,

    Rule-2: Next States of a single state should be given logicallyadjacent state assignments. For Example,

  • 8/10/2019 FSM Design and Optimisation.ppt

    28/45

    NDG on FSM FPGA Based System Design 28

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Assignment Contd

    Example-01: Consider the Bit Sequence Detector FSM

    Applying Rule 2, S1 and S2 should be assigned logicallyadjacent codes, so, let S1 = 100 and S2 = 101

    Applying Rule 1, S3 and S4 both have the same next state withgiven input condition, so, S3 and S4 are assigned logicallyadjacent codes. S3 = 110 and S4 = 111

    S0 can be assigned 000 (arbitrary), and unassigned states wouldbe 010, 011, and 001

    Fig-15: Bit Sequence Detector FSM

  • 8/10/2019 FSM Design and Optimisation.ppt

    29/45

    NDG on FSM FPGA Based System Design 29

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Optimization Contd State Ass ignment Contd

    One-Hot State Assignment Sometimes, instead of log 2 r bi-stable latches, it is more

    efficient (and convenient as well ) to have r latches/flip-flops,i.e. one for each state. It is called One-Hot State Assignment.

    At any time, only one FF will be set (FF corresponding tothe state where FSM lies at that instant)

    No State Assignment is required One-hot state assignment is particularly suitable for FPGA

    (LUT and MUX based Architecture) implementation of FSM

    Number of FF required is much higher than Min. LengthState Encoding

    Slower in Operation as compared to other option.

  • 8/10/2019 FSM Design and Optimisation.ppt

    30/45

    NDG on FSM FPGA Based System Design 30

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Implementation- HW Considerations

    Implementation Alternatives Standard ICs Suitable for Simple Designs PROM Suitable for many Outputs/States, No Logic Minimization needed,

    Exhaustive Implementation for all Possible Input Combinations, Size growsExponentially

    CPLDs/FPGAs More Suitable for most of FSM Implementations

    Fig-16:Generic BlockDiagram ofFSM

    Fig-17:Implementation ofFSM with PROM

  • 8/10/2019 FSM Design and Optimisation.ppt

    31/45

    NDG on FSM FPGA Based System Design 31

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Implementation- HW Considerations Contd

    Asynchronous Inputs A Possible Source of Race Condition Asynchronous input A to FSM, while making transition from 0 to

    1 , as shown above may give rise to a wrong state transition SOLUTION: Synchronize all the Asynchronous Inputs to FSM using a

    Latch clocked by the FSM clock

    Fig-18:AsynchronousInputs to FSM

    Fig-19:SynchronizingAsynchronousInputs

  • 8/10/2019 FSM Design and Optimisation.ppt

    32/45

    NDG on FSM FPGA Based System Design 32

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Implementation- HW Considerations Contd Types of Flip-Flops at Output

    Outputs of Programmable Macro-Cells or LEs of CPLDs/FPGAsare Configurable

    Inverting/Non-Inverting Register or Combinational D Flip-Flop, S-R FF, J-K FF, or T-FF, any type is Possible T-FF or J-K FF can Produce more Efficient Implementation

    (fewer product terms in Boolean Equations) Better CAD tools make better choice automatically

  • 8/10/2019 FSM Design and Optimisation.ppt

    33/45

    NDG on FSM FPGA Based System Design 33

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    Algorithmic State Machine (ASM) Chart An Alternative Method to Represent FSM based on Flow-

    Chart Notation Popularized by Christopher Clare DesigningLogic Systems Using State Machines

    Key Features of ASM:

    FSM is in one State Block per statetime (Clock Cycle)

    Single Entry Point for each StateBlock

    For each combination of inputs,only one unambiguous exit path

    Outputs asserted high, low, high-impedance until the next clock cycle

    Fig-20: ASM Chart [a] ASM Elements [b]An ASM Block

    [a]

    [b]

  • 8/10/2019 FSM Design and Optimisation.ppt

    34/45

    NDG on FSM FPGA Based System Design 34

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    Algorithmic State Machine (ASM) Chart Contd ASM Construction Rules

    Must Follow these Rules:

    Each State can have one and onlyone State Box

    Outputs depending on the CurrentState only (Moore Model) arerepresented by Square Box

    Outputs depending on the Inputs(and of course the Current State), asin Mealy Model, are represented byRounded Box

    Decision Box contains theConditions for the Input Variables Fig-21: ASM Multi-Way Decision Block

    Simplification

  • 8/10/2019 FSM Design and Optimisation.ppt

    35/45

    NDG on FSM FPGA Based System Design 35

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    Algorithmic State Machine (ASM) Chart Contd ASM Advantages over (Bubble) State Diagram

    ASM Chart reflects HW Algorithmbetter than (Bubble) State Diagram

    Representation of FSM Easier to Follow and Understand ASM Chart avoids Transition

    Conflicts that could Occur in StateDiagram Representation of FSM

    EXAMPLE: Inputs I 3I2I1I0 = 1101, 1011,and 1111 all will make both transitionsto be True.

    Fig-22: Possible Conflicts in StateDiagram Representation of an FSM

  • 8/10/2019 FSM Design and Optimisation.ppt

    36/45

    NDG on FSM FPGA Based System Design 36

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    Algorithmic State Machine (ASM) Chart Contd ASM Representation of Vending Machine

    Fig-23: Mealy Model of Vending Machine [a] State Diagram [b] ASM Chart

    S0

    S1

    S2

    00/00

    00/0000/00

    01/00

    10/10

    01/00

    10/00

    10/11

    01/10

    Inputs/Outputs=Rs.2:Rs.1/Vend:Change

    S3

    xx/00

    Rs.2

    Rs.1

    Rs.0

    Rs.1

    Rs.1

    Rs.2

    Rs.2

    Rs.2

    Rs.1

    [a] [b]

  • 8/10/2019 FSM Design and Optimisation.ppt

    37/45

    NDG on FSM FPGA Based System Design 37

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Mealy FSM and Its RTL Coding

    Fig-24: Mealy FSM tobe Coded in Verilog

    HDL

  • 8/10/2019 FSM Design and Optimisation.ppt

    38/45

  • 8/10/2019 FSM Design and Optimisation.ppt

    39/45

    NDG on FSM FPGA Based System Design 39

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Mealy FSM and Its RTL Coding Contd

    Contd on Next Slide

    C o n

    t d f r o m

    P r e v . S

    l i d e

  • 8/10/2019 FSM Design and Optimisation.ppt

    40/45

    NDG on FSM FPGA Based System Design 40

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Mealy FSM and Its RTL Coding Contd

    C o n

    t d f r o m

    P r e v . S

    l i d e

    Contd on Next Slide

  • 8/10/2019 FSM Design and Optimisation.ppt

    41/45

    NDG on FSM FPGA Based System Design 41

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Mealy FSM and Its RTL Coding Contd

    C o n

    t d f r o m

    P r e v . S

    l i d e

  • 8/10/2019 FSM Design and Optimisation.ppt

    42/45

    NDG on FSM FPGA Based System Design 42

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Moore FSM and Its RTL Coding

    Contd on Next Slide

  • 8/10/2019 FSM Design and Optimisation.ppt

    43/45

    NDG on FSM FPGA Based System Design 43

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Moore FSM and Its RTL Coding

    Contd on Next Slide

    C o n

    t d f r o m

    P r e v . S

    l i d e

  • 8/10/2019 FSM Design and Optimisation.ppt

    44/45

    NDG on FSM FPGA Based System Design 44

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Moore FSM and Its RTL Coding

    C o n

    t d f r o m

    P r e v . S

    l i d e

    Contd on Next Slide

  • 8/10/2019 FSM Design and Optimisation.ppt

    45/45

    NDG on FSM FPGA Based System Design 45

    FSM Design and Optimization

    * C h a p

    t e r

    # 5 a n

    d P e t e r

    C h e u n g

    L e c

    t u r e

    N o

    t e s -

    D S D - 0

    6

    FSM Design Using Verilog HDL Contd Moore FSM and Its RTL Coding

    C o n

    t d f r o m

    P r e v . S

    l i d e