summaryrefslogtreecommitdiffstats
path: root/Bachelor/Digitaltechnik 2/SS07/P6/abel.ex3.html
blob: 75bb32e71ecc4ae0c355926982bf93b08b614f8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<html><head>

   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.04 (Macintosh; I; PPC) [Netscape]">
   <meta name="Author" content="J. Van der Spiegel"><title>Example of a Mealy Machine: string recognizer</title></head><body>

<center>
<h1>
<i><font size="+1">University of Pennsylvania</font></i></h1></center>

<center><i><font size="+1">Department of Electrical Engineering</font></i></center>

<center></center>

<center><b>Finite State Machine implemented as a <font color="#0500e8">Synchronous</font>
Mealy Machine:</b></center>

<center></center>

<center><b>a non-resetting sequence recognizer.</b></center>


<p>The following state diagram (Fig. 1) describes the same finite state
machine as in the <a href="http://www.ese.upenn.edu/rca/software/abel/abel.ex1.html">previous example:</a> a sequence
detector with one input X and one output Z. The FSM asserts its output
Z when it recognizes the following input bit sequence: "1011". The machine
will keep checking for the proper bit sequence and does not reset to the
initial state after it has recognized the string. In contrast to the previous
example, the machine will be implemented as a synchronous Mealy Machine.
This will ensure that the output changes at the clock transition and will
prevent glitches which were possible with the Mealy Machine implementation
(see previous example).
</p><center>&nbsp;</center>

<center></center>

<center><img src="abel.ex3-Dateien/abel.gif" height="101" width="262"></center>


<p>Figure 1: State diagram, describing the sequence detector ("1011") implemented
as a Mealy machine. The number in italics underneath the states indicate
which part of the sequence the state remembers.

</p><p>This state diagram can be defined in ABEL code given in Listing 1. The
output is described with the "<font face="Courier">With</font>" keyword
to indicate that the output will change when the input goes to one. The
difference with the regular Mealy machine, is that the output Z is now
also clocked (see e.g. the statement, <font color="#000000"><font face="Courier"><font size="-1">[Q1,Q0,Z].CLK
=CLOCK). </font></font>Also, in the State Diagram section, the "WITH Z:=0"
makes use of the registered assignment ":=" operator.</font>

</p><p><font color="#000000">Listing 1: ABEL source code for the Mealy Machine
implementation of the sequence detector described in Fig. 1</font>
</p><ul><font size="-1"><font face="Courier"><font color="#000000">module Syncdet1</font></font></font></ul>

<ul><font face="Courier"><font color="#000000"><font size="-1">Title 'Sequence
Detector 1011 with a Synchronous Mealy Machine'</font></font></font>

<p><font face="Courier"><font color="#000000"><font size="-1">Declarations</font></font></font>
<br><font face="Courier"><font color="#000000"><font size="-1">"Input and
output signals</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">X, CLOCK, RST
PIN;</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">Z PIN istype
'reg';</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">Q1, Q0 PIN
istype 'reg';</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">"State register
definitions</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">" and assignments
of state values</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">SREG = [Q1,Q0];</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">S0 = [0,0];</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">S1 = [0,1];</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">S2 = [1,0];</font></font></font>
<br><font face="Courier"><font color="#000000"><font size="-1">S3 = [1,1];</font></font></font>

</p><p><font face="Courier"><font color="#000000"><font size="-1">Equations</font></font></font>
<br><font face="Courier"><font color="#000000"><font size="-1">"Define the
clock signal for the state machine</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">[Q1,Q0,Z].AR
= RST;</font></font></font>
<br><font face="Courier"><font color="#000000"><font size="-1">[Q1,Q0,Z].CLK
=CLOCK;</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">"Define state
diagram</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">STATE_DIAGRAM
SREG</font></font></font>

</p><p><font size="-1"><font face="Courier"><font color="#000000">STATE S0: IF
X THEN S1 ELSE S0;</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">STATE S1:
IF X THEN S1 ELSE S2;</font></font></font>
<br><font size="-1"><font face="Courier"><font color="#000000">STATE S2:
IF X THEN S3 ELSE S0;</font></font></font>
<br><font face="Courier"><font color="#000000"><font size="-1">STATE S3:
IF X THEN S1 WITH Z:=1; ELSE S2;</font></font></font>

</p><p><font face="Courier"><font color="#000000"><font size="-1">end Syncdet1</font></font></font></p></ul>
The ouput is specified with the "With" keyword. The corresponding simulation
is shown in Figure 2.
<center>&nbsp;</center>

<center>&nbsp;</center>

<center></center>

<center><img src="abel.ex3-Dateien/abel_002.gif" height="253" width="535"></center>

<center></center>

<center>Figure 2: Simulation of the sequence detector for "1011" described
with the state diagram of Fig. 1, implemented as a synchronous Mealy machine.
(Screen clip from Xilinx XACTstep(TM) Foundation software)</center>


<p>Notice that the output Z is valid after the positive clock edge (in
response to the input value just before the positive clock edge). The output
asserts at the positive clock edge when the input has gone through the
sequence "1011". Notice also that the glitch which was present in the non-synchronous
Mealy machine is gone.

</p><p>This timing in a synchronous Mealy machine is thus less critical than
in a non-synchronous machine. The price one pays for this, is additional
hardware. Making the output synchronous requires additional flip-flops
as is illustrated by the blue box (Output Registers) in the generic block
diagram of a synchronous Mealy machine in Figure 3.
</p><center></center>

<center><img src="abel.ex3-Dateien/abel_003.gif" height="121" width="333"></center>

<center></center>

<center>Figure 3: Synchronous Mealy Machine.</center>


<p>
</p><hr width="100%"><font size="-1">Back to ABEL Primer <a href="http://www.ee.upenn.edu/rca/software/abel/abel.primer.html#Contents">Contents</a>
| To to <a href="http://www.ee.upenn.edu/rca/software/xilinx/foundation/commistakes.html">Common
Mistakes</a> list | Go to the <a href="http://www.ee.upenn.edu/rca">EE
Undergraduate Lab</a> Homepage | Go to <a href="http://www.ee.upenn.edu/rca/software/xilinx.html">Xilinx
Lab Tutorial</a> Homepage | Go to the <a href="http://www.ee.upenn.edu/rca/software/xilinx/foundation/foundation.sch1.html">Foundation
Tutorial</a> page | Go to <a href="http://www.seas.upenn.edu/%7Eee200/">EE200
</a>or <a href="http://www.seas.upenn.edu/%7Eee200/lab/lab.html">EE200 Lab</a>
Homepage |</font>

<p>
</p><hr width="100%">Created by <a href="mailto:%20jan@ee.upenn.edu">J. Van der
Spiegel</a>: December 30, 1997; Updated by J. Van der Spiegel: December
30, 1997.

</body></html>