Title: Digital Design With SM
1Digital Design With SM Charts ( Contd Session 3)
AGENDA
- Example No.1- Binary Multiplier
- State Graph for Multiplier
- SM Chart for Binary Multiplier
- VHDL Code for the Multiplier Control
2Digital Design WITH SM Charts (Contd Session-3)
- Example No.2-Electronic Dice Game
Rules of the Game
Block Diagram
Flow Chart
SM Chart
Game Tester
- H/W Realization of SM Charts
PLA Implementation OF Multiplier Control
3-/Done
S0
S9
St/Load
-/Sh
S1
S8
St/0
M/Sh
M/Ad
M/Ad
M/Sh
S7
S2
M/Sh
-/Sh
-/Sh
M/Sh
S6
S3
S5
S4
M/Ad
M/Ad
-/Sh
State Graph for Binary Multiplier Control
4 Binary Multiplier
St/Load
St
Done
Add-shift control
S1
St/0
M/Sh
S0
Load
Ad
-/Sh
M
M/Ad
Sh
S2
State graph for add-shift control
K
St/ 0
Control
St/Load
S0
S1
KM/Sh
KM/Sh
M/Ad
Multiplier Control
-/Done
-/Sh
S2
S3
-K/Sh
Final state graph for add- shift control
5SM chart for Binary Multiplier
S0/
1
St
S1/
0
0
Load
0
M
1
Ad
Sh
S2 / Sh
K
0
1
0
K
1
S3/Done
6Conversion of an SM Chart to a VHDL Code
- A case statement can be used to specify as to
- what happens in each state
- Each condition box corresponds directly to an
if - statement ( or an elsif)
7VHDL code for multiplier control
architecture Multibehave of Multi is signal
State, Nextstate integer range 0 to 3 begin
process ( St, K, M, State) --start
if state or inputs change begin Load
lt 0 Sh lt 0 Ad lt 0 case
state is when 0 gt if St 1
then St (state 0)
Load lt 1
Nextstate lt 1
else Next state lt 0 -- St
end if
when 1gt if M 1 then -- M (
state 1) Ad
lt 1
8 Next state lt 2
els e
-- M
Sh lt 1 if K
1 then Next state lt 3 -- K
else Nextstate lt 1
-- K endif
endif when 2 gt Sh
lt1 --(
state 2) if K 1 then
Nextstate lt 3 --K else
Nextstate lt 1 --K
endif when 3 gt Done lt1
--(state 3)
Nextstate lt 0 endcase endprocess
9 process (CLK) begin if CLK 1 then
state lt Next state --
update state on rising edge end if
end process end Multibehave
10Example No.2- Electronic DICE Game
Rules of the GAME
- After the first Roll of the Dice, the player
wins if - the Sum is 7 or 11
- If the SUM is 2, 3 or 12 the player loses
- Otherwise the sum obtained on the first ROLL is
- referred to as a POINT
- On the second ROLL the player wins if the
- SUM POINT
The player loses if the SUM is 7
- Otherwise, the player must Roll until he/she
wins - or loses ( and RESETS)
11Components for the Dice game
- An Adder to add the two counters output
- A Register to store the POINT
- Test Logic to determine conditions for WIN
- or LOSE
12Electronic Dice Game (contd..)
Display
Display
Rb
C O N T R O L
Dice game Module
1-to-6 Counter
1-to-6 Counter
Reset
D7
ADDER
Test Logic
Win
Sum
D2312
Eq
Lose
Point Reg
Comparator
Sp
Block Diagram for Dice Game
13How does this work?
- The input to the Dice game come from 2 push
- Buttons- Rb (Roll button) and Reset
- Reset button is used to start a new game
- When the Roll button is pushed, the Dice
counters - count at a high speed, so they are not read.
- When the Roll button is released, the values in
the - 2 counters are displayed and the game proceeds
- If the Win or Lose light is not on, the player
must - push the Roll button again to keep playing
14Input signals to the control Block
- D7 1, if the Sum of the Dice is 7
- D711 1 if the sum of the Dice is 7 or 11
- D2312 1 if the sum of the dice is 2, 3, or 12
- Eq 1 if the sum of the dice equals the number
- stored in the POINT Register
- Rb 1 When the ROLL button is pressed
- Reset 1 When the Reset button is pressed
15 Output signals from the control Block
- Roll 1 Enables the Dice counters
- Sp 1 Causes the sum to be stored in the point
- Register
- Win 1 Turns on the WIN light
- Lose 1 Turns on the Lose light
16Roll
Y
N
S7/12
Y
N
S2/3/12
Store S in P.R
Roll
N
N
Y
Y
S7
SP
Win
Lose
Y
Reset
N
N
Y
Reset
Flow Chart for Dice Game
17S0 /
0
Rb
1
S1 /
SM Chart for Electronic Dice Game
Roll
Rb
1
0
From Eq D-Box
1
D711
S3/Lose
0
S2/win
1
D2312
Reset
Reset
0
From D71
To Sp
18From D3212 Decision Box
Sp
S4/
Rb
To S3/Lose State Box
S5/
Roll
Rb
To S2/WIN state Box
Eq
SM Chart for Electronic Dice Game
D7
19H/W Realisation of SM Charts
- State Machine is a Sequential Machine
- It consists of a Combinational sub network
- And Flip-flops for storing the state
- Make the statement as AB..
- Make a PLA Table indicating I/Ps,O/Ps, States
- and the next states
- Example is Binary Multiplier Control
20H/W Realisation of SM Charts
S0/
1
St
S1/
0
0
Load
0
M
1
Ad
Sh
S2 / Sh
K
0
1
0
K
1
S3/Done
SM chart for Binary Multiplier
21H/W Realisation of SM Charts
I/O
A B St M K A B Load Sh Ad done
S
0 0 0 - - 0 0
0 0 0 0 0 0 1 -
- 0 1 1 0 0
0 0 1 - 0 0 0 1
0 1 0 0 0 1 -
0 1 1 1 0 1 0
0 0 1 - 1 - 1 0
0 0 1 0
S0
S1
1 0 - - 0 0
1 0 1 0 0
S2
1 0 - - 1
1 1 0 1
0 0
1 1 - - - 0
0 0 0 0 1
S3
A AB(MK) ABK
Load AB St
B ABSt A BM AB
Ad AB M
Sh ABM AB
Done AB
2222
Done
P L A
Sh
St
Ad
M
Load
K
B
D
PLA Implementation Of Multiplier Control
Q
B
A
D
A
Q
CLOCK
2323
Linked State Machines
- If Machine is large and complex Divide this to
smaller ones
- These small machines are linked together
- Smaller machines are easier to design and
implement
- These submachines can be called elsewhere by the
main machine
- This is analogous to dividing a large software
program into - procedures that are called by the main program
2424
A
B
Some States
Idle
0
ZA
1
SA/ZA
Other states
0
ZB
1
Other States
SB/ZB
SM charts for serially linked State Machines
2525
CONCLUSION
- Procedure for Digital Design Using SM charts
- Writing VHDL code for the SM chart
- H/W Implementation using PLAs
- Split the control unit into several sections by
using - linked state machines
26(No Transcript)