Finite State Machines
Synchronous sequential circuits can be drawn in the forms shown in Figure 3.22. These forms are called finite state machines (FSMs). They get their name because a circuit with k registers can be in one of a finite number ( ) of unique states (note the state symbol in the figure below).

An FSM has M inputs, N outputs, and k bits of state. It also receives a clock, and optionally, a reset signal. An FSM consists of two blocks of combinational logic, next state logic and output logic, and a register that stores the state.
On each clock edge, the FSM advances to the next state, which was computed based on the current state and inputs. There are two general classes of finite state machines, characterized by their functional specifications.
In Moore machines, the outputs depend only on the current state of the machine.
In Mealy machines, the outputs depend of both current state and the current inputs.
Finite state machines provide a systematic way to design synchronous sequential circuits given a functional specification.
FSM Design Example
Suppose now Ben Bitdiddle wants to design a traffic light controller for the following roads

He installs two traffic sensors, and , on Academic Ave. and Bravado Blvd., respectively. Each sensor indicates TRUE if students are present and FALSE if the street is empty. He also installed two traffic lights, and . Ben also provides a clock with a 5-second period. On each clock tick (rising edge), the lights may change based on the traffic sensors. He also provides a reset button so that the technicians can put the controller in a known initial state when they turn it on. Figure 3.24 shows a black box view of the state machine.

Now, Ben follows the following steps to systemetically implement this FSM
Sktech the state transition diagram
After Ben's careful consideration, by analyzing the behavior of this system, he sketches the state transition diagram as follows

Notes
In a state transition diagram, circles represent states and arcs represent transitions between states.
The arc labeled Reset pointing from outer space into state S0 indicates that the system should enter that state upon reset, regardless of what previous state it was in.
If a state has multiple arcs leaving it, the arcs are labeled to show what input triggers each transition.
If a state has a single arc leaving it, that transition always occurs regardless of the inputs. For example, in the state transition diagram above, when the system is in state S1, it will always move to S2.
The value that the outputs (LA, LB) have while in a particular state are indicated in the state.
Write the state transition table
Ben then rewrites the state transition diagram as a state transition table, which indicates, for each state an input, what the next state, S', should be.

Notes
The table uses don't care symbols (X) whenever the next state does not depend on a particular input.
Reset is omitted from the table. Instead, we use resettable flip-flops that always go to state S0 on reset, independent of the inputs.
Encode states and outputs
The state transition diagram is abstract in that it uses states labeled {S0, S1, S2, S3} and outputs {red, yellow, green}. To build a real circuit, the states and outputs must be assigned binary encodings. Ben chooses the simple encodings in Table 3.2 and 3.3. Each state and each output is encoded with two bits: and .

Calculate the next state logic
Ben updates the state transition table to use these binary encodings, as shown in Table 3.4. The revised state transition table is a truth table specifying the next state logic. It defines next state, S', as a function of the current state, S, and the inputs.

From this table, we can either observe straight-forwardly or use the Karnaugh Map to get the simplest boolean equation for and .
To use a K-map here,
The first key point is to know that we should have two functions/boolean equations for our "outputs" and . Thus the content of our K-map should be the value of either these two "outputs".
Then, the columns and rows of the K-map should be the parameters of the function/boolean equation, which are current state and inputs.
Knowing these two points, and taking care of the don't cares carefully, we can build the K-map for as follows,
00
01
11
10
00
1
1
0
0
01
0
0
0
0
11
0
0
0
0
10
1
0
0
1
From the K-map table, we can easily get the boolean equation for . For , it will be similar.
State Encodings
In the previous example, the state and output encodings were selected arbitrarily. A different choice would have resulted in a different circuit.
One important decision in state encoding is the choice between binary encoding and one-hot encoding.
With binary encoding, as was used in the traffic light controller example, each state is represented as a binary number. Because K binary numbers can be represented by bits, a system with K states only needs bits of state.
In one-hot encoding, a separate bit of state is used for each state. It is called one-hot because only one-bit is "hot" or TRUE at any time. For example, a one-hot encoded FSM with three states would have state encodings of 001, 010, and 100. Each bit of state is stored in a flip-flop, so one-hot encoding requires mroe flip-flops than binary encoding. However, with one-hot encoding, the next-state and output logic is often simpler, so fewer gates are required.
A related encoding is the one-cold encoding, in which K states are represented with K bits, exactly one of which is FALSE.
The best encoding choice depends on the specific FSM.
Moore and Mealy Machines
So far, we have shown examples of Moore machines, in which the output depends only on the state of the system. Hence, in state transition diagrams for Moore machines, the outputs are labeled in the circles. Recall that Mealy machines are much like Moore machines, but the outputs can depend on inputs as well as the current state. Hence, in state transition diagrams for Mealy machines, the outputs are labelled on the arcs instead of in the circles. The block of combinational logic that computes the outputs uses the current state and inputs, as was shown in Figure 3.22(b).
Notes
An easy way to remember the difference between the two types of finite state machines is that a Moore machine typically has more states than a Mealy machine for a given problem.
When labelling the arcs for Mealy machines, we can use the tradition
A/Y, whereAis the value of the input that causes the transition, andYis the corresponding output.
Factoring State Machines
Designing complex FSMs is often easier if they can be broken down into multiple interacting simpler state machines such that the output of some machines is the input of others. This application of hierarchy and modularity is called factoring of state machines.
Deriving an FSM from a Schematic
Deriving the state transition diagram from a schematic follows nearly the reverse process of FSM design. This process can be necessary, for example, when taking on an incompletely documented project or reverse engineering somebody else’s system.
Examine circuit, stating inputs, outputs, and state bits.
Write next state and output equations.
Create next state and output tables.
Reduce the next state table to eliminate unreachable states.
Assign each valid state bit combination a name.
Rewrite next state and output tables with state names.
Draw state transition diagram.
State in words what the FSM does.
In the final step, be careful to succinctly describe the overall purpose and function of the FSM — do not simply restate each transition of the state transition diagram.
FSM Review
Finite State machines are a powerful way to systematically design sequential circuits from a written specification. Use the following procedure to design an FSM:
Identify the inputs and outputs.
Sketch a state transition diagram
For a Moore machine:
Write a state transition table
Write an output table
For a Mealy machine: Write a combined state transition and output table
Select state encodings — your selection affects the hardware design
Write Boolean equations for the next state and output logic
Sketch the circuit schematic
Last updated




















