digitalteknik eitf65 · 2019-09-03 · trellis definition atrellisisa(directed)graphwhere i...
TRANSCRIPT
Digitalteknik EITF65
Lecture 2: Finite State Machines
September 3, 2019
State transition graphs
DefinitionA state transition graph is a graph where
I the state is an abstract (and compact) desription of the past.It contains all relevant information about the history.
I in each state there is one branch for each input.I in each state there is one output combination for each input.
The branches between the states are drawn as arrows labeled withthe input and the output.
x/u
s s+
Martin Hell, Digitalteknik L2:2, Ch 2.1-2.2
State Machine
Definition (2.2)A state machine is defined by the five-tupleM = {I,S,Z, δ, λ}whereI: is the input set.S: is the state set.Z: is the output set.δ: S × I → S is the state transition function.λ: S × I → Z is the output function.
The behavior of a state machine can be described by a statetransition graph.
Martin Hell, Digitalteknik L2:3, Ch 2.1-2.2
Trellis
DefinitionA trellis is a (directed) graph where
I each node represents a state at a certain depth.I there is a set of root vertices that does not have any entering
edges.The depth of a root vertex is zero. The depth of other vertices aredefined as the number of edges from a root vertex.
Martin Hell, Digitalteknik L2:4, Ch 2.1-2.2
Parity checkExample 2.2Check if a sequence has even or odd parity, i.e., if the number ofones is even or odd.
i = i0i1i2i3 . . . z = z0z1z2z3 . . .
where
zk =
{even if
∑k`=0 i` even
odd if∑k
`=0 i` odd
I: = {0,1} is the input set,
Z: = {even, odd} is the output set
S: = {∑k−1
`=0 i` even,∑k−1
`=0 i` odd}
We can use a state transition graph to define δ and λ.
Martin Hell, Digitalteknik L2:5, Ch 2.1-2.2
Parity check (Graph)
even odd
0/even
1/odd
1/even
0/odd
Let even = 0 and odd = 1 to get:
0 1
0/0
1/1
1/0
0/1
Martin Hell, Digitalteknik L2:6, Ch 2.1-2.2
Parity check (Trellis)
1/0 1/1
0/0
0/1
1
00/0 0/0
0/1 0/1
1/1
1/0
1/1
1/0
time
Martin Hell, Digitalteknik L2:7, Ch 2.1-2.2
Detector
Example 2.3Give 1 as output if and only if the last four input bits matches0011, otherwise 0.E.g.,
i : . . .0011 . . .0011 . . .↓ ↓
z : . . .00010. . .00010. . .
Question: What areI, (input set)S, (state set)Z, (output set)δ, S × I → S (state transition function)λ, S × I → Z (output function)
Martin Hell, Digitalteknik L2:8, Ch 2.1-2.2
Detector (Graph)
0/01/0
0/0
1/0
0/0
1/0
0/0
1/1
s0 s1 s2 s3
Martin Hell, Digitalteknik L2:9, Ch 2.1-2.2
Detector (Trellis)
1/0 0/0
0/0
1/0
0/0
1/1
1/0
0/0
s3
s2
s1
s0
time
1/0 1/0 1/0 1/0
0/0 0/0 0/0 0/0
1/0 1/0 1/0 1/0
0/0 0/0 0/0 0/0
0/0 0/0 0/0 0/0
1/0 1/0 1/0 1/0
1/1 1/1 1/1 1/10/0 0/0 0/0 0/0
Martin Hell, Digitalteknik L2:10, Ch 2.1-2.2
Modulo 5 counter
ExampleConstruct a system that works as a modulo 5 counter. It has twoinputs, Count and U/D. If Count is 0 it does not count and if it is 1it counts. If U/D is 1 it adds one to the result and if 0 it subtractsone. (There is no explicit output here.)
Count U/D state next state0 0 Q Q0 1 Q Q1 0 Q Q-1 mod 51 1 Q Q+1 mod 5
Martin Hell, Digitalteknik L2:11, Ch 2.1-2.2
Modulo 5 counter (Graph)
11
11
11
11
11
10
10
10
10
10
0−
0−
0−0−
0−
s0
s1
s2s3
s4
Martin Hell, Digitalteknik L2:12, Ch 2.1-2.2
The lion threat (two lions)
Example 2.4In a zoo there is an enclosure for lions. It consists of two parts, acage where the lions can rest and the enclosure, which is a big openfield where the lions can stroll around. The enclosure is hilly and,therefore, difficult to overview. Since the keeper wants to clean theenclosure while the lions are in the cage he needs a system where alamp, Danger, tells if there is any lion in the enclosure.
At the passage between the cage and the enclosure there are twophoto detectors, G1 and G2 that are parted by half a meter. Thelions are about two meters long and cannot pass the passage at thesame time.
Construct a graph that solves the problem for two lions.
Martin Hell, Digitalteknik L2:13, Ch 2.1-2.2
The lion threat (figure)
Cage
Enclosure
⊗� �G1⊗� �G2
⊗Danger
��������
�����
��
��
�����
����� ��
��
����
��
��� � �
��
���
������
� ��
��
��
��
��
���
��
��
�� ��
��
��
��
��
���
��������
Martin Hell, Digitalteknik L2:14, Ch 2.1-2.2
The lion threat (Graph)
s2
s0
s̃1
s1
01/1
11/1
11/1
01/1
10/100/1
00/0
11/1
01/1
01/1
11/1
00/1
10/1
10/1
00/1
Martin Hell, Digitalteknik L2:15, Ch 2.1-2.2
Variable name
Example 2.8In programming languages the variable names often consist of aletter followed by letters or digits.
The name ends when the sequence of letters and digits ends, i.e.,when some other character is written.
s0 s1 s2Letter Other
Letter or digit
Martin Hell, Digitalteknik L2:16, Ch 2.1-2.2
Event controlled or clock controlled
When do we change state, i.e., follow an edge?I New event can cause a state transition. On each new input,
look at input and state, and make a state transition. Example:Variable name.
I External clock signal can cause state transition. On eachclock signal, look at input and state, and make a statetransition. Example: Modulo 5 counter.
Clock controlled situations often require additional states since theclock can be very fast!
I Modulo 5 counter would require extra statesI Lion threat would not require extra states
Martin Hell, Digitalteknik L2:17, Ch 2.1-2.2
Design flow
Martin Hell, Digitalteknik L2:18, Ch 2.1-2.2