Project Paper

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

2017 IEEE 2nd International Conference on Signal and Image Processing

A VHDL Based Moore and Mealy FSM Example for Education

Sultana Alsubaei1, S. M. Qaisar1, W. Alhalabi2


1
Electrical and Computer Engineering Department, Effat University, Jeddah, KSA
2
Computer Science Department, Effat University, Jeddah, KSA
e-mail: 1saalsubaie@effat.edu.sa, 1sqaisar@effatuniversity.edu.sa

Abstract—With recent technological advancements, modern


societies are becoming more and more dependent on the
states [7]–[9]. Only one machine state can be active at a
automated machines. It is in order to cope with their fast-going given instant. It is done as a function of the inputs
lives. Modern automated machines adapt their sequence of combination, previous sate and the system memory
actions depending on their environment and events. The FSM elements status [7].
(Finite state machine) is used to mathematically express those The FSM can be modeled by either FSM model
sequences of actions or instructions. In this article two FSM designing or by ASM (Algorithmic State Machines) method,
machines types, Moore and Mealy, are discussed. Showing which is mainly used for designing FSMs and for digital
different results in order to demonstrate the importance of integrated circuits diagram representation by flowcharts
FSM modeling. An edge detector circuit is designed by methodology [12], [13]. ASM shares conceptual similarities
employing both Moore and Mealy machines. It is a FSM design with FSM modeling except that ASM is easier for
example, can be used for students concepts building and understanding due to its informality as shown on Figure 1,
demonstration. These designs are implemented in VHDL. A illustrating modulo three counters [14]. ASM can be
comparison is also made based on both implementations. compiled by using ASM++ compiler. Moreover, certain
other interesting state machine synthesizers examples are
Keywords-FSM,; automation; VHDL;, Xilinx-ISE;, timing available in the literature [15], [16].
diagram; computer aided design

I. INTRODUCTION
Because of ever wanted features, the DSP (Digital
Signal Processing) has replaced the analog processing in
most of the modern systems [1]–[3]. A smart digital signal
processing design can lead towards an efficient solution and
vice versa [1]–[3].
Information in digital systems is classified as, data or
control information [4]. Data is known as discrete element
of information that can be altered in order to preform
arithmetic, logic and other data-processing tasks which is
implemented with digital components such as decoders,
adders and counters [5]. While control information provides
Figure 1. Modulo three counters
command signals that supervises the operations held in the
data section to ensure the desired output [4], [5].
There are two distinct modules of all digital processing II. THE FSM PRINCIPLE
system. One is dealing with the performance of data The FSM is typically used as a type of control system
processing by designing the suitable digital circuit. The where knowledge is represented in the states and actions are
other part deals with the design of the operation supervisor, constrained by rules [17]. The general FSM model is shown
the control circuit [5]. on Figure 2.
The control logic uses status conditions from the data Figure 2, illustrates the form and function of a state
processor to serve as decision variables to determine the machine. Usually drawn as a bubble-and-arrow diagram.
sequence of control signals. The control logic provides a State is a uniquely identifiable set of values measured at
sequence of time signals, which is essential for operation various points in a digital system. Where next State is the
initiation in the data processor, and also the determination of state to which the state machine makes the next transition,
the next state of the control subsystem [6]. determined by the inputs present when the device is clocked.
Finite state machine FSM [7]–[9] or also known as Branch explains the change from present state to next state.
finite- state automaton FSA [10], [11]. The word automaton For any given state, there is a finite number of possible next
expresses a machine that functions based on already stored states. On each clock cycle, the state machine branches to
and determined coded instructions, with a wide range of the next state. One of the possible next states becomes the
programmed capabilities based on different circumstances new present state, depending on the inputs present on the
[10], [11]. It simplifies the meaning of FSM to be a clock cycle [7], [17].
mathematical model of computation that is based on a
hypothetical machine that consists of a finite number of

978-1-5386-0969-9/17/$31.00 ©2017 IEEE


rized licensed use limited to: Vignan's Foundation for Science Technology & Research (Deemed to be University). Downloaded on October 12,2023 at 10:43:09 UTC from IEEE Xplore. Restrictions
456

rized licensed use limited to: Vignan's Foundation for Science Technology & Research (Deemed to be University). Downloaded on October 12,2023 at 10:43:09 UTC from IEEE Xplore. Restrictions
the inputs present on the triggering edge of clock [17]. The
Mealy machine principle is illustrated with the help of a
diagram, shown on Figure 4 [17]. The Outputs are shown on
transitions since they are determined in the same way as is
the next state.

Figure 2. The general FSM model

Figure 4. Mealy state machine diagram [17].

III. ILLUSTRATING EXAMPLE


In order to illustrate the FSM design process a Rising
Edge Detector circuit is designed. This circuit is frequently
employed in a variety of modern applications and act as a
signal level or state change indicator [21]–[23]. This circuit
generates a one clock cycle pulse, a tick, when the input
Figure 3. Moore state machine diagram [17]. signal changes its logic from low to high. This functionality
is frequently employed to indicate the low-to-high transition
There are two main categories of FSM. The first one is of a slow time-varying input signal. The circuit is designed
deterministic FSM, meaning that for a given input and the by employing both Moore and Mealy machines. These
current state, the state transition can be predicted [17]. The designs are implemented in VHDL. A comparison of both
second type is Non-deterministic finite state machine. In this implementations is also made.
case, for a given input and current state the state transition is The state machine diagram of a Moore machine based
not predictable [17]. The non-deterministic finite state edge detector implementation is shown on Figure 5.
machine is employed in the case of event driven systems
control units design [18], [19], [25], [26].
The deterministic and non-deterministic FSMs are
further classified as transducers, acceptors, classifiers and
sequencers [20]. In the automat and control applications,
two FSM types named as Mealy and Moore machines are
frequently employed. A brief description of the Moore and
Mealy machines is provided in the following subsections.
A. The Moore Machines
The Moore machine is a FSM whose output is
determined only as a function of the present state [7], [17].
The output has no relation with the input. The Moore
machine principle is illustrated with the help of a diagram,
shown on Figure 3 [17].
In Figure 3, the Moore State machine output is shown
inside the State bubble, because the output remains the same
as long as the state machine remains in that state. The output Figure 5. The state machine diagram of Moore machine based edge
can be arbitrarily complex but must be the same every time detector [24].
the machine enters in that state [17].
B. The Mealy Machines In Figure 5, the zero and one states show that the input
signal has been low and high for a while. The rising edge
In the case of Mealy machine the output is determined as occurs when the input changes to high in the zero state. The
a function of the current input and present state [7], [17]. FSM moves to the edge state and the output, tick, is asserted
Therefore, it is capable of generating a variety of different in this state.
output patterns for the same state. It is done as a function of

4
rized licensed use limited to: Vignan's Foundation for Science Technology & Research (Deemed to be University). Downloaded on October 12,2023 at 10:43:09 UTC from IEEE Xplore. Restrictions
The state machine diagram of a Mealy machine based
edge detector is shown on Figure 6. The zero and one states
have similar meaning. When the FSM is in the zero state
and the input changes to high, the output is asserted
immediately. The FSM moves to the one state at the rising
edge of the next clock and the output is de-asserted.

Figure 8. The Moore machine based edge detector technology schematic.

Figure 9. The Mealy machine based edge detector RTL schematic.

Both implemented circuits functionality is also verified


with the Xilinx-ISim. The timing simulation results obtained
for the Moore and the Mealy based edge detectors are
Figure 6. The state machine diagram of Mealy machine based edge detector shown respectively on Figures 10 and 11.
[24].

For both Moore and Mealy machine based designs, the


circuit are implemented in VHDL and are synthesized with
the Xilinx-xst for the XC6LXT240T component from the
Virtex-6 family. The circuit block diagram is shown on
Figure 7. The Moore machine based circuit technology
schematic and the Mealy machine based circuit RTL Figure 10: The Moore machine based edge detector Timing Diagram.
(Register Transfer Level) schematic are respectively shown
on Figures 8 and 9.

Figure 11. The Mealy machine based edge detector Timing Diagram.

Figures 10 and 11 show that both Moore and Mealy


machine based designs can generate a short tick at the rising
edge of the input signal. However, there are still certain
understandable differences. The Mealy machine-based
design requires fewer states and responds faster (cf. Figures
5, 6, 8 and 9), but the width of its output may vary and input
glitches may be passed to the output [24]. The choice
Figure 7. The edge detector Block Diagram, generated with Xilinx-ISE. between the two designs depends on the system module,
employs the output of edge detector. Most of the time the
subsystem is a synchronous system that shares the same
clock signal, employed by the edge detector. In this case, the
edge detector output is sampled only at the rising edge of
the clock, the width and glitches do not matter as long as the
output signal is stable around the edge [24]. As the Mealy
machine based circuit responds faster than the Moore

4
rized licensed use limited to: Vignan's Foundation for Science Technology & Research (Deemed to be University). Downloaded on October 12,2023 at 10:43:09 UTC from IEEE Xplore. Restrictions
machine based circuit. Therefore, the Mealy machine based [5] M. M. Mano, Digital design. EBSCO Publishing, Inc., 2002.
edge detectors are preferred for the synchronous system [6] R. Vemu, A. Jas, J. A. Abraham, R. Galivanche, and S. Patil, “A low-
implementations. However, in the case of asynchronous cost concurrent error detection technique for processor control logic,”
system implementations, the employment of Mealy machine presented at the Proceedings of the conference on Design, automation
and test in Europe, 2008, pp. 897–902.
based edge detectors can lead towards the system instability [7] M. M. Mano, Digital design. EBSCO Publishing, Inc., 2002.
[24]. Therefore, in this case, because of a consistent width [8] Chaudhary, Ankit, et al. "Intelligent approaches to interact with
tick generation, the Moore based edge detectors machines using hand gesture recognition in natural way: a survey."
employment is preferred over the Mealy based counter arXiv preprint arXiv:1303.2292 (2013).
circuits [24]. [9] El-Maleh, Aiman H. "Majority-based evolution state assignment
algorithm for area and power optimisation of sequential circuits." IET
Computers & Digital Techniques 10.1 (2016): 30-36.
IV. CONCLUSION [10] Omlin, Christian W., and C. Lee Giles. "Training second-order
recurrent neural networks using hints." Proc. 9th Int. Workshop
In recent era, we are becoming more dependent on the Machine Learning. 2014.
automated machines. Modern automated machines adapt [11] Sales, Daniel O., et al. "Adaptive finite state machine based visual
their sequence of actions depending on their environment autonomous navigation system." Engineering Applications of
and events. The FSM (Finite state machine) is extensively Artificial Intelligence 29 (2014): 152-162.
[12] Cho, Heumpil, and Earl E. Swartzlander. "Adder designs and
employed for a systematic design and mathematical analyses for quantum-dot cellular automata." IEEE Transactions on
representation of the sophisticated automates. In this context, Nanotechnology 6.3 (2007): 374-383.
an introduction of the FSM principle has been made. The [13] W. Grieskamp, Y. Gurevich, W. Schulte, and M. Veanes,
FSM categories like deterministic and non-deterministic “Generating finite state machines from abstract state machines,”
FSMs are discussed. Moore and Mealy machines based FSM ACM SIGSOFT Software Engineering Notes, vol. 27, no. 4, pp. 112–
122, 2002.
design principles are described. An edge detector has been [14] S. J. Baylor, P. F. Corbett, B. G. Fitch, and M. E. Giampapa, “Using
designed based on Moore and Mealy machines for students virtual disks for disk system checkpointing,” May 1997.
concepts building and demonstration. These designs have [15] Aluthwala, Pasindu, et al. "A simple digital architecture for a
been implemented in VHDL. The circuits are successfully harmonic-cancelling sine-wave synthesizer." Circuits and Systems
synthesized with the Xilinx-XST for the XC6LXT240T (ISCAS), 2014 IEEE International Symposium on. IEEE, 2014.
[16] E. Börger and R. Stärk, Abstract state machines: a method for high-
component from the Virtex-6 family. The synthesized circuit
level system design and analysis. Springer Science & Business
block diagram has been presented. Moreover, the Moore Media, 2012.
machine based circuit technology schematic and the Mealy [17] Jason Brownlee, “http://ai-depot.com/FiniteStateMachines/FSM-
machine based circuit RTL schematics have also been Background.html.”
shown. The designed circuits functionality is also verified [18] Al-Yamani, N., Qaisar, S., Alhazmi, A., Mohammad, S., & Subasi,
with the help of Xilinx-ISim based timing simulations. The A. (2016, December). An event driven surveillance system. In
Electronic Devices, Systems and Applications (ICEDSA), 2016 5th
simulation results have been shown on Figures 10 and 11. It International Conference on (pp. 1-4). IEEE.
confirms a proper functionality of the designed edge [19] S. M. Qaisar, L. Fesquet, and M. Renaudin, “Adaptive rate filtering a
detectors. A comparison between both Moore and Mealy computationally efficient signal processing approach,” Signal
machines based edge detector implementations has been Processing, vol. 94, pp. 620–630, 2014.
made. It has been shown that for the implemented edge [20] R. Keller, “Classifiers, Acceptors, Transducers, and Sequencers,”
Computer Science: Abstraction to Implementation. Harvey Mudd
detectors, the Mealy machine based implementation is faster College, p. 480, 2001.
than the Moore machine one. However, the Mealy machine [21] R. Etienne-Cummings, J. Van der Spiegel, and P. Mueller, “A focal
based implementation can only be employed in the plane visual motion measurement sensor,” IEEE Transactions on
synchronous systems. On other hand, the Moore machine Circuits and Systems I: Fundamental Theory and Applications, vol.
based implementation is suitable for both synchronous and 44, no. 1, pp. 55–66, 1997.
[22] S.-J. Wei and K.-Y. Chen, “Circuit and method for preventing
asynchronous systems. Moore and Mealy based machines runaway in a phase lock loop,” Apr. 2002.
design of other elementary circuits like period counter, [23] B. J. Williams, K. Dalmia, and T. D. Little, “Linearized digital phase-
frequency counter, code converters, etc. is a prospect. locked loop,” Mar. 2004.
[24] P. P. Chu, FPGA prototyping by VHDL examples: Xilinx Spartan-3
REFERENCES version. John Wiley & Sons, 2011.
[25] Qaisar, S.M., 2011. Electronic management system for
[1] E. C. Ifeachor and B. W. Jervis, Digital signal processing: a
rechargeable battery has measuring circuit measuring parameter
practical approach. Pearson Education, 2002.
determining variation of parameter transmitting data to electronic
[2] Ingle, Vinay K., and John G. Proakis. Digital Signal Processing
processing unit if variation is higher than predetermined threshold.
Using MATLAB: A Problem Solving Companion. Cengage
[26] Qaisar, Saeed Mian, Reda Yahiaoui, and Tijani Gharbi. "An
Learning, 2016.
efficient signal acquisition with an adaptive rate A/D conversion."
[3] Smith, Steven. Digital signal processing: a practical guide for
Circuits and Systems (ICCAS), 2013 IEEE International
engineers and scientists. Newnes, 2013.
Conference on. IEEE, 2013.
[4] Fort, Blair, et al. "Automating the design of processor/accelerator
embedded systems with legup high-level synthesis." Embedded and
Ubiquitous Computing (EUC), 2014 12th IEEE International
Conference on. IEEE, 2014.

4
rized licensed use limited to: Vignan's Foundation for Science Technology & Research (Deemed to be University). Downloaded on October 12,2023 at 10:43:09 UTC from IEEE Xplore. Restrictions

You might also like