Project Paper

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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 states [7]–[9]. Only one machine state can be active at a
societies are becoming more and more dependent on the given instant. It is done as a function of the inputs
automated machines. It is in order to cope with their fast-going combination, previous sate and the system memory elements
lives. Modern automated machines adapt their sequence of status [7].
actions depending on their environment and events. The FSM The FSM can be modeled by either FSM model
(Finite state machine) is used to mathematically express those designing or by ASM (Algorithmic State Machines) method,
sequences of actions or instructions. In this article two FSM which is mainly used for designing FSMs and for digital
machines types, Moore and Mealy, are discussed. Showing
integrated circuits diagram representation by flowcharts
different results in order to demonstrate the importance of
methodology [12], [13]. ASM shares conceptual similarities
FSM modeling. An edge detector circuit is designed by
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
command signals that supervises the operations held in the Figure 1. Modulo three counters
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 other where knowledge is represented in the states and actions are
part deals with the design of the operation supervisor, the constrained by rules [17]. The general FSM model is shown
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 finite- Branch explains the change from present state to next state.
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 a
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


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 a
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 shown
Figure 6. The state machine diagram of Mealy machine based edge detector 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


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


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 a

You might also like