Dsd Vhdl Ch5

  • Upload
    ftkoay

  • View
    234

  • Download
    0

Embed Size (px)

Citation preview

  • 7/29/2019 Dsd Vhdl Ch5

    1/23

    1

    Ch. 5 Digital Design with SM Chart

    Flowchart for Hardware Design

    - alternative to state diagram

    - easier to understand

    - condition for state graphs are satisfied automatically

    - direct hardware realizationExamples

    -multiplier

    -dice game controller

    Components of State Machine (Flow) Charts

    SM Chart, or ASM(Algorithmic State Machine) Chart

    3 components

    1) State Box 2) Decision Box 3) Conditional Output Box

    State box

    State_name/output list, output list is optional

    Optional state code

    Condition: T rue , False branches

    Conditional output box

  • 7/29/2019 Dsd Vhdl Ch5

    2/23

    2

    SM Block Contains only 1 state box + decision + cond. output

    description of one state

    All tests take place in one clock

    1 Entrance path and one or more exit path

    in p ath 3

    z3=z4=0

    link path

    entrancepath exit

    path(s)

    Equivalent SM blocks

    ( b) is more complex

    Next state

  • 7/29/2019 Dsd Vhdl Ch5

    3/23

    3

    Equivalent SM Chart for a Combinational

    Networks

    (a) (b)

    Z1=1 if (A=1) or

    (A=0,B=1, and C=1)

    i.e. Z1=A+ABC =A+BC

    Rules of SM block

    1. For every valid c ombination of input variab les ,

    there must be exactly one exit path defined.

    2. Internal feedback is not allowed in SM block

  • 7/29/2019 Dsd Vhdl Ch5

    4/23

    4

    Equivalent SM Blocks

    Correct in SM chart

    concurrent!

    sequential!

    executed in one clock time,

    serial form

    Conversion of a State Graph to an SM Chart

    Moore output : Za,Zb, Zc

    Mealy output: Z1,

    Z2

  • 7/29/2019 Dsd Vhdl Ch5

    5/23

    5

    Timing Chart

    5.2 Derivation of SM Charts

    draw block diagram

    de fine input and o utput s ignals

    construct SM chart

  • 7/29/2019 Dsd Vhdl Ch5

    6/23

    6

    SM chart for Binary Multiplier

    K: completion signal

    VHDL for SM Chart of Figure 5-9

    entity Mult is

    port (CLK,St,K,M: in bit;

    Load,Sh,Ad,Done: out bi t ) ;

    end mult;

    architecture SMbehave of Mult is

    signal State , Nexts ta te : integer range 0 to 3 ;

    begin

    process ( S t , K, M, S ta te ) - - s t a r t if s t at e o r in p ut schange

    begin

    Load

  • 7/29/2019 Dsd Vhdl Ch5

    7/23

    7

    when 2 = > Sh

  • 7/29/2019 Dsd Vhdl Ch5

    8/23

    8

    Flow Chart for Dice Game

    SM Chart for Dice Game

  • 7/29/2019 Dsd Vhdl Ch5

    9/23

    9

    State Graph for Dice Game Controller

    Behavioral Model for Dice Game

    entity DiceGame is

    port ( Rb, Res et, CLK: in bit;

    Sum: in integer range 2 to 1 2 ;

    Roll, Win, Lose : ou t bi t ) ;

    e nd DiceGame;

    library BITLIB;

    us e BITLIB.bit_pack. all;

    architecture DiceBehave of DiceGame is

    signal State , Nexts ta te : integer range 0 to 5 ;

    signal Point: intege r range 2 to 1 2 ;

    signal Sp: bit;begin

    process (Rb, Res et , Sum, State)

    begin

    Sp

  • 7/29/2019 Dsd Vhdl Ch5

    10/23

    10

    when 2 = > Win

  • 7/29/2019 Dsd Vhdl Ch5

    11/23

    11

    SM Chart for Dice Game Test

    Dice Game Test Module

    entity GameTest is

    port (Rb, Rese t: out bit; Sum: out integer range 2 to 12;

    CLK: inout bit; Roll, Win, Lose: in bit) ;

    e nd GameTest ;

    library BITLIB;

    us e BITLIB.bit_pack.all;

    architecture dicetest of GameTest issignal Ts tate , Tnext: integer range 0 to 3 ;

    signal T rig1: bit;

    type ar r is arra y ( 0 to 11) of integer;

    constant Sumarray:ar r := (7 ,11 ,2 ,4 ,7 ,5 ,6 ,7 ,6 ,8 ,9 ,6) ;

    begin

    CLK

  • 7/29/2019 Dsd Vhdl Ch5

    12/23

    12

    process (Roll, Win, Lose, Tstate)

    variable i: na tura l; - - i is i n it ia l ized to 0

    begin

    case T s t a t e is

    when 0 = > Rb

  • 7/29/2019 Dsd Vhdl Ch5

    13/23

    13

    Simulation and Command File for Dice Game

    Tester

    list / dice test/ trig1 - NOTrigge r sum1 win1 los e1 / dice / point

    run 2000

    PLA Table for Multiplier Control

    A+ = A'BM'K + A'BM + AB'K = A'B(M + K) + AB'K

    B+ = A'B'St + A'BM'(K'+K) + AB'(K'+K) = A'B'St +

    A'BM' + AB'

    Sh = A'BM'(K'+K) + AB'(K'+K) = A'BM' + AB'

    Load = A'B'St Ad = A'B MDone = A B

  • 7/29/2019 Dsd Vhdl Ch5

    14/23

    14

    PLA Realization of Dice Game Controller

    PLA Table for Dice Game

  • 7/29/2019 Dsd Vhdl Ch5

    15/23

    15

    Maps Derived from Table 5-2

    Data Flow Model for Dice Game

    library BITLIB;

    us e BITLIB.bit_pack.all;

    architecture Dice_Eq of DiceGame is

    signal Sp,Eq,D7,D711 ,D231 2: bit:= '0'; s ignal

    DA,DB,DC,A,B,C :bit:= '0 ';

    signal Point: integer range 2 to 12;

    beginprocess (Clk)

    begin

    if rising_edge(Clk) then

    A

  • 7/29/2019 Dsd Vhdl Ch5

    16/23

    16

    Win

  • 7/29/2019 Dsd Vhdl Ch5

    17/23

    17

    Complete Dice Gameentity Game is

    port ( Rb, Res et, Clk: in bit;

    Win, Lose : ou t bi t ) ;

    e nd Game;

    architecture Play1 of Game is

    component Counter

    port ( Clk, Roll: in bit;

    Sum: out integer range 2 to 1 2 ) ;

    end component ;

    component DiceGame

    port ( Rb, Res et, CLK: in bit;

    Sum: in integer range 2 to 1 2 ;

    Roll, Win, Lose : ou t bi t ) ;

    end component ;signal roll1: bit;

    signal sum1: integer range 2 to 1 2 ;

    begin

    Dice: Dicegame port map(Rb,Reset,Clk,sum1,roll1,Win,Lose);

    Count: Counter port map(Clk,roll1,sum1);

    e nd Play1;

    Control Network Using an input Mux

    to Select the Next State

  • 7/29/2019 Dsd Vhdl Ch5

    18/23

    18

    PLA/ ROM Table for Figure 5-27

  • 7/29/2019 Dsd Vhdl Ch5

    19/23

    19

    MUX for SM Chart of Fig. 5-27

    Counter Network using a Counter for State

    Register

  • 7/29/2019 Dsd Vhdl Ch5

    20/23

    20

    SM chart with Serial State Assignment and

    Added X-states

    SM Chart with Serial State Assignment and

    Added X-state

  • 7/29/2019 Dsd Vhdl Ch5

    21/23

    21

    MUX for SM chart of Figure 5-30

    PLA Table for Figure 5-31

  • 7/29/2019 Dsd Vhdl Ch5

    22/23

    22

    SM Charts for Serially Linked State Machine

    Linked SM Charts for Dice Game

  • 7/29/2019 Dsd Vhdl Ch5

    23/23

    Linked SM Charts for Dice Game