Académique Documents
Professionnel Documents
Culture Documents
http://www.comp.nus.edu.sg/~cs1104
Flowcharts
ASM Charts
Components of ASM Charts
ASM Charts: An Example
Register Operations
CS1104-14
CS1104-14
CS1104-14
Top-Down Approach
unnecessary details).
Break the problem into smaller sub-problems.
Repeat the process until subproblems are small enough to
be solved directly (implementable).
CS1104-14
Top-Down Approac
Top-Down Approach
Do Tutorials
Ask questions
CS1104-14
Pass Tests
Practice
Revise
Top-Down Approac
Pass Exam
Sleep well
CS1104-14
CS1104-14
Control unit
(Controller)
Input
data
Data
Processor
(Architecture)
Output
data
another.
Driver (controller): gives instructions to car to achieve
objective.
CS1104-14
Flowcharts
Main symbols:
Operation box: contains tasks/operations to perform.
Decision box: alternative actions based on decisions to be
taken.
Arrows: indicate appropriate sequencing.
CS1104-14
Flowcharts
10
Flowcharts
Sub-task or
operation to
perform
CS1104-14
Flowcharts
11
Flowcharts
choice
option A
CS1104-14
option B
option C
Flowcharts
12
Flowcharts
Sequential flow: simplest type of sequencing; tasks
are done in sequential order.
CS1104-14
Flowcharts
13
Flowcharts
CS1104-14
Flowcharts
14
Flowcharts
enough?
yes
Eat dessert
CS1104-14
Flowcharts
15
Flowcharts
Flowcharts
can be used
to implement
complex
decisions.
nice colour
& style?
no
yes
affordable?
no
yes
made in
Europe?
no
poor
insulting
yes
test out
fitting?
acceptable
BFs opinion?
encouraging
reject
CS1104-14
Flowcharts
get BF to buy
16
ASM Charts
CS1104-14
ASM Charts
17
state
binary
code
one or more
operations
CS1104-14
Components of ASM
18
deciding
factors
CS1104-14
deciding
factors
Components of ASM
19
conditional
operations
CS1104-14
Components of ASM
20
An example:
T0
Initial state
A is a register; Ai
stands for ith bit of
the A register.
A = A4A3A2A1
T1
A 0
F 0
A A+ 1
A2
E 0
E 1
A3
T2
1
F 1
CS1104-14
ASM Charts: An Ex
21
Register Operations
Registers are present in the data processor for
CS1104-14
Register Operations
22
Register Operations
CS1104-14
Register Operations
23
CS1104-14
24
1
T1
A 0
F 0
A A+ 1
3 ASM blocks
A2
E 0
E 1
A3
T2
1
F 1
CS1104-14
25
clock cycle
decision boxes are dependent on the status of the previous
clock cycle (that is, they do not depend on operations of
current block)
CS1104-14
26
clock
10
11
12 13
states
T0
T0
T1
T1
T1
T1
T1
T1
T1
T2
T0
T0
input
S=0
S=1
A=2
A=3
A=4
register
values
Operations
T0
S=0
A=0
F=0
A=1
A=7
F=1
E=0
A0
F0
A=5 A=6
E=0
AA+1
E0
AA+1
E0
E=1
E=1
AA+1
E1
AA+1
E1
E=0
E=0
E=1
AA+1
E0
AA+1
E0
F1
AA+1
E1
A = A4A3A2A1
CS1104-14
27
clock
states
T0
T0
T1
T1
T1
T1
input
S=0
S=1
A=1
A=2
A=3
E=0
E=0
E=1
register
values
S=0
A=0
F=0
1
T1
A 0
F 0
A0
F0
Operations
A A+ 1
A2
E 0
T2
0
1
F 1
A = A4A3A2A1
CS1104-14
clock
10
11
12 13
states
T1
T1
T1
T2
T0
T0
T0
input
E 1
A3
AA+1
AA+1
E0
E1
AA+1
AA+1
E0
E1
register
values
A=4
A=5 A=6
A=7
E=1
E=0
E=1
F=1
E=0
AA+1
F1
E0
AA+1
AA+1
E0
E1
Operations
28
CS1104-14
29
Procedure:
Step 1: Identify all states and assign suitable codes.
Step 2: Draw state diagram.
Step 3: Formulate state table using
CS1104-14
30
T2
A 0
F 0
Present
state
G1 G0
A A+ 1
T0 = 00
T1 = 01
T2 = 11
T1
1
T1
T0
Initial state
A2
E 0
E 1
A3
T2
1
F 1
CS1104-14
0
0
0
0
0
1
0
0
1
1
1
1
Next
state
inputs
outputs
A2 A3 G1+ G0+ T0 T1 T2
0
1
X
X
X
X
X
X
0
1
1
X
X
X
X
0
1
X
0
0
0
0
1
0
0
1
1
1
1
0
1
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
1
31
Guidelines:
always use high-level units
simplest architecture possible.
CS1104-14
32
Deduce:
One 4-bit register A (e.g.: 4-bit synchronous counter with
clear/increment).
Two flip-flops needed for E and F (e.g.: JK flip-flops).
CS1104-14
33
start
T0
Controller
T1
Clk
A2
T2
J
K
J
A4
A3
A2
4-bit syn.
counter A
CS1104-14
A1
count
CP
clear
clock
34
state/output functions.
2. Decoder + D flip-flops
suitable for moderately large controllers.
procedure: use decoder to obtain individual states; from the
CS1104-14
Implementing the Co
35
3. Multiplexers
a more structured approach to implement controller.
suitable for moderately large controllers.
three level structure:
first level consists of multiplexers that determine the next
state of the register;
second level is a register that holds the present state;
third level has a decoder to provide separate output for each
controller state.
CS1104-14
Implementing the Co
36
5. PLA/ROM
highly regular approach.
ROM approach uses a very simple table lookup technique
CS1104-14
Implementing the Co
37
Implementing Controller:
With JK Flip-flops
State table
obtained from
ASM chart:
Present
state
G1 G0
0
0
0
0
0
1
0
1
0
1
1
1
inputs
S
0
1
X
X
X
X
A2
X
X
0
1
1
X
A3
X
X
X
0
1
X
Next
state
G1+ G0+
0
0
0
1
0
1
0
1
1
1
0
0
outputs
T0
1
1
0
0
0
0
T1
0
0
1
1
1
0
T2
0
0
0
0
0
1
G1 G0
0 0
0 0
0 1
0 1
0 1
1 1
CS1104-14
inputs
S A2
0 X
1 X
X 0
X 1
X 1
X X
Next
state
Flip-flop
inputs
Implementing Control
38
Implementing Controller:
Decoder + D Flip-flops
G1
D Q
D Q
G0
2x4
decoder
T0
T1
unused
T2
clock
CS1104-14
Implementing Contro
39
Implementing Controller:
Decoder + D Flip-flops
Given the
state table:
Present
state
G1 G0
0
0
0
0
0
1
0
0
1
1
1
1
Next
state
inputs
outputs
A2 A3 G1+ G0+ T0 T1 T2
0
1
X
X
X
X
X
X
0
1
1
X
X
X
X
0
1
X
0
0
0
0
1
0
0
1
1
1
1
0
1
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
1
CS1104-14
Implementing Contro
40
Implementing Controller:
Decoder + D Flip-flops
Circuit:
A2
A3
G1
D Q
D Q
G0
2x4
decoder
T0
T1
unused
T2
clock
CS1104-14
Implementing Contro
41
Implementing Controller:
One Flip-flop per State
D Q
T0
D Q
T1
:
:
clock
CS1104-14
Implementing Control
42
Implementing Controller:
One Flip-flop per State
CS1104-14
Implementing Control
43
Implementing Controller:
One Flip-flop per State
State table:
Present
state
Next
state
inputs
S A2 A3
T0
T0
T1
T1
T1
T2
0
1
X
X
X
X
X
X
0
1
1
X
X
X
X
0
1
X
State diagram:
S=0
A2=0
S=1
T0
T1
T1
T1
T2
T0
T0
T1
T2
A2=1,
A3=0
A2=1,
A3=1
CS1104-14
Implementing Control
44
Implementing Controller:
One Flip-flop per State
A2
A3
DT0 = T2 + S'.T0
DT1 = S.T0 + (A2.A3)'.T1
DT2 = A2.A3.T1
CS1104-14
D Q
T0
D Q
T1
D Q
T2
clock
clear
Implementing Control
45
Implementing Controller:
One Flip-flop per State
Alternative: Use Q' output for T0, and input function for
T0 is complemented. To initialise, clear all flip-flops to
zero.
D Q
Q'
A2
A3
CS1104-14
T0
D Q
T1
D Q
T2
clock
clear
Implementing Control
46
Implementing Controller:Multiplexers
CS1104-14
Implementing Control
47
Implementing Controller:Multiplexers
Example 1: Given
the state table.
Reformat the
state table.
CS1104-14
Present
state
G1 G0
0
0
0
0
0
1
0
1
0
1
1
1
Present
state
inputs
S
0
1
X
X
X
X
Next
state
G1 G0 G1
0 0
0
0 0
0
0 1
0
0 1
0
0 1
1
1 1
0
Next
state
A2 A3 G1+ G0+
X X
0
0
X X
0
1
0 X
0
1
1 0
0
1
1 1
1
1
X X
0
0
G0+
Input
conditions
0
1
1
1
1
0
S'
S
A2'
A2. A3'
A2. A3
1
Implementing Control
Multiplexer
inputs
MUX1
MUX0
48
Implementing Controller:Multiplexers
Next
state
G1 G0 G1
0 0
0
0 0
0
0 1
0
0 1
0
0 1
1
1 1
0
CS1104-14
G0
0
1
1
1
1
0
Input
conditions
S'
S
A2'
A2. A3'
A2. A3
1
Multiplexer
inputs
MUX1
MUX0
A2. A3
Implementing Control
49
Implementing Controller:Multiplexers
Present
state
Draw circuit:
T0
T1
T2
A2
A3
0
0
0
1 MUX1
2
3
S1 S0
D Q
G1 G0
0 0
0 1
1 1
S1 S0
0
1 MUX0
2
3
Determine next
state of register
CS1104-14
D Q
MUX1
0
A2. A3
0
MUX0
S
1
0
G1
2x4
decoder
S
1
Multiplexer
inputs
G0
T0
T1
T2
clock
Hold present
state
Implementing Control
50
Implementing Controller:Multiplexers
Present
state
Example 2:
T0
T1
0
T3
0
0
0
w
1 01
11
T2
CS1104-14
G1 G0 G1
0
0
0
0
0
0
0
1
1
0
1
1
1
0
0
1
0
1
1
0
1
1
1
0
1
1
1
1
1
1
00
1
1
Next
state
Present
state
10
y
0
T0
T1
T2
T3
G0
0
1
0
1
0
0
1
1
0
1
Input
conditions
w'
w
x
x'
y'
y.z'
y.z
y'.z
y
y'.z'
Multiplexer
inputs
G1 G0
MUX1
MUX0
0
0
0
w
0
1
x+x'=1
x'
1
0 y.z' + y.z
y.z
=y
1
1
y + y'.z'
y'.z +
= y + z' y'.z' = y'
Implementing Control
51
Implementing Controller:Multiplexers
Present
state
T0
T1
T2
T3
y
z'
0
1
y
G1 G0
0 0
0 1
1 0
1 1
Multiplexer
inputs
MUX1
0
1
y
y + z'
0
1 MUX1
2
3
S1 S0
D Q
MUX0
w
x'
y.z
y'
G1
2x4
decoder
y
z
CS1104-14
w
x'
y'
S1 S0
0
1 MUX0
2
3
D Q
G0
T0
T1
T2
T3
clock
Implementing Control
52
Commands to
architecture
PLA/ROM
Present
state
Next
state
CS1104-14
Implementing Contr
53
End of segment
CS1103