Académique Documents
Professionnel Documents
Culture Documents
: : 2004.01.09
Contents
SM Charts properties
Derivation of SM Charts Implementation of the Dice game Alternative realizations for SM Charts using Microprogramming Linked State Machine
SM Charts properties
ASM (Algorithmic State Machine) Often used to design control units for digital systems Useful in the H/W design of digital systems Easier to understand the operation Leads directly to a hardware realization
Components of SM chart
Optional State code
xxx
State_name/ Output list
(true branch)
(false branch)
condition
Example of an SM chart
One entrance path
S1/Z1Z2
Link Path a
One state
SM block
0 X1
1
Link Path b
Z3 Z4 0 X2 1
X3
Z5
n exit paths
Equivalent SM Blocks
S1/Z1 0
X2
1 X1 0 Z2 S3/
(b)
S0/
S0/ 1 C 0 Z1 B 0 Z1 0 1 1 A 1
A+BC 0
(a)
(b)
Z1=A+A`BC=A+BC
S0/
S0/
x
1
x 1
(a) Incorrect
(b) Correct
So/ Za
0/0
S1/ Zb
0/Z1
S2/ Zc
1/Z2
00
S0/Za
Link 1 0
S1/Zb
Link 2 0
S2/Zc
0
11
Link 3
Z1
Z2
Derivation of SM Charts
St
Load S1/
0
Sh
0
Ad S2/Sh
1
K
1
S3/Done
Entity Mult is port(CLK,St,K,M: in bit; Load,Sh,Ad,Done: out bit); End Mult; Architecture SMbehave of Mult is signal State, Nextstate : integer range 0 to 3; begin process(St, K, M, State) begin Load<=0 ; Sh<=0 ; Ad<=0 ; case State is when 0 => if St=1 then (state 0) --- St Load<=1; Nextstate<=1; else Nextstate<=0; --- St
EX2.Dice Game
Rule
The player wins if the sum is 7 or 11 The player loses if the sum is 2,3,12 otherwise, the sum is referred to as a point and roll again The second or subsequent, the player wins if the sum equals the point the player loses if the sum is 7, Otherwise, the player roll again until player wins or loses
EX2.Dice Game
Display Display DiceGame Module Rb 1-to-6 Counter 1-to-6 Counter Roll Reset
D7 D711 D2312
Control Win
Point Register
Comparator
Eq
Lose
Sp
Roll dice Y N
Sum = Point
Sum = 7
Y Win Y N N Lose Y
Reset
Reset
S0 / 0 Rb 1 S1 / Rb 0
D711
0
D2312
1
S3/Lose Reset 0
0 Sp S4 / Rb 1 S5 / Rb 0 Eq
S4 : No button
S5 : Button Pressed
0
D7 1
Entity Game is port(Rb, Reset,Clk : in bit; Win, Lose: out bit); end Game;
component Dicegame port(Rb, Reset,Clk : in bit; Sum : out integer range 2 to 12; Roll, Win, Lose : out bit); end component; signal roll1 : bit; signal sum1: integer range 2 to 12; begin Dice:Dicegame port map(Rb,Reset,Clk,sum1,roll1,Win,Lose); Counter port map(Clk,roll1,sum1); end Play1;
Architecture Play of Game is component Counter port(Clk, Roll : in bit; Sum : out integer range 2 to 12); end component;
PLA
C
C+ B+
D Q CK D Q CK D Q CK
B
A
A+
Clock
2
3 4 5 6 7 8 9
000
001 001 001 001 010 010 011
1
1 0 0 0 -
0 1 1
0 0 1 -
0 1 -
0
0 1 0 0 0 0 0
0
0 0 1 1 1 0 0
1
1 0 1 0 0 0 0
0
0 0 0 0 1 1 0
0
0 0 0 0 0 0 1
0
1 0 0 0 0 0 0
0
0 1 0 0 0 0 0
10
11 12 13 14 15 16 17 18
011
100 100 101 101 101 101 110 111
0 1 0 0 0 1 -
0
-
0 1 -
0 0 1 -
0
1 1 1 0 0 1 -
1
0 0 0 1 1 0 -
1
0 1 0 1 0 1 -
0
0 0 0 0 0 0 -
1
0 0 0 0 0 0 -
0
0 0 0 0 0 1 -
0
0 0 0 0 0 0 -
Sp = ABCRbD711D2312
architecture Dice_Eq of DiceGame is signal Sp, Eq, D7, D711, D2312 : bit : =0; signal DA, DB, DC, A, B, C, : bit : =0; signal Point : integer range 2 to 12 ; begin process(CLK) begin if rising_edge(CLK) then A<=DA; B<=DB; C<=DC; if Sp=1 then Point<=Sum; end if; end if end process ;
Register Inputs
MUX1
MUX2
A sequential machine becomes large and complex, Desirable to divide the machine into several smaller machines linked together. Each of the smaller machines is easier to design and implement.
Machine A (calling machine) Machine B (called machine)
SOME STATES
IDLE 0
ZA SA / ZA 0 1 OTHER STATES
ZB 1 OTHER STATES
SB/ ZB