Lecture 9: Finite State Representation of Digital Circuits: DOC112: Computer Hardware Lecture 9 1
Lecture 9: Finite State Representation of Digital Circuits: DOC112: Computer Hardware Lecture 9 1
We noted that any member of the class of circuits called flip flops can be conveniently be represented by a finite
state machine, and in general any synchronous circuit can be modelled by a finite state machine, and vice versa.
A finite state machine in its most general form can be represented by a pair of equations:
Where S(t) represents the state at time t and can take only a finite set of values, normally thought of as integers.
I(t) and O(t) are the inputs and outputs which are also normally discrete bounded variables and f and g are
functions. Synchronous circuits which conform to the above equations are called Mealy machines, and are
represented by the block diagram of Figure 1.
There is a simpler form of finite state machine which is often used where the output is only a function of
the state, and the equation pair becomes:
Circuits of this form are called Moore machines, and are represented by the block diagram of Figure 2. In both
cases the blocks f and g compute the finite state machine functions and are implemented by combinational
logic. We will call block g the output (or decode) logic and block f the state sequencing (or input) logic. The
blocks marked D − Q are called state registers and consist of a set of D-type flip flops.
The fact that synchronous circuits can be represented by finite state machines gives us the basis of a design
methodology. As with programme design (or indeed any engineering design task) we can most easily solve a
problem at the highest functional level, hence it is better to design the finite state machine before considering
how to construct it out of gates. The methodology for synchronous circuit design can be stated as follows:
2. Determine the state transitions and outputs and draw the finite state machine
3. Choose the way in which the states will be represented (State Assignment)
4. Express the state sequencing logic as a set of Boolean equations combining the states and the inputs,
using the existing methodology based on finding minterms. Minimise using the Karnaugh map method.
5. Express the required outputs as a Boolean function of the states, and minimize using Karnaugh maps if
possible.
We will now consider a simple example which will illustrate some of the issues concerned with this method-
ology. It is a counting circuit, similar to that designed in the previous lecture. The input will be taken from a
push button, and the output will be a digit in the range 0 to 5 displayed on a seven segment display (see Figure
3). The seven segment display device will be set up so that a logic 1 makes the corresponding segment visible,
and a logic 0 will make it invisible. Such a circuit might used to set the time in a digital clock.
The design of the finite state machine is quite straightforward. Clearly there are six states, which we can
label 0 to 5 representing the digit that will be displayed. If we assume that the circuit operates on a slow clock,
providing a falling edve once every second, and the display advances when the input button is pushed (I = 1)
are to be represented. The simplest possibility is that we allocate one flip flop per state, so that our D-Q box in
Figure 2 is made up of six flip flops. However, this arrangement is likely to use many more components than
we need, since the states could be encoded on just three flip flops rather than six. But here again is a problem,
since three flip flops can represent eight states, that is to say, if we treat the outputs of the flip flops as a three bit
number, we have eight possibilities, and we need to decide which number encodes (or represents) each state.
This is the state assignment problem, and the choices that we make will affect both the output and the state
sequencing logic.
We will choose to make the state allocation simple. State 0 will be allocated the three bit binary number
(Q2 Q1 Q0 ) 000, state 1 will be allocated 001 and so on. If we use a binary variable Si to represents the ith state,
we see immediately that each state has a corresponding minterm with the three flip flop outputs as its variables,
and we can define the assignment using these minterms:
S0 = Q02 · Q01 · Q00 S1 = Q02 · Q01 · Q0 etc
Only one of the eight states Si will evaluate to logic 1 at any one time. The output logic is very simple in this
case. It is specified entirely by the OR function. For example, consider output 1 (which makes the top segment
visible). It should be one only when we are displaying the numbers 0,2,3 and 5. That is to say, it is a one when
we are in states S0 , S2 , S3 and S5 . Thus we can write:
O1 = S0 + S2 + S3 + S5
O1 = Q02 · Q01 · Q00 + Q02 · Q1 · Q00 + Q02 · Q1 · Q0 + Q2 · Q01 · Q0
and apply the Karnaugh map method to determine the minimum circuit for O1 . tThe same method is used for
all the other output lines. We can now construct the input logic by considering each state in turn. The design
decomposes into a separate problem for each state. The equations for a state can be derived simply by looking
at the arrows that point to that state in the finite state machine diagram. We can obtain an equation directly in
the canonical form. For example:
N0 = S5 · I + S0 · I 0
where N0 means the next state is to be S0 . Here again we have a problem that we can minimise using the
standard Karnaugh map method. However, the new state needs to be presented to the D input of the flip
flops, and thus must be encoded. For example if the next state is to be 1, we need to set the D inputs to be
D2 = 0, D1 = 0 and D0 = 1. In practice we formulate the equations the other way round, saying that the D0
value should be set to 1 when the next state is S1 (001) or S3 (011) or S5 (101). D0 is the bottom bit of the
number that defines the state. Written as a Boolean equation this is:
similarly:
D1 = N2 + N3 and D2 = N4 + N5
D1 = S1 · I + S2 · I 0 + S2 · I + S3 · I 0
D1 = Q02 · Q01 · Q0 · I + Q02 · Q1 · Q00 · I 0 + Q02 · Q1 · Q00 · I + Q02 · Q1 · Q0 · I 0
Following the same procedure for D0 and D2 we obtain the Boolean equations of the whole state sequencing
logic in canonical form ready for minimisation. Once the state assignment has been made, the unused states
become don’t care states, and we expect that they will never appear when the circuit is in correct operation.
Remembering that don’t cares may be treated as either zero or one, and, when using the minterm canonical form
we can often benefit if we treat some of them as ones. We add them to the Karnaugh maps for simplification
of the resulting circuit. When a synchronous circuit has been designed in this way it is necessary to check
that it will start up correctly. The problem is that, since we have treated the unassigned states as don’t cares,
we cannot define how they will behave. For example, it is possible that the unassigned states form a closed
finite state machine as shown in Figure 5, and on start up the circuit never enters any of the required states and
therefore does not perform correctly. We could avoid this problem by explicitly including the unassigned states
in the design, for example making them all lead to a known state, as shown in Figure 6, but this would have the
disadvantage that the resulting circuit may not be the smallest possible. Another strategy would be to check to
see what state transitions are implied when the don’t cares have been allocated particular values, and modify
the circuit if it is unsafe. A third possibility is to use the set and reset features on standard flip flops to force the
circuit into an assigned state either on start up, or on the press of a reset button.
Unfortunately, in general, there is no easy way to see which state assignment will result in the best sim-
plification of the whole circuit. One strategy is to try out all possibilities, and determine which gives the best
overall result. At first sight this looks like a daunting task, since the number of ways we could allocate the
eight possibilities to the six states is 56. However, fortunately many of them can be eliminated. For example,
consider one possible state assignment shown in the table below.
1. All those states that have the same next state for the same input should be given adjacent state assignments
2. The next states of a state produced by applying adjacent input conditions should be given adjacent state
assignments.
In our case the second rule suggests that the neighbouring states in our diagram should be given adjacent state
assignments, ie going round the ring in Figure 4 we would use 000 001 011 111 110 100 and back to 000.
There are many such rules quoted but it is beyond the scope of this course to discuss them.