Professional Documents
Culture Documents
Synchronous Sequential Circuits
Synchronous Sequential Circuits
Circuits
Synchronous Sequential Circuits
W Combinational Combinational
Flip-flops
p p circuit Z
circuit
i i Q
Cl k
Clock
Clockcycle: t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
w: 0 1 0 1 1 0 1 1 1 0 1
C z = 1
z: 0 0 0 0 0 1 0 0 1 1 0
w = 1
Synchronous Sequential Circuits
State Table
• Rather than having the circuit description in the graphical
form of a state diagram, we can translate the diagram into a
tabular form known as a state table.
• A state table contains all the information of the state
diagram: transitions, input signal, and output signals; but
places
l them
th in i a form
f from
f which
hi h it is
i easier
i tot simplify
i lif
and implement a circuit.
w=1
w=0 A z = 0 B z = 0
w=0
Present Next state Output w=0 w=1
state w = 0 w = 1 z
A A B 0 C z = 1
B A C 0
C A C 1
w=1
Synchronous Sequential Circuits
State Assignment
• When implementing a sequential circuit, each state is
represented by a particular valuation (combination of values) of
state variables.
• With each state variable implemented in the form of a flip-flop.
w= 1
• We have three states, and can w= 0 Az=0 Bz=0
w= 0
represent this using two state variables. w= 0 w= 1
• Since the output z is a function of only the
Cz=1
current state, our design is a Moore type.
• Once we have determined how many flip-flops
flip flops we w= 1
need to implement our circuit, we need to be able to map the
information contained in the state table to the information
which will be stored in the flip-flops
Synchronous Sequential Circuits
w= 1
• We have two state variables, and therefore two flip-flops.
• For an assigned state table, we can label their present states as
y1 and y2, and the next-state variables as Y1 and Y2.
As can be seen
seen, the below assigned state table is
basically a variation on a truth table and can be used
to generate the necessary combinational logic using
techniques such as Karnaugh maps, etc.
Next state w= 1
Present w= 0 Az=0 Bz=0
w = 0 w = 1 Output
state w= 0
z w= 0 w= 1
y y Y Y Y Y
2 1 2 1 2 1
Cz=1
A 00 00 01 0
B 01 00 10 0
w= 1
C 10 00 10 1
11 dd dd d
Y1 y1
w
Combinational Combinational z
circuit circuit
Y2 y2
Clock
Y2 y2
D2
Clock
y y
2 1 Next state
w 00 01 11 10 Ignoring don't cares
Present
w = 0 w = 1 Output
0 0 0 d 0 Y = wy y
state
1 1 2 z
1 1 0 d 0
Using don't cares y 2y 1 Y 2 Y1 Y 2 Y1
Y = wy y
1 1 2
A 00 00 01 0
B 01 00 10 0
y y
2 1 C 10 00 10 1
w
00 01 11 10 Ignoring don't cares 11 dd dd d
0 0 0 d 0 Y = wy y + wy y
2 1 2 1 2
Y1 y1
w D Q
Clock
Resetn
1
w
0
1
y1
0
1
y2
0
1
z
0
A 00 00 01 0 A 00 00 01 0
B 01 00 10 0 B 01 00 11 0
C 10 00 10 1 C 11 00 11 1
11 dd dd d 10 dd dd d
y y y y y
2 1 2 1 1
y
w 00 01 11 10 w 00 01 11 10 2 0 1
0 0 0 0 0 d 0 0 0
0 0 0 d
1 1 1 1 d 1 0 1 1 d 1 d 1
Y2 y2
D Q z
Y2 y2
D Q z
Q
Q
Y1 y1
Y1 y1 w D Q
w D Q
Q Clock Q
Resetn
Clock
Resetn
Final circuit for the original (left) and improved (right) state
g
assignments
Synchronous Sequential Circuits
Bus Structure
• Digital systems such as microprocessor contain a set of
registers.
• Each register Ri (i=1,2,..k) is connected to a set of n wires.
Synchronous Sequential Circuits
• It is essential to ensure that only one circuit block attempts
to place data onto the bus
• A control circuit will ensure that the bus is used by only
one register as well as the transfer of the data signals.
R1out
R1in
w
R2out
Control
circuit R2in
Tri-state Clock
R3out
R3in
buffers Done
Synchronous Sequential Circuits
• In the starting state A, no transfer is indicated, and all
output signals are 0.
w= 0
• The circuit remains in this state until a request to swap
arrives in the form of w =1. Reset
A No transfer
• In state B the signals required to transfer the contents of
R2 into R3 are asserted. w= 1
• Th nextt active
The ti clock
l k edge
d places
l the
th contents
t t into
i t R3
B R2out= 1R3in = 1
• It also causes the circuit to change to state C , regardless
of the value of w w= 0
w= 1
• In this state the signals
g for transferringg R1 into R2 are w= 0
w= 1 C R1out= 1R
R1 R2
2in = 1
asserted.
w= 0
• The transfer takes place at the next active clock edge the w= 1
ckt changes to state D regardless of the value w
D R3out= 1R1in = 1Done = 1
• The final transfer from R3 to R1 is performed on the
clock edge that leaves state D which causes the ckt to go
to state A
Present Next
N t state
t t O t t
Outputs
state w = 0 w = 1
A A B 0 0 0 0 0 0 0
B C C 0 0 1 0 0 1 0
C D D 1 0 0 1 0 0 0
D A A 0 1 0 0 1 0 1
State-assigned table
A 00 00 01 0 0 0 0 0 0 0
B 01 10 10 0 0 1 0 0 1 0
C 10 11 11 1 0 0 1 0 0 0
D 11 00 00 0 1 0 0 1 0 1
y2 y1
w
00 01 11 10
0 1
Y 1 = wy 1 + y 1 y 2
1 1 1
y2 y1
w
00 01 11 10
0 1 1
Y 2 = y1 y2 + y1 y2
1 1 1
w R 1 in
Y1 y1
D Q
R 3 out
y1
Clock Q Done
R 1 out
R 2 in
Y2 y2
D Q
y2
Q
R 2 out
R 3 in
A 00 00 01 0 0 0 0 0 0 0
B 01 10 10 0 0 1 0 0 1 0
C 10 11 11 1 0 0 1 0 0 0
D 11 00 00 0 1 0 0 1 0 1
Present Nextstate
state Outputs
A 00 00 01 0 0 0 0 0 0 0
B 01 11 11 0 0 1 0 0 1 0
C 11 10 10 1 0 0 1 0 0 0
D 10 00 00 0 1 0 0 1 0 1
Present
Present
Nextstate
Next state
state Outputs
Outputs
state
AA 00
00 000
0 01
01 00 00 0 00 00 00 00
BB 01
01 110
1 10
11 00 00 11 00 00 11 00
CC 10
11 111
0 11
10 11 00 00 11 00 00 00
DD 11
10 000
0 00
00 00 11 00 00 11 00 11
y2y1 y2y1
w
w 00 01 11 10 00 01 11 10
0 1 0 1 1
1 1 1 1 1 1
Y1 = wy2 + y1y2 Y2 = y1
Synchronous Sequential Circuits
One-Hot Encoding
• Another approach to the state assignment questions is to use as many
state variables as there are states in a sequential circuit.
• In this method, for each state all but one of the state variables are equal
to 0, and is referred to as one-hot encoding.
• The following table shows how one-hot state can be applied to the
example sequential circuit.
w= 1
w= 0 Az=0 Bz=0 Present NextNextstate
Present
state
w= 0 state = 1 Output
state w =w0= w0 = 1 w Output
w= 0 w= 1 z z
y 32 12 y 1 2Y31Y2 Y12 1 Y3 Y2 Y1
y y Y Y Y Y
A 00 00 01 0
Cz=1 A
B
001
01 00
001 10
010 0
0
B
C 010
10 00001 10 1001 0
w= 1 C 100
11 dd001 dd 100d 1
A No transfer
Present Next state
w= 1 state Outputs
B R2out= 1R3in = 1
w= 0
w= 1 A 00 00 01 0 0 0 0
w= 0 B 01 10 10 0 0 1 0
w= 1 C R1out= 1R2in = 1
C 10 11 11 1 0 0 1
w= 0
w= 1
D 11 00 00 0 1 0 0
D R3out= 1R1in = 1Done = 1
Present Nextstate
state Outputs
Y1 wy1 y4
Y2 wy1 R1out R 2in y3
Y3 y2 R1in R3out Done y4
Y4 y3 R 2out R3in y2
Example:
Design a circuit which monitors an input for two consecutive 1s
with the output z equal to 1 in the same clock cycle when the
second occurrence of w=1 is detected.
w = 0 z = 0 A B w = 1 z = 1
w = 0 z = 0
w D Q
y
Clock Q
Resetn
Circuit
t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t 10
1
Clock
0
1
w
0
1
y
0
1
z
0
Timing diagram
z
D Q Z
w D Q Q
y
Cl k
Clock
Resetn
Mealy
l → Moore
(a) Circuit
t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t 10
1
Clock
0
1
w
0
1
y
0
1
z
0
1
Z
0
Mealy
State
Mealy
Out
More
State
Moore
State
Moore
Out
w= 0 w = 0
w= 1
w = 1 R2out = 1 R3in = 1
B R2out= 1R3in = 1
w= 0 B
w= 1
w= 0
w= 1 C R1out= 1R2in = 1 w = 0 R1 = 1 R2 = 1
w = 1 out in
w= 0
w= 1
w = 0 R3 = 1 R1 = 1 Done = 1
w = 1 out in
• With the output value depending on both the state and the
present value of the inputs
• For a Moore-type FSM, the output must depend only on the
state off the
h machine hi andd will
ill therefore
h f require
i additional
ddi i l states.
• A key difference between the two types of FSMs is that in the
Mealy a change in the inputs reflects itself immediately in the
outputs,
• while in the Moore the outputs do not change until the change
i inputs
in i forces
f the
h machine
hi into
i a new state, which
hi h takes
k place
l
one clock cycle later. a1 b1 a0 b0
• Solution:
• Let A = an-1,an-2, … a0 c1
c2 FA FA
• Let B = bnn-11,bnn-22, … b0
s1 s0
Synchronous Sequential Circuits
• With the output value depending on both the state and the
present value of the inputs
• The process starts by adding a0 and b0
• In the next clock cycle, a1 and b1 bits are added including a
possible carry
A
a
Shift register
Parallel load s
Adder
dd
FSM Shift register
Shift register
Parallel load
b
S
Sum = A+ B
B
Clock
• With the output value depending on both the state and the
present value of the inputs
• The addition starts by loading the values of A and B
• Then in each clock cycle, a pair of bits is added by the Adder
FSM and at the end of the cycle the resulting sum is shifted to
the Sum register A
a
Shift register
Parallel load s
Adder
dd
FSM Shift register
Shift register
Parallel load
b
S
Sum = A+ B
B
Clock
Presentt
P Next state Output s
state ab =00 01 10 11 00 01 10 11
G G G G H 0 1 1 0
H G H H H 1 0 0 1
State-assigned table.
Next state Output
Present
state ab =00 01 10 11 00 01 10 11
y Y s
0 0 0 0 1 0 1 1 0
1 0 1 1 1 1 0 0 1
a s
Full
b
adder Y y
D Q
carry-outt
Clock Q
Reset
Synchronous Sequential Circuits
Moore-type FSM serial adder
Instead of G,, we will use G0 and G1 to denote the fact that the carry
y is 0 and
that the sum is either 0 or 1
We will use H0 and H1 the same way
Reset
11 01
00 G0 s = 0 H0 s = 0
10
00
01 00 11 01
10 11 10
01 G1 s = 1 H1 s = 1 11
10 00
State table for the Moore-type serial adder FSM.
State-assigned table.
Nextstate
Present
state ab =00 01 10 11 Output
y2 y1 s
Y2 Y1
00 00 01 01 10 0
01 00 01 01 10 1
10 01 10 10 11 0
11 01 10 10 11 1
Y1 a b y2
Y2 ab ay2 by2
s y1
Sum bit Y1 y1
a D Q s
Full
b
adder Carry-out
Q
Y2 y2
D Q
Clock Q
Reset
• Ideally, to minimize the complexity of the FSM, a machine should use the
minimum number of states.states
• Therefore it becomes important to be able to identify redundant or duplicate
states.
• T define
To d fi what h constitutes
i a duplicate
d li state, if we have
h two states, Si and
d Sj
they are considered to be equivalent if and only if for every possible input
sequence, the same output sequence will be produced regardless of whether
Si orSj is the initial state,
state i.e.
ie
• The two state produce the same k successors.
• If an input signal w=0 is applied to a machine in state Si and the result is
th t the
that th machine
hi moves to t state
t t Su we will
ill say that
th t Su is
i a 0-successor
0 off Si .
• Similarly, if w=1 is applied in the state Si and it causes the machine to move
to state Sv we will say that Sv is a 1-successor of Si.
• In general, we will refer to the successors of Si as its k-successors.
• Using the concept of equivalency and k-successors, we are able to define a
method to minimize the number of states known as the partitioning
• minimization method.
Synchronous Sequential Circuits
A B C 1
B D F 1
C F E 0
D B G 1
E F C 0
F E D 0
G F G 0
• P3=(ABD)(CEG) (F)
• For (ABD) the 0- successors are (BDB) which are in the same block in P3
• The 1-
1 successors are (CFG) , which are not in the same block
• Since F is in a different block than C and G, it follows that the state B cannot be
equivalent to states A and D
• The 0- and 1- successors of (CEG) are (FFF) and (ECG)
• Both of these are accomodated in the blocks of P3
• Hence P4=(AD)(B)(CEG) (F)
A B C 1 A B C 1
B D F 1 B A F 1
C F E 0 C F C 0
D B G 1 F C A 0
E F C 0
F E D 0 A→ A and D
G F G 0
C→ C, E and G
P4=(AD)(B)(CEG) (F)
Synchronous Sequential Circuits
Example vending machine
• Suppose that a coin
coin-operated
operated vending machine dispenses candy
under the following conditions:
– The machine accepts nickels and dimes.
– It takes 15 cents for a piece of candy to be released from the
machine.
– If 20 cents is deposited
deposited, the machine will not return the
change, but will credit the buyer with 5 cents and wait for
the buyer to make a second purchase
• Assume a 100 ns clock period and positive edge trigger flip-
flops.
• The coin receptor generates two signals senseD and senseN
which are asserted when a dime or a nickel is detected.
• The coin receptor also generates signal D and is set to 1 for one
clock cycle after senseD becomes 1
• Same for signal N and senseN
Clock
sense N
senseD
Timing diagram
N
senseN D Q D Q
Clock Q Q
Reset
DN
DN S1 0 DN
DN DN
D N
S3 0 D
S4 1 S2 0 S7 1
N
D N
DN
S5 1 S6 0 DN DN
N D
S8 1 S9 1
State diagram.
State table
S1 S1 S3 S2 – 0
S2 S2 S4 S5 – 0
S3 S3 S2 S4 – 0
S4 S1 – – – 1
S5 S3 – – – 1
Minimized state table
Present Next state Output DN
state DN =00
00 01 10 11 z
S1 S1 S3 S2 – 0 S1 0
S2 S2 S4 S5 – 0
S3 S3 S2 S4 – 0 N
S4 S1 – – – 1 DN
S5 S3 – – – 1
S3 0
D
DN N DN
D
Minimized state diagram. DN S2 0 S5 1
N
D
S4 1
DN 0 DN
S1 0
S1
N
N 0 D 1 DN
DN 0 S3 0
D
N 1 S3 D 0
DN N DN
N 0 D 1 D
DN S2 0 S5 1
S2 N
D
S4 1
DN 0
Mealy-type FSM
Synchronous Sequential Circuits
Incompletely Specified FSMs
• If all the k-successors for each state are defined,, a state table is said to be
completely specified.
• However, it is possible that some successors may not be specified or
represent
p input
p conditions which will never occur.
• These unspecified successors correspond to don't care conditions, and the
state table containing them is said to be incompletely specified.
• The partitioning minimization procedure which was applied to completely
specified state tables can also be applied to incompletely specified state
tables.
• To perform the partitioning process, we can assume that the unspecified
outputs have a specific value.
• The partitioning method is equally applicable to Mealy type FSMs in the
same way as for Moore
Moore-type
type FSMs.
Example of incompletely specified FSM.
w= 1 w= 1 w= 1
A/0 B/1 C/2 D/3
w= 1 w= 1
w= 0 w= 0 w= 0 w= 0
w=1 w=1
St t
State-assigned
i d table
t bl for
f the
th counter.
t
y1y0
wy2
Next state 00 01 11 10
Present
Count
state w= 0 w= 1 00 0 0
y2 y1 y0 z2z1z0 01 0 0
Y0 Y0
11 1 0 0 1
A 000 0 1 000
B 001 1 0 001 10 1 0 0 1
St t
State-assigned
i d table
t bl for
f the
th counter.
t
y1y0
wy2
00 01 11 10
00 0 0 1 1
Next state 01 0 0 1 1
Present
Count 11 0 1 0 1
state
t t w= 0 w= 1
y2 y1 y0 z2z1z0 10 0 1 0 1
Y2 Y1 Y0 Y2 Y 1 Y0
Y1 = wy1 + y1y0 + wy0y1
A 000 000 001 000
y1y0
B 001 001 010 001 wy2
C 010 010 011 010 00 01 11 10
St t
State-assigned
i d table
t bl for
f the
th counter.
t
w Y0
D Q y0
Y1
D Q y1
Y2
D Q y2
Clock
Resetn
Synchronous Sequential Circuits
Flip-flop
p p inputs
p
Present
Count
state w= 0 w= 1
y2 y1 y0 z2z1z0
Y2 Y1 Y0 J2K 2 J1K 1 J0K 0 Y2 Y1 Y0 J2K 2 J1K 1 J0K 0
A 000 000 0d 0d 0d 001 0d 0d 1d 000
B 001 001 0d 0d d0 010 0d 1d d1 001
C 010 010 0d d0 0d 011 0d d0 1d 010
D 011 011 0d d0 d0 100 1d d1 d1 0011
E 100 100 d0 0d 0d 101 d0 0d 1d 100
F 101 101 d0 0d d0 110 d0 1d d1 101
G 110 110 d0 d0 0d 111 d0 d0 1d 110
H 111 111 d0 d0 d0 000 d1 d1 d1 111
01 0 d d 0 01 d 0 0 d
11 1 d d 1 11 d 1 1 d
10 1 d d 1 10 d 1 1 d
J0 = w K0 = w
Flip-flop
p p inputs
p
Present
Count
state w= 0 w= 1
y2 y1 y0 z2z1z0
Y2 Y1 Y0 J2K 2 J1K 1 J0K 0 Y2 Y1 Y0 J2K 2 J1K 1 J0K 0
A 000 000 0d 0d 0d 001 0d 0d 1d 000
B 001 001 0d 0d d0 010 0d 1d d1 001
C 010 010 0d d0 0d 011 0d d0 1d 010
D 011 011 0d d0 d0 100 1d d1 d1 0011
E 100 100 d0 0d 0d 101 d0 0d 1d 100
F 101 101 d0 0d d0 110 d0 1d d1 101
G 110 110 d0 d0 0d 111 d0 d0 1d 110
H 111 111 d0 d0 d0 000 d1 d1 d1 111
01 0 0 d d 01 d d 0 0
11 0 1 d d 11 d d 1 0
10 0 1 d d 10 d d 1 0
J1 = wy0 K 1 = wy0
y1 y0 y1 y0
wy2 wy2
00 01 11 10 00 01 11 10
00 0 0 0 0 00 d d d d
01 d d d d 01 0 0 0 0
11 d d d d 11 0 0 1 0
10 0 0 1 0 10 d d d d
J2 = wy0 y1 K 2 = wy0 y1
w J Q y0
K Q
J Q y1
K Q
J Q y2
K Q
Clock
Resetn
A B 000 D2 Y2 y2 000 1 00 0 00
B C 100 D1 Y1 y1 y2 100 0 10 1 00
C D 010 D0 Y0 y0 y1 y2 010 1 10 0 10
D E 110 110 0 01 1 10
E F 001 001 1 01 0 01
F G 101
0 101 0 11 1 01
G H 011 011 1 11 0 11
H A 111 111 0 00 1 11
D Q z2
D Q z1
D Q z0
w Q
Synchronous Sequential Circuits
FSM As An Arbiter Circuit
• The purpose of the arbiter FSM is to control access to a shared resource
where only one device can use the resource at a time.
• Arbiter FSMs are practical circuits which are useful in many types of
systems.
• An example is a computer system in which various devices are connected to
a bus.
• Example
• Design a 3 input priority arbiter circuit, where 3 devices (device 1, device 2,
device 3) provide requests (r1, r2, and r3) to the machine, and the FSM
produces separate output grants (g1, g2, and g3).
• A device indicates its need to use the resource by asserting its request
signal.
• The devices are assigned
g a priority:
p y device 1> device 2 > device 3
• Thus if more than one request signal is asserted, the grant is given to the
highest priority device.
• All signals can change values only on the positive edge of the clock.
clock
r 1r 2 r 3
Reset 000 Reset
Idle Idle
0xx 1xx r1 r1
xx1 r3
Delay
Q
w
Y2 y2
D Q
Clock Q
Resetn
Next State
Present
Output
state w= 0 w= 1
Y1 = y2 y1 z
Y2 Y1 Y2 Y1
Y2 = 00 00 01 0
01 00 10 0
z= 10 00 11 0
11 00 11 1
Next State
Present
Output
p
state w= 0 w= 1 Present Next state Output
y2 y1 z state z
Y2 Y1 Y2 Y1 w= 0 w= 1
00 00 01 0 A A B 0
01 00 10 0 B A C 0
10 00 11 0 C A D 0
11 00 11 1 D A D 1
K Q
K
1
J y
2 2
J Q
Clock
K Q
K
2
Resetn
Algorithmic
Al ith i StState
t MMachine
hi (ASM) Ch Chartst
• For large FSMs, rather than using the state diagram, designers often use a
different representation called an Algorithmic State Machine (ASM) chart.
• The ASM chart is a type of flow chart and is used since it provides more
information than is normally indicated on a state diagram
• Three types of elements are used in an ASM chart:
• i) state boxes; ii) decision boxes; and iii) conditional output boxes.
• State box: equivalent to a node in the state diagram or a row in the state table.
• The name of the state is indicated outside the box in the top p left corner.
• The Moore outputs are listed inside the box.
• It is customary to write only the name of the signal that has to be asserted, i.e.
it is sufficient to write z rather than z = 1.
1
• Also, it may be useful to indicate an action that has to be taken, e.g. Count
Count+1.
Synchronous Sequential Circuits
Algorithmic
g State Machine (ASM)
( ) Charts ((continue))
State name
Output signals
or actions State box
(Moore type)
Algorithmic
g State Machine (ASM)
( ) Charts ((continue))
• For the analysis of an FSM we reverse the steps of the synthesis process.
• Knowing that the outputs of the flip-flops represent the present-state
variables, and their inputs determine the next state that the circuit will enter,
we can construct the state-assigned table for the circuit.
• Once the assigned state table is determined, the state table and the
corresponding state diagram can be generated by giving a name to each
state.
• Decision Box: This indicates that the stated condition expression is to be
tested and the exit path is to be chosen accordingly.
Algorithmic
g State Machine (ASM)
( ) Charts ((continue))
• Conditional Output Box: denotes the output signals that are of Mealy type.
• The condition that determines whether such outputs are generated is
specified in a decision box.
• NOTE: ASM charts are similar to traditional flowcharts, but includes timing
information because it implicitly specifies that the FSM changes from one
state to another only after each active clock edge.
Reset
Reset
w = 1 z = 0 0
w
A B 1
w = 0 z = 0 w = 1 z = 1
w = 0 z = 0
B z
1
w
Summary:
• Throughg the use of a state diagram,
g state table, and assigned
g
state table, a formal method for designing FSMs was
introduced.
• Mealy
Meal FSMs can be designed using sing the same methods as a
Moore FSM with the understanding that the output timing will
differ.
• By using a portioning procedure, the number of states in an
FSM can be optimized.