Finite State Machines (as a sequential network) hold the present state in memory and compute the next state and output using combinational logic. The input to the next state computation is the present state and any inputs. A modulus counter represents the simplest FSM since it has no inputs, the next state depends completely on the present state. For example, a Mod-5 counter FSM counts 0, 1, 2, 3, 4, 0, 1, ... The general architecture of an FSM is the following: the architecture consists of Compute Next State that uses the Present State to determine which will be the next state to enter. The Clock input serves to synchronize the FSM operation into discrete points of state change.
It is important to understand the role of the clock in coordinating
the operation of the FSM. As the following diagram illustrates, the Next
State computation is (must be) completed when the clock pulse
occurs. The clock is active on the rising edge in this example meaning
that all changes to the memory occur on the rising clock edge. The Next
State becomes the Present State on the active clock edge, meaning
the count changes.
![]() |
![]() |
![]() |
![]() |
8.2 High-level and Binary Implementations
Actual FSM implementation in hardware requires that all inputs, outputs,
and states be encoded into a binary representation. For the Mod-5
FSM the high level graphical representation and binary encoding of state
and
output
are:
![]() |
![]() |
| Output: z(t) element
of {000, 001, 010, 011, 100}
State: ps(t) element of {ps2, ps1, ps0}, psi element of {0,1} Initial State: ps(0) = (0,0,0) Transition ns0 = ps2'*ps0'
|
High-level PS| A | B/0 B | C/1 C | D/2 D | E/3 E | A/4 |NS/Output |
Binary encoded PS | ps210|ns210/z210 000| 001/ 000 001| 010/ 001 010| 011/ 010 011| 100/ 011 100| 000/ 100 | NS/Output |
Present Next ps2 ps1 ps0| ns2 ns1 ns0 0 0 0| 0 0 1 0 0 1| 0 1 0 0 1 0| 0 1 1 0 1 1| 1 0 0 1 0 0| 0 0 0 1 0 1| d d d 1 1 0| d d d 1 1 1| d d d |
\ ps1 ps0 ps2\00 01 11 10 0| 0| 0| 1| 0| 1| 0| d| d| d| ns2 = ps1*ps0 z2 = ps2 |
\ ps1 ps0 ps2\00 01 11 10 0| 0| 1| 0| 1| 1| 0| d| d| d| ns1 = ps1'*ps0+ps1*ps0' z1 = ps1 |
\ ps1 ps0 ps2\00 01 11 10 0| 1| 0| 0| 1| 1| 0| d| d| d| ns0 = ps2'*ps0' z0 = ps0 |
8.3 D Flip-Flop - Flip-flops can serve as memory for the FSM architecture. The D-FF or Data Flip-Flop can store one data bit, either a 0 or a 1. For synchronization, flip-flops must be clocked, inputting new D data only on an active clock pulse. The excitation table and graphical representation of the D-FF is:
D-FF Excitation Table Clk D|Q Inactive x|No Change Active 0|0 Active 1|1 |
![]() |
![]() |
D-FF with Preset and Clear PreSet Clear Clk D|Q 0 1 x x|1 1 0 x x|0 1 1 Inactive x|No Change 1 1 Active 0|0 1 1 Active 1|1 |
![]() |
![]() |
| ENTITY ch8dff IS
PORT( Clock, Reset : IN BIT; ps2, ps1, ps0 : OUT BIT); END ch8dff; ARCHITECTURE structural OF ch8dff IS
SIGNAL ips2, ips1, ips0
: BIT;
-- Internal ps
-- Transition ns0 = ps2'*ps0'
ns0 <= (NOT ips2) AND (NOT ips0);
DFF0: dff PORT MAP (ns0, Clock, Reset,
ONE, ips0);
ps2 <= ips2; ps1 <= ips1;
ps0 <= ips0; -- Assign ps output
|
![]() |
Multiplexer Method - Using combinational logic to compute the next state often yields a design that is difficult to understand for even simple FSMs though the Mod-5 next state computation is straightforward. An easier, clearer implementation uses multiplexers, a general selector device, to provide the selection logic for next state. Since there are 5 states (0,1,2,3,4), 3 D-FFs are again required as present state memory.
On the multiplexer, the next state is the multiplexer inputs, selected by the present state, the D-FF output. To understand the architecture operation consider when the present state is 001.
![]() |
Present Next ps2 ps1 ps0| ns2 ns1 ns0 0 0 0 0| 0 0 1 1 1 0 0 1| 0 1 0 2 2 0 1 0| 0 1 1 3 3 0 1 1| 1 0 0 4 4 1 0 0| 0 0 0 0 5 1 0 1| d d d 6 1 1 0| d d d 7 1 1 1| d d d Present/Next State Table Present |Next State State |Multiplexer Input s2 s1 s0| D2 D1 D0 0 0 0| 0 0 1 0 0 1| 0 1 0 0 1 0| 0 1 1 0 1 1| 1 0 0 1 0 0| 0 0 0 1 0 1| d d d 1 1 0| d d d 1 1 1| d d dMultiplexer Inputs |
Inputs | Outputs Select | Enable | C B A | GN | Y WN X X X | H | L H L L L | L | D0 D0' L L H | L | D1 D1' L H L | L | D2 D2' L H H | L | D3 D3' H L L | L | D4 D4' H L H | L | D5 D5' H H L | L | D6 D6' H H H | L | D7 D7' 74151 8 Input Multiplexer |
![]() |
| ENTITY ch8mux IS
PORT( Clock : IN BIT; ps2, ps1, ps0 : OUT BIT); END ch8mux; ARCHITECTURE structural OF ch8mux IS
SIGNAL ips2, ips1, ips0
: BIT;
Mux0: f74151 PORT MAP (ips2, ips1, ips0, ns0, ZERO, y0, x0);
DFF0: dff PORT MAP (y0, Clock, ONE, ONE, ips0);
ps2 <= ips2; ps1 <= ips1; ps0 <=
ips0;
|
The one additional requirement of the one-hot method is that
only one flip-flop be hot at a time, including the starting state FF. To
force the FSM to start in state 0, an asynchronous Reset
is needed that forces a 1 into the D-FF 0, and 0 into D-FFs 1,2,3,4. This
is accomplished by connecting a Reset to the PRESET of D-FF
0, and to the
CLEAR of D-FFs 1,2,3,4. When the FSM is reset, only
D-FF 0 is 1, the rest are 0.
![]() |
Using the one-hot method, the state table is more easily developed
by listing the next state first and determining which present
state leads to the next state, the reverse order of the combinational
and multiplexer method. For that reason the next state is listed
first followed by the present state.
|
| ENTITY ch8one IS
PORT( Clock, Reset : IN BIT; ps4, ps3, ps2, ps1, ps0 : OUT BIT); END ch8one; ARCHITECTURE structural OF ch8one IS
SIGNAL d0, d1, d2, d3, d4
: BIT;
d0 <= q4; d1 <= q0; d2 <= q1; d3 <= q2; d4 <= q3; DFF1: dff PORT MAP (d1, Clock, RESET, ONE,
q1);
ps4 <= q4; ps3 <= q3; ps2 <= q2; ps1 <= q1;
ps0 <= q0;
|

FSMs with Inputs - The FSM implementations examined so far changed to the next state based solely on the present state, no input was examined. The following revisits the use of combinational logic, multiplexer, and the one-hot methods for FSM implementation that have input.
8.6 Combinational Logic - The FSM to be examined is a switchable
counter that counts only even numbers from 0 through 4 when the input Even
is
true and is a Mod 5 counter when Even is false. The high level
graphical representation and with binary encodings for input, output,
and state are given below.
![]() |
![]() |
Input: Even(t) element of {0,1}
Output: z(t) element of
{000, 001, 010, 011, 100}
State: ps(t) element of {ps2, ps1, ps0},
psi element of {0,1}
Initial State: ps(0) = (0,0,0)
Transition ns0 = ps2'*ps0'
and Output ns1 = ps1'*ps0+ps1*ps0'
Functions: ns2 = ps1*ps0
z(t) = (ps2,ps1,ps0)
|
| Input PS|Even=0 Even=1 A |B/0 C/0 B |C/1 C/1 C |D/2 E/2 D |E/3 E/3 E |A/4 A/4 |NS/Output |
| Input PS |Even=0 Even=1 000|001/000 010/000 001|010/001 010/001 010|011/010 100/010 011|100/011 100/011 100|000/100 000/100 |NS/Output |
The transition table in terms of binary variables for input, present and next state is at left. The expressions for the next state variables (ns2, ns1, ns0) are simplified at right using Karnaugh maps. The implementation of these expressions in VHDL or graphical is very similar to the previous combinational logic implementation of the Mod-5 counter.
Input Present Next Even ps2 ps1 ps0| ns2 ns1 ns0 0 0 0 0| 0 0 1 0 0 0 1| 0 1 0 0 0 1 0| 0 1 1 0 0 1 1| 1 0 0 0 1 0 0| 0 0 0 0 1 0 1| d d d 0 1 1 0| d d d 0 1 1 1| d d d 1 0 0 0| 0 1 0 1 0 0 1| 0 1 0 1 0 1 0| 1 0 0 1 0 1 1| 1 0 0 1 1 0 0| 0 0 0 1 1 0 1| d d d 1 1 1 0| d d d 1 1 1 1| d d dPresent/Next State Table |
Even\ ps1 ps0 ps2\00 01 11 10 00| 0| 0| 1| 0| 01| 0| d| d| d| 11| 0| d| d| d| 10| 0| 0| 1| 1| ns2 = Even*ps1 +ps1*ps0 z2 = ps2 |
Even\ ps1 ps0 ps2\00 01 11 10 00| 0| 1| 0| 1| 01| 0| d| d| d| 11| 0| d| d| d| 10| 1| 1| 0| 0| ns1=ps1'*ps0 + Even*ps2'*ps1' + Even'*ps1*ps0' z1 = ps1 |
Even\ ps1 ps0 ps2\00 01 11 10 00| 1| 0| 0| 1| 01| 0| d| d| d| 11| 0| d| d| d| 10| 0| 0| 0| 0| ns0=Even'*ps2'*ps0' z0 = ps0 |
Multiplexer Method - Combinational logic yields a design that is difficult to follow since it changes substantially for each design. While using multiplexers yields a simpler design it is necessary to define multiplexer inputs (which determine the next state) based in present state and FSM inputs. For the counter under consideration, there are two possible count sequences: when input is Even the sequence is 0, 2, 4, 0, ...; when input is Even' the 0, 1, 2, 3, 4, 0, 1, ... Obviously, at least some of the multiplexer inputs must include the input variable Even.
The diagram below defines the architecture (note that the Clock
would normally be connected but was not here for readability) identical
to the previous Mod 5 counter example except for the inclusion of the Even
variable. Consider the input 010 to Multiplexer 2. Remember that Multiplexer
2 controls only bit 2 from the state encoding. When the present
state is 010 the input Even must be examined. When Even
is true or 1, the next state should be 100. When Even is
false or 0, the next state should be 011. The Even variable
determines whether D-FF 2 receives a 0 or 1. Hence state bit 2 is
determined by the Even input variable. The derivation of multiplexer
inputs can often be done by sight without the formal process as demonstrated
in the table at the right of the diagram .
|
|
Present |Input| Next Mux Inputs ps2 ps1 ps0| |ns2 ns1 ns0| 2 1 0 0 0 0|Even'| 0 0 1| 0 0 Even' 0 0 0|Even | 0 1 0| 0 Even 0 0 0 1|Even'| 0 1 0| 0 Even' 0 0 0 1|Even | 0 1 0| 0 Even 0 0 1 0|Even'| 0 1 1| 0 Even' Even' 0 1 0|Even | 1 0 0|Even 0 0 0 1 1|Even'| 1 0 0|Even'0 0 0 1 1|Even | 1 0 0|Even 0 0 1 0 0|Even'| 0 0 0| 0 0 0 1 0 0|Even | 0 0 0| 0 0 0 1 0 1|Even'| 0 0 0| 0 0 0 1 0 1|Even | 0 0 0| 0 0 0 1 1 0|Even'| 0 0 0| 0 0 0 1 1 0|Even | 0 0 0| 0 0 0 1 1 1|Even'| 0 0 0| 0 0 0 1 1 1|Even | 0 0 0| 0 0 0 |
Deriving Multiplexer Input Expressions
In general the next state is the multiplexer input, selected
by the present state. The multiplexer input depends upon the present
state and input. The following expressions define the each multiplexer
input for each present state.
Mux2(000) = ns2(001)*Even' + ns2(010)*Even = 0*Even' + 0*Even
= 0
Mux2(001) = ns2(010)*Even' + ns2(010)*Even = 0*Even' + 0*Even
= 0
Mux2(010) = ns2(011)*Even' + ns2(100)*Even = 0*Even' + 1*Even
= Even
Mux2(011) = ns2(100)*Even' + ns2(100)*Even = 1*Even' + 1*Even
= 1
Mux2(100) = ns2(000)*Even' + ns2(000)*Even = 0*Even' + 0*Even
= 0
Mux1(000) = ns1(001)*Even' + ns1(010)*Even = 0*Even' + 1*Even
= Even
Mux1(001) = ns1(010)*Even' + ns1(010)*Even = 1*Even' + 1*Even
= 1
Mux1(010) = ns1(011)*Even' + ns1(100)*Even = 1*Even' + 0*Even
= Even'
Mux1(011) = ns1(100)*Even' + ns1(100)*Even = 0*Even' + 0*Even
= 0
Mux1(100) = ns1(000)*Even' + ns1(000)*Even = 0*Even' + 0*Even
= 0
Mux0(000) = ns0(001)*Even' + ns0(010)*Even = 1*Even' + 0*Even
= Even'
Mux0(001) = ns0(010)*Even' + ns0(010)*Even = 0*Even' + 0*Even
= 0
Mux0(010) = ns0(011)*Even' + ns0(100)*Even = 1*Even' + 0*Even
= Even'
Mux0(011) = ns0(100)*Even' + ns0(100)*Even = 0*Even' + 0*Even
= 0
Mux0(100) = ns0(000)*Even' + ns0(000)*Even = 0*Even' + 0*Even
= 0
Multiplexer Method in VHDL - Using VHDL, the only significant
change from the Mod-5 counter is the inclusion of the Even input
variable into the definition of the next state. Note in the signal
assignment of ns2, ns1, ns0 below the use of the concatenation operator
& to construct all inputs at one time for multiplexers 2, 1, and 0.
| ENTITY ch8mux IS
PORT( Even, Clock : IN BIT; ps2, ps1, ps0 : OUT BIT); END ch8mux; ARCHITECTURE structural OF ch8mux IS
SIGNAL ips2, ips1, ips0
: BIT;
ZERO <= '0'; ONE <= '1'; -- Constant 0 and 1 Mux0: f74151 PORT MAP (ips2, ips1, ips0, ns0, ZERO, y0, x0);
DFF0: dff PORT MAP (y0, Clock, ONE, ONE, ips0);
ps2 <= ips2; ps1 <= ips1; ps0 <=
ips0;
|
![]() |
![]() |
Next |Input|Present State| |State 1 |Even'| 0 2 |Even | 0 2 | d | 1 3 |Even'| 2 4 |Even | 2 4 | d | 3 0 | d | 4 |
Next State |Input|Present State D-FF Inputs | | D-FF Outputs NS|D0 D1 D2 D3 D4 | |Q0 Q1 Q2 Q3 Q4|PS NS = PS*Input 1| 0 1 0 0 0 |Even'|1 0 0 0 0 | 0 D1 = Q0*Even' 2| 0 0 1 0 0 |Even |1 0 0 0 0 | 0 D2 = Q0*Even 2| 0 0 1 0 0 | d |0 1 0 0 0 | 1 + Q1 3| 0 0 0 1 0 |Even'|0 0 1 0 0 | 2 D3 = Q2*Even' 4| 0 0 0 0 1 |Even |0 0 1 0 0 | 2 D4 = Q2*Even 4| 0 0 0 0 1 | d |0 0 0 1 0 | 3 + Q3 0| 1 0 0 0 0 | d |0 0 0 0 1 | 4 D0 = Q4 |
![]() |
ENTITY ch8one IS
PORT( Even, Clock, Reset : IN BIT; ps4, ps3, ps2, ps1, ps0 : OUT BIT); END ch8one; ARCHITECTURE structural OF ch8one IS
SIGNAL d0, d1, d2, d3, d4
: BIT;
d0 <= q4;
DFF1: dff PORT MAP
ps4 <= q4; ps3 <= q3; ps2 <= q2;
|
![]() |
![]() |
Set-Reset Flip-Flops - The standard excitation table of the simple
SR-FF is at left, the SR-FF primitive available in MAX+plus II with asynchronous
Clear and Preset description is at right:
S R Clock | Q x x Inactive|No Change 0 0 Active |No Change 0 1 Active | 0 1 0 Active | 1 1 1 Active | Illegal |
![]() |
Present |Input|Next Q2 Q1 Q0|Even | |R2 S2 R1 S1 R0 S0 0 0 0| 0 |001| 1 0 1 0 0 1 0 0 0| 1 |010| 1 0 0 1 1 0 0 0 1| 0 |010| 1 0 0 1 1 0 0 0 1| 1 |010| 1 0 0 1 1 0 0 1 0| 0 |011| 1 0 0 1 0 1 0 1 0| 1 |100| 0 1 1 0 1 0 0 1 1| 0 |100| 0 1 1 0 1 0 0 1 1| 1 |100| 0 1 1 0 1 0 1 0 0| 0 |000| 1 0 1 0 1 0 1 0 0| 1 |000| 1 0 1 0 1 0 1 0 1| 0 |000| 1 0 1 0 1 0 1 0 1| 1 |000| 1 0 1 0 1 0 1 1 0| 0 |000| 1 0 1 0 1 0 1 1 0| 1 |000| 1 0 1 0 1 0 1 1 1| 0 |000| 1 0 1 0 1 0 1 1 1| 1 |000| 1 0 1 0 1 0 Present/Next State Table |
\ Q0 Even Q2Q1 \00 01 11 10 00| 1| 1| 1| 1| 01| 1| 0| 0| 0| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| R2=Q2+Q1'+Q0'*Even' S2=R2' by observation of Present/Next Table z2=Q2 |
\ Q0 Even Q2Q1 \00 01 11 10 00| 1| 0| 0| 0| 01| 0| 1| 1| 1| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| R1=Q2+Q1*Even +Q1*Q0 +Q1'*Q0'*Even' S1=R1' by observation of Present/Next Table z1=Q1 |
\ Q0 Even Q2Q1 \00 01 11 10 00| 0| 1| 1| 1| 01| 0| 1| 1| 1| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| R0=Q2+Q0+Even S0=R0' z0=Q0 |
J K Clock | Q x x Inactive|No Change 0 0 Active |No Change 0 1 Active | 0 1 0 Active | 1 1 1 Active | Q' |
![]() |
Present |Input|Next Q2 Q1 Q0|Even | |K2 J2 K1 J1 K0 J0 0 0 0| 0 |001| 1 0 1 0 1 1 0 0 0| 1 |010| 1 0 1 1 1 0 0 0 1| 0 |010| 1 0 1 1 1 1 0 0 1| 1 |010| 1 0 1 1 1 1 0 1 0| 0 |011| 1 0 0 1 1 1 0 1 0| 1 |100| 1 1 1 1 1 0 0 1 1| 0 |100| 1 1 1 1 1 1 0 1 1| 1 |100| 1 1 1 1 1 1 1 0 0| 0 |000| 1 1 1 0 1 0 1 0 0| 1 |000| 1 1 1 0 1 0 1 0 1| 0 |000| 1 1 1 0 1 1 1 0 1| 1 |000| 1 1 1 0 1 1 1 1 0| 0 |000| 1 1 1 1 1 0 1 1 0| 1 |000| 1 1 1 1 1 0 1 1 1| 0 |000| 1 1 1 1 1 1 1 1 1| 1 |000| 1 1 1 1 1 1 Present/Next State Table |
|||
\ Q0 Even Q2Q1 \00 01 11 10 00| 1| 1| 1| 1| 01| 1| 1| 1| 1| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| K2=1 \ Q0 Even Q2Q1 \00 01 11 10 00| 0| 0| 0| 0| 01| 0| 1| 1| 1| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| J2=Q2+Q1*Q0 +Q1*Even z2=Q2 |
\ Q0 Even Q2Q1 \00 01 11 10 00| 1| 1| 1| 1| 01| 0| 1| 1| 1| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| K1=Q2+Q1'+Q0+Even \ Q0 Even Q2Q1 \00 01 11 10 00| 0| 1| 1| 1| 01| 1| 1| 1| 1| 11| 1| 1| 1| 1| 10| 0| 0| 0| 0| J1=Q1+Q2'*Even +Q2'*Q0 z1=Q1 |
\ Q0 Even Q2Q1 \00 01 11 10 00| 1| 1| 1| 1| 01| 1| 1| 1| 1| 11| 1| 1| 1| 1| 10| 1| 1| 1| 1| K0=1 \ Q0 Even Q2Q1 \00 01 11 10 00| 1| 0| 1| 1| 01| 1| 0| 1| 1| 11| 0| 0| 1| 1| 10| 0| 0| 1| 1| J0=Q0+Q2'*Q0'*Even' z0=Q0 |