Beruflich Dokumente
Kultur Dokumente
Sequential circuit
State Machines
State transition diagram
Qn+1 represents
Qn represents the the next state
current state (output)
(output)
State Machines
State transition diagram
A number next to the arrow will show under what input condition
the machine will change to a particular state.
10,11
00 a, Q = 0 b, Q = 1 00
01 10
01,11
A sling starts from a circle (state) and returns to the same circle
(state).
1
a, 0 b, 0
1
- 0
0
c, 1
State-transition diagram
State Machines
State tables
In order to realise a sequential machine from a state-
transition diagram, a state table must be generated.
Such a table shows the present state, the state required at
the next clock pulse, and the transitions required at the flip-
flops for the change.
State Machines
State tables
For JK flip-flops the input conditions required for any
transition are:
Using don’t care conditions we
can simplify the table to:
State Machines
State tables
3-input K-map
From which K2 = 1
From which J1 = Q0
State Machines
State tables – An example
Step 4: From the state table, draw K-maps to simplify the flip-flop
inputs
From which K1 = Q0
From which J0 = Q2
State Machines
State tables – An example
Step 4: From the state table, draw K-maps to simplify the flip-flop
inputs
From which K0 = 1
State Machines
State tables – An example
Step 5: Sketch the circuit
State Machines
Creating a state machine: An example
Use JK flip-flops
Clock
State Machines
Creating a state machine: An example
Looking at the first row the state of A is 0 and the next state of A is
0. Therefore, from the transition table we see that Ja must be 0 and
Ka must be X. The state of C is 0 and the next state of C is 1.
Therefore, from the transition table we see that Jc must be 1 and
Kc must be X.
When the next state is XXXX all J and K inputs can also be X
because we don’t care what happens here.
State Machines
State Machines
Creating a state machine: An example
Next a Karnaugh map must be done for each J and K input using
the current state as the inputs.
Clock
State Machines
Creating a state machine: An example
We have created the state machine with JK flip flops, can we
achieve the same outcome using D-flip flops?
Yes
Clock
State Machines
Creating a state machine: An example
Let’s draw the state-next table again.
State Machines
Creating a state machine: An example
Now draw a Karnaugh map for each column of the next state using
the current state as the inputs.
So for Da (first column of Next State) we get the following:
State Machines
Creating a state machine: An example
Doing Karnaugh maps for all D inputs we get the following:
Clock
State Machines
State machines in AHDL
Here is where we see some of the simplicity of AHDL
over VHDL. In AHDL we need do nothing more than
enter the table showing the current state and the next
state.
State Machines
State machines in AHDL
SUBDESIGN statemachine
(
clk : INPUT;
reset : INPUT;
z[3..0] : OUTPUT;
)
VARIABLE
% current current %
% state output %
ss: MACHINE OF BITS (z[3..0])
WITH STATES ( s0 = 0,
s1 = 2,
s2 = 13,
s3 = 4);
State Machines
State machines in AHDL
BEGIN
ss.clk = clk;
ss.reset = reset;
TABLE
% current next %
% state state %
ss => ss;
s0 => s1;
s1 => s2;
s2 => s3;
s3 => s0;
END TABLE;
END;
State Machines
State machines in AHDL
This describes the state machine in the previous example.
The state machine itself is declared as a buried variable.
We have called it ss.
It uses 4 bits, (z[3..0]) and it has the states 0, 2, 13 and 4
which have been labelled s0, s1, s2 and s3.
In the logic section we first connect the clock signal to
the state machines clock and then the reset signal to the
state machines reset.
State Machines
State machines in AHDL
Finally, we use the truth table statement to list the current
and next states.
The first line of the TABLE statement, (not including the
comments), says that the current state and the next state
are from ss, the state machine.
The next few lines list the current state of the state
machine and the next state for the state machine.
State machines
In this topic we will be covering