FSM ASM Diagramas

  • Upload
    vaz5z

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

  • 8/16/2019 FSM ASM Diagramas

    1/56

    George Mason UniversityECE 448 – FPGA and ASIC Design with VHDL

    Finite State Machines

    State Diagrams,

    State Tables,

     Algorithmic State Machine (ASM) Charts,

    and VHDL code

    ECE 44

    Lect!re

  • 8/16/2019 FSM ASM Diagramas

    2/56

    "ECE 448 – FPGA and ASIC Design with VHDL

    #e$!ired reading

    % S& 'ron and & Vranesic, Fundamentals of Digital Logi with VHDL Design

    Chapter 8, Synchronous Sequential Circuits

      Sections 8.1-8.5 Chapter 8.10, Algorithmic State Machine

    (ASM) Charts

    % *& Ch!, FPGA P!otot"#ing $" VHDL E%am#les

      Chapter 5, SM 

  • 8/16/2019 FSM ASM Diagramas

    3/56

    +ECE 448 – FPGA and ASIC Design with VHDL

    Datapath

    vs.

    Controller 

  • 8/16/2019 FSM ASM Diagramas

    4/56

    4ECE 448 – FPGA and ASIC Design with VHDL

    Str!ct!re o a T-.ical Digital S-stem

    Data.ath(E/ec!tion

    0nit)

    Controller (Control

    0nit)

    Data 1n.!ts

    Data 2!t.!ts

    Control 1n.!ts

    Stat!s 2!t.!ts

    Control

    Signals

    Stat!s

    Signals

  • 8/16/2019 FSM ASM Diagramas

    5/56

    3ECE 448 – FPGA and ASIC Design with VHDL

    Data.ath (E/ec!tion 0nit)

    % Mani.!lates and .rocesses data

    % *erorms arithmetic and logic o.erations, shiting,

    and other data.rocessing tas5s

    % 1s com.osed o registers, gates, m!lti.le/ers,

    decoders, adders, com.arators, AL0s, etc&% *ro6ides all necessar- reso!rces and

    interconnects among them to .erorm s.eciied

    tas5

    % 1nter.rets control signals rom the Controller and

    generates stat!s signals or the Controller 

  • 8/16/2019 FSM ASM Diagramas

    6/56

    7ECE 448 – FPGA and ASIC Design with VHDL

    Controller (Control 0nit)

    % Controls data mo6ements in the Data.ath b-sitching m!lti.le/ers and enabling or disablingreso!rces

    E/am.le8 enable signals or registers

    E/am.le8 control signals or m!/es

    % *ro6ides signals to acti6ate 6ario!s .rocessingtas5s in the Data.ath

    % Determines the se$!ence the o.erations.erormed b- Data.ath

    % Follos Some 9*rogram: or Sched!le

  • 8/16/2019 FSM ASM Diagramas

    7/56;ECE 448 – FPGA and ASIC Design with VHDL

    Controller 

    % Controller can be .rogrammable or non.rogrammable

    % *rogrammable

    % Has a .rogram co!nter hich .oints to ne/t instr!ction

    % 1nstr!ctions are held in a #AM or #2M e/ternall-

    % Micro.rocessor is an e/am.le o .rogrammablecontroller 

    % or=hardired instr!ctions>

    % In the following several lectures we will be focusing

    on non-programmable controllers.

  • 8/16/2019 FSM ASM Diagramas

    8/56ECE 448 – FPGA and ASIC Design with VHDL

    Finite State Machines% Digital S-stems and es.eciall- their Controllers can be

    described as Finite State Machines (FSMs)% Finite State Machines can be re.resented !sing

    % State Diagrams and State Tables  s!itable or

    sim.le digital s-stems ith a relati6el- e in.!ts

    and o!t.!ts

    % Algorithmic State Machine (ASM Charts 

    s!itable or com.le/ digital s-stems ith a large

    n!mber o in.!ts and o!t.!ts

    %  All these descri.tions can be easil- translated to the

    corres.onding s-nthesi?able VHDL code

  • 8/16/2019 FSM ASM Diagramas

    9/56@ECE 448 – FPGA and ASIC Design with VHDL

    !ardware Design with "T# $!D#

    *se!docode

    Data.ath Controller  

    'loc5

    diagram

    'loc5

    diagram

    State diagram

    o! ASM chart

    VHDL code VHDL code VHDL code

    1nterace

  • 8/16/2019 FSM ASM Diagramas

    10/56BECE 448 – FPGA and ASIC Design with VHDL

    %inite State Machines"efresher 

  • 8/16/2019 FSM ASM Diagramas

    11/56ECE 448 – FPGA and ASIC Design with VHDL

    Finite State Machines (FSMs)

    %  An- Circ!it ith Memor- 1s a Finite StateMachine

    % E6en com.!ters can be 6ieed as h!ge FSMs

    % Design o FSMs 1n6ol6es% Deining states

    % Deining transitions beteen states

    % 2.timi?ation minimi?ation

    % Man!al 2.timi?ationMinimi?ation 1s

    *ractical or Small FSMs 2nl-

  • 8/16/2019 FSM ASM Diagramas

    12/56"ECE 448 – FPGA and ASIC Design with VHDL

    Moore FSM

    % 2!t.!t 1s a F!nction o a *resent State 2nl-

    *resent State

    register 

  • 8/16/2019 FSM ASM Diagramas

    13/56+ECE 448 – FPGA and ASIC Design with VHDL

    Meal- FSM

    % 2!t.!t 1s a F!nction o a *resent State and 1n.!ts

  • 8/16/2019 FSM ASM Diagramas

    14/564ECE 448 – FPGA and ASIC Design with VHDL

    State Diagrams

  • 8/16/2019 FSM ASM Diagramas

    15/563ECE 448 – FPGA and ASIC Design with VHDL

    Moore Machine

    state & '

    output &

    state  'output

    transition

    condition &

    transition

    condition

  • 8/16/2019 FSM ASM Diagramas

    16/56

  • 8/16/2019 FSM ASM Diagramas

    17/56;ECE 448 – FPGA and ASIC Design with VHDL

    Moore 6s& Meal- FSM ()

    % Moore and Meal- FSMs Can 'eF!nctionall- E$!i6alent

    % E$!i6alent Meal- FSM can be deri6ed rom

    Moore FSM and 6ice 6ersa% Meal- FSM Has #icher Descri.tion and

    0s!all- #e$!ires Smaller

    States% Smaller circ!it area

  • 8/16/2019 FSM ASM Diagramas

    18/56ECE 448 – FPGA and ASIC Design with VHDL

    Moore 6s& Meal- FSM (")

    % Meal- FSM Com.!tes 2!t.!ts as soon as1n.!ts Change

    % Meal- FSM res.onds one cloc5 c-cle sooner

    than e$!i6alent Moore FSM% Moore FSM Has

  • 8/16/2019 FSM ASM Diagramas

    19/56@ECE 448 – FPGA and ASIC Design with VHDL

    Moore FSM E/am.le

    % Moore FSM that #ecogni?es Se$!ence =B>

    SB B S B S"

    BB

    B

    reset

    Meaningo states8

    SB8

    obser6ed

    S"8 =B>

    obser6ed

  • 8/16/2019 FSM ASM Diagramas

    20/56"BECE 448 – FPGA and ASIC Design with VHDL

    Meal- FSM E/am.le

    % Meal- FSM that #ecogni?es Se$!ence=B>

    SB S

    B B B B

    B reset

    Meaning

    o states8

    SB8

    obser6ed

  • 8/16/2019 FSM ASM Diagramas

    21/56"ECE 448 – FPGA and ASIC Design with VHDL

    Moore Meal- FSMs E/am.le

    cloc5

    in.!t

    Moore

    Meal-

    B B B B

    SB S S" SB SB

    SB S SB SB SB

  • 8/16/2019 FSM ASM Diagramas

    22/56

    ""ECE 448 – FPGA and ASIC Design with VHDL

    %inite State Machinesin $!D#

  • 8/16/2019 FSM ASM Diagramas

    23/56

    "+ECE 448 – FPGA and ASIC Design with VHDL

    FSMs in VHDL

    % Finite State Machines Can 'e Easil-

    Described ith *rocesses

    % S-nthesis Tools 0nderstand FSM Descri.tion

    i Certain #!les Are Folloed

    % State transitions sho!ld be described in a .rocess 

    sensiti6e to lo&  and as"nh!onous !eset  signals

    onl-

    %2!t.!t !nction described !sing r!les orcombinational logic, i&e& as conc!rrent statements

    or a .rocess ith all in.!ts in the sensiti6it- list

  • 8/16/2019 FSM ASM Diagramas

    24/56

  • 8/16/2019 FSM ASM Diagramas

    25/56

    "3ECE 448 – FPGA and ASIC Design with VHDL

    Meal- FSM

  • 8/16/2019 FSM ASM Diagramas

    26/56

    "7ECE 448 – FPGA and ASIC Design with VHDL

    Moore FSM E/am.le

    % Moore FSM that #ecogni?es Se$!ence =B>

    SB B S B S"

    B

    B

    B

    reset

  • 8/16/2019 FSM ASM Diagramas

    27/56

    ";ECE 448 – FPGA and ASIC Design with VHDL

    Moore FSM in VHDL ()

    T+, state IS (S* S&* S/

    SI01A# Moore2state3 state/

    42Moore3 ,"5CSS (cloc)* reset

    60I1

    I%(reset 7 8&9 T!1

    Moore2state :7 S/

    #SI% (cloc) 7 8&9 A1D cloc)9event T!1

    CAS Moore2state IS

    ;!1 S 7<

      I% input 7 8&9 T!1

      Moore2state :7 S&/

    #S

      Moore2state :7 S/

      1D I%/

  • 8/16/2019 FSM ASM Diagramas

    28/56

    "ECE 448 – FPGA and ASIC Design with VHDL

    Moore FSM in VHDL (")

      ;!1 S& 7

  • 8/16/2019 FSM ASM Diagramas

    29/56

    "@ECE 448 – FPGA and ASIC Design with VHDL

    Meal- FSM E/am.le

    % Meal- FSM that #ecogni?es Se$!ence=B>

    SB S

    B B B B

    B reset

  • 8/16/2019 FSM ASM Diagramas

    30/56

    +BECE 448 – FPGA and ASIC Design with VHDL

    Meal- FSM in VHDL ()

    T+, state IS (S* S&/SI01A# Meal=2state3 state/

    42Meal=3 ,"5CSS(cloc)* reset

    60I1

    I%(reset 7 8&9 T!1Meal=2state :7 S/

    #SI% (cloc) 7 8&9 A1D cloc)9event T!1

    CAS Meal=2state IS

      ;!1 S 7<

      I% input 7 8&9 T!1

    Meal=2state :7 S&/

    #S

      Meal=2state :7 S/

      1D I%/

  • 8/16/2019 FSM ASM Diagramas

    31/56

    +ECE 448 – FPGA and ASIC Design with VHDL

    Meal- FSM in VHDL (")

    ;!1 S& 7<  I% input 7 89 T!1

      Meal=2state :7 S/

    #S

      Meal=2state :7 S&/

      1D I%/

    1D CAS/

    1D I%/

    1D ,"5CSS/

    5utput :7 8&9 ;!1 (Meal=2state 7 S& A1D input 7 89 #S 89/

  • 8/16/2019 FSM ASM Diagramas

    32/56

    +"ECE 448 – FPGA and ASIC Design with VHDL

    Algorithmic State Machine (ASMCharts

  • 8/16/2019 FSM ASM Diagramas

    33/56

    ++ECE 448 – FPGA and ASIC Design with VHDL

     Algorithmic State Machine

     Algorithmic State Machine

      re.resentation o a Finite State Machine

      s!itable or FSMs ith a larger n!mber oin.!ts and o!t.!ts com.ared to FSMs

    e/.ressed !sing state diagrams and state

    tables&

  • 8/16/2019 FSM ASM Diagramas

    34/56

    +4ECE 448 – FPGA and ASIC Design with VHDL

    Elements !sed in ASM charts ()

    Output signals

    or actions

    (Moore type)

    State name

    Condition

    expression

    0 (False) 1 (True)

    Conditional outputs

    or actions (Mealy type)

    (a) State ox () !ecision ox

    (c) Conditional output ox

  • 8/16/2019 FSM ASM Diagramas

    35/56

    +3ECE 448 – FPGA and ASIC Design with VHDL

    State 'o/

    % State bo>  re.resents a state&

    % E$!i6alent to a node in a state diagram or aro in a state table&

    % Contains register transer actions or o!t.!tsignals

    % Moore-t=pe outputs are listed inside of thebo>. 

    % 1t is c!stomar- to rite onl- the name o thesignal that has to be asserted in the gi6enstate, e&g&, ? instead o ?G&

    %  Also, it might be !se!l to rite an action to beta5en, e&g&, co!nt G co!nt I , and onl- latertranslate it to asserting a control signal thatca!ses a gi6en action to ta5e .lace (e&g&,enable signal o a co!nter)&

    Output signals

    or actions

    (Moore type)

    State name

  • 8/16/2019 FSM ASM Diagramas

    36/56

    +7ECE 448 – FPGA and ASIC Design with VHDL

    Decision 'o/

    % Decision bo> indicates that a

    gi6en condition is to

    be tested and the

    e/it .ath is to bechosen accordingl-

    The condition

    e/.ression ma-incl!de one or more

    in.!ts to the FSM&

    Condition

    expression

    0 (False) 1 (True)

  • 8/16/2019 FSM ASM Diagramas

    37/56

    +;ECE 448 – FPGA and ASIC Design with VHDL

    Conditional 2!t.!t 'o/

    % Conditional

    output bo>

    % Denotes o!t.!t

    signals that are o

    the Meal- t-.e&

    % The condition that

    determines hether

    s!ch o!t.!ts are

    generated iss.eciied in the

    decision bo/&

    Conditional outputs

    or actions (Mealy type)

    ASMs re.resenting sim.le FSMs

  • 8/16/2019 FSM ASM Diagramas

    38/56

    +ECE 448 – FPGA and ASIC Design with VHDL

     ASMs re.resenting sim.le FSMs

    %  Algorithmic state machines can model bothMeal- and Moore Finite State Machines

    % The- can also model machines that are o

    the mi/ed t-.e

  • 8/16/2019 FSM ASM Diagramas

    39/56

  • 8/16/2019 FSM ASM Diagramas

    40/56

    4BECE 448 – FPGA and ASIC Design with VHDL

    Present Next state Outputstate

    w " 0 w " 1  z

    A A B 0B A C 0

    C A C 1

    Moore FSM E/am.le "8 State table

  • 8/16/2019 FSM ASM Diagramas

    41/56

  • 8/16/2019 FSM ASM Diagramas

    42/56

    4"ECE 448 – FPGA and ASIC Design with VHDL

    4S ieee.std2logic2&&[email protected] /

    1TIT+ simple IS

    ,5"T ( cloc) 3 I1 STD2#50IC /

      resetn 3 I1 STD2#50IC /

      w 3 I1 STD2#50IC /

    3 54T STD2#50IC /

    1D simple /

    A"C!ITCT4" 6ehavior 5% simple IS

    T+, State2t=pe IS (A* 6* C /

    SI01A# = 3 State2t=pe /

    60I1

    ,"5CSS ( resetn* cloc)

    60I1

    I% resetn 7 BB T!1

    = :7 A /

    #SI% (Cloc)B$1T A1D Cloc) 7 B&B T!1

    E/am.le "8 VHDL code ()

  • 8/16/2019 FSM ASM Diagramas

    43/56

    4+ECE 448 – FPGA and ASIC Design with VHDL

    CAS = IS

    ;!1 A 7<

    I% w 7 BB T!1= :7 A /

    #S

    = :7 6 /

    1D I% /

    ;!1 6 7<

    I% w 7 BB T!1

    = :7 A /

    #S

    = :7 C /

    1D I% /

    ;!1 C 7<

    I% w 7 BB T!1

    = :7 A /

    #S

    = :7 C /

    1D I% /

    1D CAS /

    E/am.le "8 VHDL code (")

    E am.le " VHDL code (+)

  • 8/16/2019 FSM ASM Diagramas

    44/56

    44ECE 448 – FPGA and ASIC Design with VHDL

    E/am.le "8 VHDL code (+)

      1D I% /  1D ,"5CSS /

      :7 B&B ;!1 = 7 C #S BB /

    1D 6ehavior /

    S S

  • 8/16/2019 FSM ASM Diagramas

    45/56

    43ECE 448 – FPGA and ASIC Design with VHDL

    A

    w 0=  z 0= ⁄

    w 1=  z 1= ⁄Bw 0=  z 0= ⁄

    Reset

    w 1=  z 0= ⁄

    Meal- FSM E/am.le +8 State diagram

  • 8/16/2019 FSM ASM Diagramas

    46/56

    47ECE 448 – FPGA and ASIC Design with VHDL

     ASM Chart or Meal- FSM E/am.le +

    w

    w0 1

    0

    1

    A

    B

    Reset

     z

    E l + VHDL d ()

  • 8/16/2019 FSM ASM Diagramas

    47/56

    4;ECE 448 – FPGA and ASIC Design with VHDL

    #I6"A"+ ieee /

    4S ieee.std2logic2&&[email protected] /

    1TIT+ Meal= IS

    ,5"T ( cloc) 3 I1 STD2#50IC /

      resetn 3 I1 STD2#50IC /

      w 3 I1 STD2#50IC /

    3 54T STD2#50IC /1D Meal= /

    A"C!ITCT4" 6ehavior 5% Meal= IS

    T+, State2t=pe IS (A* 6 /

    SI01A# = 3 State2t=pe /

    60I1,"5CSS ( resetn* cloc)

    60I1

    I% resetn 7 BB T!1

    = :7 A /

    #SI% (cloc)B$1T A1D cloc) 7 B&B T!1

    E/am.le +8 VHDL code ()

  • 8/16/2019 FSM ASM Diagramas

    48/56

    4ECE 448 – FPGA and ASIC Design with VHDL

    E/am.le +8 VHDL code (")

    CAS = IS  ;!1 A 7<

      I% w 7 BB T!1

    = :7 A /

    #S

    = :7 6 /1D I% /

      ;!1 6 7<

    I% w 7 BB T!1

    = :7 A /

    #S

    = :7 6 /

      1D I% /

    1D CAS /

  • 8/16/2019 FSM ASM Diagramas

    49/56

    Control 0nit E/am.le8 Arbiter ()

  • 8/16/2019 FSM ASM Diagramas

    50/56

    3BECE 448 – FPGA and ASIC Design with VHDL

    Control 0nit E/am.le8 Arbiter ()

    Arbiter 

    reset

    r&

    r

    r

    g&

    g

    g

    cloc)

    Control 0nit E/am.le8 Arbiter (")

  • 8/16/2019 FSM ASM Diagramas

    51/56

    3ECE 448 – FPGA and ASIC Design with VHDL

    Idle

    000

    1xx

    Reset

    gnt1g1 ⁄ 1=

    x1x

    gnt2g2 ⁄ 1=

    xx1

    gnt3g3 ⁄ 1=

    0xx 1xx

    01xx0x

    001xx0

    Control 0nit E/am.le8 Arbiter (")

  • 8/16/2019 FSM ASM Diagramas

    52/56

  • 8/16/2019 FSM ASM Diagramas

    53/56

    E l 4 VHDL d ()

  • 8/16/2019 FSM ASM Diagramas

    54/56

    34ECE 448 – FPGA and ASIC Design with VHDL

    E/am.le 48 VHDL code ()

    L1'#A#J ieeeK0SE ieee&stdlogic74&allK

    E

  • 8/16/2019 FSM ASM Diagramas

    55/56

    33ECE 448 – FPGA and ASIC Design with VHDL

    E/am.le 48 VHDL code (")'E1<

    *#2CESS ( #esetn, Cloc5 )

    'E1<

    1F #esetn NBN THE< - G 1dle K

    ELS1F (Cloc5NEVE

  • 8/16/2019 FSM ASM Diagramas

    56/56

    E/am.le 48 VHDL code (+)

    HE< gnt+ O

    1F r(+) NN THE< - G gnt+ K

    ELSE - G 1dle K

    E