ASM Chart: Multiplier Control COE608: Computer Organization and Architecture
ASM Chart: Multiplier Control COE608: Computer Organization and Architecture
Ryerson University
Overview
Types of Sequential Circuits
Page: 1
Combinational
Logic
Output
variables
(z1 ..... zm)
}
}Nvext-state
ariables
Clock
Memory
Devices
Inputs
Primary Inputs
State variables
Outputs
Output variables
Next state variables.
Page: 2
Comb.
Logic
Network
Outputs
(Z)
Next State
State Present
Reg. State
Clock
Moore Machines: The outputs depend on the
present state only.
Inputs
(x)
Comb.
Logic
Network
Outputs
(Z)
Next State
State Present
Reg. State
Clock
G.Khan
Page: 3
Moore Model
AB/S
AB
00/0
11/0
10/0
00/0
11/1
01/0
00
11
NS
Z/0
01
10
01/0
10/0
PS
AB
00
x x
y x
z x
01
00
11
Y/1
AB
00 01 11 10
x x/0 z/0 x/0 y/0
y x/0 y/0 x/1 y/0
z x/1 z/0 x/0 z/0
G.Khan
X/0
10
00/1
11/0
01/0
10/0
PS
00
11
01
10
NS
01
z
y
z
11
x
x
x
10
y
y
z
Output
S
0
1
0
Page: 4
Input A
Input B
Output S
Input A
Input B
Output S
G.Khan
Page: 5
G.Khan
Page: 6
1
10/0
01/0
11/0
01/0
10/0
00/0
01/0
10/0
11/0
00/0
00/0
00/0
3
11/0
G.Khan
Page: 7
State Assignment
The occurrence of sequence of pairs of inputs
00001110 is to be detected.
Mealy Machine Design Approach
State-Transition Table
Present
Inputs X1, X2
state
Next state
Output z
00 01 11 10 00 01 11 10
2 1 1 1 0 0 0 0
1
3 1 1 1 0 0 0 0
2
3 1 4 1 0 0 0 0
3
2 1 1 1 0 0 0 1
4
State Assignment: Assign binary codes to the
states. 1 = 00, 2 = 01, 3 = 11 and 4 = 10
Present
State
y1y2
00
01
11
10
G.Khan
Inputs x1x2
Next State, w1w2
Output z
00 01 11 10 00 01 11 10
01 00 00 00 0 0 0 0
11 00 00 00 0 0 0 0
11 00 10 00 0 0 0 0
01 00 00 00 0 0 0 1
Page: 8
State Assignment
Any state assignment is satisfactory as long
as each state is assigned a unique binary
code.
However, one particular assignment may be
optimal that requires least number of gates.
Overall
Minimize the number of Sate Variable changes as
you move through the state diagram.
G.Khan
Page: 9
01
11
x1x2
00
y1y2
10
00
01
11
10
00
01
11
10
w1 = x1 x 2 y 2 + x1x 2 y1y 2
x1x2
00
y1y2
01
01
11
10
w 2 = x1 x 2
11
10
00
01
11
10
BY INSPECTION OUTPUT z = x1 x2 y1 y2
G.Khan
Page: 10
x1
W2 Q
y2
W1 Q
y1
x2
Q
Clock
Timing Diagram
CLK
Present
State
Input x1
Input x2
Output z
G.Khan
Page: 11
State Diagram
10
01
11
01,10,11
1/0
01
11
01
10
11
10
01
5/1
00
2/0
00
00
00
3/0
11
00
10
4/0
G.Khan
Page: 12
1
2
3
4
5
Output
z
Next State
xy
00 01 11
2 1 1
3 1 1
3 1 4
2 1 1
2 1 1
10
1
1
1
5
1
0
0
0
0
1
State Assignment
Present State Next state (A+B+C+) Output
ABC
XY
z
00 01 11 10
000
001 000 000 000
0
001
011 000 000 000
0
011
011 000 010 000
0
010
001 000 000 110
0
110
001 000 000 000
1
Using D-type FFs
G.Khan
Page: 13
A=0
A=1
X
XY
00
BC
01
11
X
10
00
00
01
x
1
11
B
01
10
11
10
B = Cx y + BCxy + ABC xy
+
A=0
XY
00
BC
A=1
X
01
11
X
10
00
01
11
10
00
01
11
10
1
Y
x
C
C + = xy
G.Khan
Page: 14
DA QA
QA
DB QB
QB
X
Y
DC QC
QC
clock
Timing Diagram
CLK
Present
State
ABC
1(000)
1(000)
2(001)
3(011)
4(010)
5(110)
1(000)
Input x
Input y
Output z
G.Khan
Page: 15
G.Khan
Page: 16
ASM Charts
A Typical ASM Chart
S0/Za
S1/Zb
S2/Zc
Z1
G.Khan
Z2
Page: 17
ASM Charts
The state diagram/table based design approach
becomes impractical for systems with large
number of inputs.
G.Khan
Page: 18
ASM Charts
Basic Elements of an ASM chart are:
State Box
Exit Path
G.Khan
Page: 19
ASM Charts
Decision Box
G.Khan
Page: 20
ASM Charts
ASM charts are equivalent to state diagrams:
Sate Box State diagram node
Decision Box Input values on the state
transition lines.
Outputs in the State Box Output values in the
state nodes. (Moore Machine)
Outputs in Conditional Output Box Output
values on the state transition lines. (Mealy
Machine)
ASM Block
ASM charts are constructed from ASM Blocks
An ASM block consists of:
Exactly one state box.
Decision and conditional output boxes
associated with the state.
One entry path and one or more exit paths.
A pure combinational circuit can be described by
one ASM block.
An ASM block describes the machine operation
during the time that the machine is in that state.
G.Khan
Page: 21
ASM Block
When a digital system enters the state associated
with an ASM block:
Outputs on the output list of the state box become true.
The conditions in the decision boxes are evaluated to
determine which path(s) are to be followed.
When a conditional output box is encountered along
such a path, the corresponding conditional outputs
become true.
If an output is not encountered along a path that output
is assigned a FALSE (by default).
Each exit path of an ASM block must lead to another
state.
Each possible path through an ASM block from
entrance to exit is termed as link path.
Entry path
S1
x1
x2
Z2
Z1
S2
G.Khan
many
exit
paths
S3
S4
Page: 22
ASM Block
An ASM Block can be drawn in several ways.
S1/Z1
X1
Z2
X2
S2
S3
S1/Z1
X2
1
1
X1
0
Z2
S2
G.Khan
X1
0
Z2
S3
Page: 23
ASM Block
Rules to Construct an ASM Block
For every valid combination of input variables, there
must be one exit path.
No internal feedback within an ASM block is allowed.
S0/
S0/
X1
X1
X1
0
Z1
G.Khan
X2
X3
0
Z2
Z3
Page: 24
ASM Chart
An ASM chart consists of one or more ASM
blocks connected in a consistent manner.
In the case of autonomous sequential circuits
ASM chart will consist of state boxes connected
by direct transition link paths.
zero
1
1
out 1
one
0
G.Khan
Page: 25
ASM Chart
From State Diagram to ASM Chart
X is an input
Za, Zb & Zc are Moore Outputs
Z1 & Z2 are Mealy Outputs
0/0
S0/Za
0/0
00
1/0
1/0
S1/Zb
S2/Zc
1/Z2
G.Khan
0/Z1
Page: 26
G.Khan
Page: 27
S0/Za
0
01
S1/Zb
11
S2/Zc
Z1
G.Khan
Z2
Page: 28
Moore Outputs
Za = A'B';
Zb = A'B;
Zc = AB
Conditional Output
G.Khan
Page: 29
Binary Multipliers
Hand Multiplication:
11
* 13
143
1101
1011
1101
1101
0000
1101
10001111
Multiplicand
Multiplier
Final Result = 0 1 0 0 0 1 1 1 1
G.Khan
Page: 30
Multiplier
Block Diagram
IN
n-1
Counter-P
log2n
G(Go)
Multiplicand
Register-B
n
Zero Detect
Cout
Control
Unit Q0
Parallel
Adder
n
Shift
Register-A
Multiplier
Shift
Register-Q
n
G.Khan
Page: 31
Binary Multipliers
The multiplication of two binary numbers is performed
by successive additions and shifting.
B Multiplicand; Q Multiplier
Partial product is formed in A and stored in A & Q.
Multiplier Circuit Operation
Q is an n-bit shift register where multiplier is loaded
that is shifted right. It vacates 1-bit space every time.
This space accepts the lower part of the partial
product.
An n-bit parallel adder produces Sums as
AA+B
C flip-flop stores the carry from addition. It is reset to
zero during the right shift.
Counter P counts the number of add-shift or shift
actions. It is initially set at (n-1) & it counts down.
When P counts 0, the final product is in the double
register A and Q.
Control Unit is the heart of Multiplier:
Its input, G initiate multiplication.
Control unit generate control signals to perform addshift or shift operations.
It uses Q0 (LSB of Q shift register) and counter zerodetect, Z signals.
G.Khan
Page: 32
C 0; A 0
P n-1
MUL0
Q0
AA+B
C Cout
MUL1
C 0, C || A || Q sr C || A || Q
P P-1
1 Multiplication Done
Page: 33
Sum of A and B.
PP transferred to A.
Cout transferred to C.
PP & multiplier in A:Q shifted right.
Carry from C is shifted to MSB of A:
LSB of Q is discarded.
After right shift, 1-bit of PP is transferred
into Q and multiplier bits are shifted one
bit right.
Page: 34
Multiplier Control
ASM Chart Analysis
Multiplicand in register B
Multiplier in Q
State Changes from IDLE to MUL0
MUL0 State
MUL1 State
Decrement Counter P
Four transfers take place
A(n-1) C;
A sr A;
Q(n-1) A(0);
Q sr Q;
G.Khan
Page: 35
G.Khan
Page: 36
Hardwired Control
Type of Registers Used for Datapath
Register A is a shift register with parallel
load and synchronous clear.
Register Q is a shift register.
C flip-flop needs a synchronous clear.
Register B has a parallel load.
Register Q has a parallel load.
G.Khan
Page: 37
Control
Expression
Load
CAQsr CAQ
Shift
Register B B IN
Load_B
C0
Clear_C
FF C
C Cout
Load
Register Q Q IN
Load_Q
CAQsr CAQ Shift
Counter P P n 1
Initialize
PP1
Decrement
Count
Page: 38
IDLE
MUL0
MUL1
G.Khan
Page: 39
Decision
Logic
Sequence
Register
Decoder
Present
State
Tn
Page: 40
Sequence Register
and Decoder Method
Binary Multiplier Control Sequencer
3-states and 2-inputs:
State Table
Present State Inputs N. State
Name
M1
IDLE 0
0
MUL0 0
MUL1 1
1
1
M0
0
0
1
0
0
1
G
0
1
x
x
x
x
Decoder
MUL0 MUL1
0
0
1
0
0
x
0
0
0
1
1
x
2 Flip-flops : M1 M0
States 00, 01 and 10: IDLE, MUL0 and MUL1
DM0 = M0+
DM1 = M1+
Outputs: Initialize, Clear_C, Shift and Load
Initialize and Shift already available
Page: 41
Sequence Register
and Decoder Method
Implementation
Outputs to
Datapath
Inputs
Initialize
Go (G)
Clear_C
Z
Load
Q0
A0
2-to-4
Decoder
1
2
A1
Shift_dec
Clock
G.Khan
Page: 42
Page: 43
process
begin
-- executes on rising edge of clock
wait until Clk = '1';
case State is
when 0 =>
--initial State
if St='1' then
ACC(8 downto 4)<= "00000"; --Begin cycle
-- Load multiplier
ACC(3 downto 0) <= Mplier;
State <= 1;
end if;
when 1 | 3 | 5 | 7 => --"add/shift" State
if Q0 = '1' then
--Add multiplicand
ACC(8 downto 4) <=
add4(ACC(7 downto 4),Mcand,'0');
State <= State + 1;
else
-- Shift accumulator right
ACC <= '0' & ACC(8 downto 1);
State <= State + 2;
end if;
when 2 | 4 | 6 | 8 =>
--"shift" State
-- Right shift
ACC <= '0' & ACC(8 downto 1);
State <= State + 1;
when 9 =>
-- End of cycle
State <= 0;
end case;
end process;
Done <= '1' when State = 9 else '0';
end behave1;
G.Khan
Page: 44
External
input
conditions
S0
Decision
Logic
S1
S2
S3
Clock
G.Khan
Page: 45
G.Khan
Page: 46
Entry
State Code
(optional)
State_Name/
outputs (Moore)
Entry X
Entry
Exit 1
Exit
State Box
Exit
0
Exit 0
Exit 0
Exit 1
Decision Box
G.Khan
Page: 47
Entry
X
Exit 1
Exit 1
Output
Entry 1
Entry 2
Entry 1
Entry 2
Exit
Exit
Junction
G.Khan
Page: 48
IDLE
Initialize
Clear_C
MUL0
Q0
AA+B
C Cout
MUL1
C 0, C || A || Q sr C || A || Q ; P P 1
(Complex Shift)
0
G.Khan
(LOAD)
1 Multiplication Done
Page: 49
D
C
Initialize
Clear_C
Load
Q0
Z
Shift_dec
C
Clock
G.Khan
Page: 50