Page 1 of 14
7 Sequential Circuits
We have so far been looking at combinational circuits in which their output values are computed entirely from
their current input values. We will now study the behavior of sequential circuits where their output values are
computed using both the current and past input values. The dependence of past input values implies the need for
memory elements to remember this history of inputs. The values stored in the memory elements define the state of
the sequential circuit. Since memory is finite, therefore, the sequence size must also be finite, which means that the
sequential logic can contain only a finite number of states. Because of this, sequential circuits are also referred to as
finite-state machines (FSM).
Finite-state machines are a very important part in the designing of microprocessors as we will find out in
Chapter 9. Finite-state machines can be classified into two main types: Moore and Mealy (or a mixture of the two).
A Moore type FSM is one where the output of the machine is independent on the input, whereas a Mealy type FSM
is one where the output is dependent on the input.
Sequential circuits can also either be asynchronous or synchronous. Asynchronous sequential circuits change
their state and output values whenever a change in input values occurs. Synchronous sequential circuits, on the other
hand, change their states and output values only at fixed points in time, which usually are at the active clock edge.
7.1
Sequential logic circuits or finite-state machines have a finite number of states. The state memory, consisted of
flip-flops, remembers the current state that the machine is in. In other words, the current state of the machine is
determined by the current contents of the flip-flops. The operation of the finite-state machine is determined by how
it transitions from one state to the next. The circuitry that is responsible for the transitioning of the states is known as
the next-state logic circuit or function. The next-state logic function excites or causes the state memory flip-flops to
change states. In addition to the next-state logic function, there is an output logic function that generates output
signals that are dependent on either the current state only or on both the current state and the input signals. Figure
1(a) shows the general schematic for the finite-state machine where its output is dependent only on its current state.
These types of finite-state machines are known as Moore type machines. Figure 1(b) shows the general schematic
for a Mealy type finite-state machine where its outputs are dependent on both the current state of the machine and
also the inputs.
input signals
Next-state
Logic
Function
F
excitation
Clock
State
Memory current state
Flip-Flops
Output
Logic
Function
G
output signals
(a)
input signals
Next-state
Logic
Function
F
excitation
Clock
State
Memory current state
Flip-Flops
Enoch Hwang
Output
Logic
Function
G
output signals
Page 2 of 14
(b)
Figure 1. Finite-state machines: (a) Moore machine; (b) Mealy machine.
7.2
Analysis of sequential circuits is the process in which we are given a sequential circuit and we want to obtain a
precise description of the operation of the circuit. The description can be in the form of a next-state and output table,
and/or a state diagram. The steps for the analysis of sequential circuits is as follows:
1.
2.
3.
4.
5.
6.
Input
S1
Q1
Clk
Output
R1
Q'1
S0
Q0
Clk
R0
Q'0
Clk
Next-state logic
State memory
Output logic
Enoch Hwang
Page 3 of 14
S1 = CQ1'Q0
R1 = CQ1Q0
S0 = CQ0'
R0 = CQ0
Current State
Q1Q0
00
01
10
11
Next State
Q1next Q0next
C=0
C=1
00
01
01
10
10
11
11
00
For example, to find the Q0next value for the current state Q1Q0 = 00 and C = 1, we substitute the values Q1 = 0,
Q0 = 0 and C = 1 into the equation Q0next = CQ0' + (CQ0)'Q0 = (11) + (10)' 0 to get the value 1. Similarly, we get
Q1next = 0 by substituting the same values for Q1, Q0, and C into the equation Q1next = CQ1'Q0 + (CQ1Q0)'Q1.
Enoch Hwang
Page 4 of 14
After constructing the next-state table, we can add in the output values as obtained from the output equations.
The output table for a Moore machine is slightly deferent from a Mealy machine. For a Moore machine, we can
simply add an extra column in the next-state table for each output signal. For a Mealy machine, the output values
have to be included with the next-state values. The next-state / output table for the sample circuit is as follows:
Current State
Q1Q0
00
01
10
11
Next State
Q1next Q0next
C=0
C=1
00
01
01
10
10
11
11
00
Output
Y
0
0
0
1
Q 1 Q 0 = 00
Y =0
C =0
Q 1 Q 0 = 01
Y =0
C =1
C =1
C =1
Q 1 Q 0 = 11
Y =1
C =0
C =0
C =1
Q 1 Q 0 = 10
Y =0
C =0
t1
t2
t3
From the state diagram and the timing diagram, we can conclude that the circuit of Figure 2 is for a modulo-4
Enoch Hwang
Page 5 of 14
Input
J1
Q1
Clk
Clk
Output
K1
Q'1
T0
Q0
Clk
Q'0
Next-state logic
State memory
Output logic
Notice the difference between this next-state / output table with the one from the previous example for the
Moore FSM. Here, the output values are dependent on both the current state and the input values, therefore, they are
included together with the next-state values rather than as a separate column. Other than that, all the next-state
values are identical.
Enoch Hwang
Page 6 of 14
Since the output value is dependent on both the state and the input, we also need to modify the way we label the
outputs in the state diagram slightly. Instead of labeling the outputs in the states, we label the outputs on the edges.
Hence, we get the following state diagram
C =0
Y =0
C =1
Y =0
Q 1 Q 0 = 00
Q 1 Q 0 = 01
C =1
Y =1
C =0
Y =0
C =0
Y =0
C =1
Y =0
C =1
Y =0
Q 1 Q 0 = 11
Q 1 Q 0 = 10
C =0
Y =0
t1
t2
t3 t4
We see that this Mealy circuit is also a modulo-4 counter like in the previous example. The only difference is in
the Y output trace. For the Moore machine at t2 when C is de-asserted, Y remains asserted, whereas, for the Mealy
7.3
Synthesis of sequential circuits is just the reverse procedure of the analysis of sequential circuits. In synthesis,
we start with what is usually an ambiguous functional description of the circuit that we want. From this description,
we need to come up with a precise state diagram and next-state / output table, from which we can derive the circuit.
During the synthesis process, there are many possible circuit optimizations in terms of the circuit size, speed, and
power consumption. Some basic choices for circuit size optimization include state minimization, state encoding, and
flip-flop type. In many situations, optimizing the circuit size will also result in optimizing the speed and power
consumption. Our discussion will focus mainly on circuit size optimization. Readers interested in speed and power
optimization are referred to the references.
We will first demonstrate the synthesis process without considering optimizations by applying the following
basic steps on a simple example.
1.
2.
3.
4.
5.
6.
Enoch Hwang
Page 7 of 14
C= 0
Q2Q1Q0 = 000
Y=0
C= 1
Q2Q1Q0 = 001
Y=0
C= 1
Q2Q1Q0 = 101
Y=1
C= 1
C= 0
C= 0
Q2Q1Q0 = 010
Y=0
C= 1
C= 1
C= 0
C= 0
Q2Q1Q0 = 100
Y=0
C= 1
Q2Q1Q0 = 011
Y=0
C= 0
Enoch Hwang
Page 8 of 14
Next State
Q2next Q1next Q0next
C=0
C=1
000
001
001
010
010
011
011
100
100
101
101
000
Current State
Q2Q1Q0
000
001
010
011
100
101
Output
Y
0
0
0
0
0
1
Qnext
0
1
0
1
T
0
1
1
0
For example, in the next-state table for C = 1 and the current state Q2Q1Q0 = 010, we want the next state
to be 011. The corresponding entry in the implementation table using T flip-flops would be T2T1T0 =
001 because for flip-flop2 we want its content to go from Q2 = 0 to Q2next = 0. The excitation table tells us that to
realize this change, the T2 input needs to be a 0. Similarly, for flip-flop1 we want its content to go from Q1 = 1 to
Q1next = 1, and again the T1 input needs to be a 0 to realize this change. Finally, for flip-flop0 we want its content to go
from Q0 = 0 to Q0next = 1, this time, we need T0 to be a 1. Continuing in this manner for all the entries in the next-state
table, we obtain the following implementation table
Q2nextQ1nextQ0next
Current State
Q2Q1Q0
000
001
010
011
100
101
Implementation
T2 T1 T0
C=0
C=1
000
001
000
011
000
001
000
111
000
001
000
101
Enoch Hwang
T2
CQ2Q0
CQ1Q0
T1
CQ2
Q1 Q0
Page 9 of 14
00
01
11
10
00
01
11
10
T0
CQ2
Q1 Q0
00
01
11
10
00
01
11
10
CQ2'Q0
T2 = CQ2Q0 + CQ2Q1
CQ2
00
01
11
10
00
01
11
10
T1 = CQ2'Q0
Q1Q0
T0 = C
T2
Q2
Clk
Q'2
T1
Q1
Clk
Q'1
T0
Clk
Q0
Clk
Q'0
Example 7.4
We will illustrate the synthesis process with another example. We will design a counter that counts in the
following sequence:
1, 4, 6, 7, 1, 4, 6, 7, .
The count is to be represented directly by the contents of the flip-flops. The counter is enabled by the input C. The
count stops when C = 0. The next-state table, therefore, is
Enoch Hwang
Page 10 of 14
Next State
Q2next Q1next Q0next
C=0
C=1
001
100
100
110
110
111
111
001
Current State
Q2Q1Q0
001
100
110
111
To do something different, we will use a JK flip-flop, a D flip-flop and a SR flip-flop in this order starting from
the most significant bit for the three flip-flops needed. Converting from the next-state table to the implementation
table requires the excitation tables for the three flip-flops that well be using. The excitation tables from Figure 7.15
are repeated here for convenience.
Q
0
0
1
1
Qnext
0
1
0
1
J
0
1
1
0
D
0
1
0
1
S
0
1
0
0
1
0
Each entry in the implementation table will have five values for the five inputs (J2 K2 D1 S0 R0) needed for our
three flip-flops. The first bit Q2next from the next-state table will convert to the two input bits J2 and K2. The Q1next bit
will convert to the D1 input, and Q0next will convert to the two input bits S0 and R0.
Implementation
J2 K2 D1 S0 R0
C=0
C=1
000
1001
000
010
010
0110
010
100
Current State
Q2Q1Q0
001
100
110
111
From the implementation table, we get the following five K-maps and excitation equations
J2
Q1Q0
D1
K2
CQ2
00
01
11
10
00
01
11
10
CQ2
Q1Q0
00
CQ1
10
CQ2
Q1Q0
00
01
11
10
00
01
01
11
11
10
10
CQ0
K2 = CQ0
R0
CQ2
Q1Q0
11
00
J2 = C
S0
01
00
01
11
10
00
01
11
10
S0 = CQ1
CQ0'
C'Q1
D1 = CQ0' + C'Q1
CQ2
Q1Q0
CQ1'
00
01
11
10
00
01
11
10
R0 = CQ1'
Enoch Hwang
Page 11 of 14
J2
Q2
Clk
K2
Q'2
D1
Q1
Clk
Q'1
S0
Q0
Clk
R0
Clk
Q'0
Next State
Q1next Q0next
C=0 C=1
00
01
01
10
10
11
11
00
Implementation table:
Current State
Q1 Q0
00
01
10
11
Next State
T1 T0
C=0 C=1
00
01
00
11
00
01
00
11
Excitation equations:
T1 = CQ0
T0 = C
Enoch Hwang
Page 12 of 14
T1
Q1
Clk
Q'1
T0
Clk
Q0
Clk
Q'0
7.4
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY MooreFSM IS
PORT(
clk
: IN BIT;
cnt
: IN BIT;
Y : OUT BIT);
END MooreFSM;
ARCHITECTURE Behavioral OF MooreFSM IS
TYPE STATE_TYPE IS (s0, s1, S2);
SIGNAL state : STATE_TYPE;
BEGIN
PROCESS (clk)
BEGIN
IF (clk'EVENT AND clk = '1') THEN
CASE state IS
WHEN s0=>
Y <= '0';
IF cnt = '1' THEN
state <= s1;
ELSE
state <= s0;
END IF;
WHEN s1=>
Enoch Hwang
Page 13 of 14
Y <= '0';
IF cnt = '1' THEN
state <= s2;
ELSE
state <= s1;
END IF;
WHEN s2=>
Y <= '1';
IF cnt = '1' THEN
state <= s0;
ELSE
state <= s2;
END IF;
END CASE;
END IF;
END PROCESS;
END Behavioral;
Enoch Hwang
Page 14 of 14
END PROCESS;
Y <= '1' WHEN state = s2 ELSE '0';
END Behavioral;
Enoch Hwang