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

‫‪Ministry of Higher Education‬‬ ‫وزارة التعليم العالي والبحث‬

‫‪And Scientific Researches‬‬ ‫العلمي‬


‫‪Baghdad University‬‬ ‫جامعة بغداد‬
‫‪Al-Khwarizmi College of‬‬
‫كلية هندسة الخوارزمي‬
‫‪Engineering‬‬ ‫قسم هندسة الطب الحياتي‬

‫‪State Machines‬‬

‫مقدم من قبل الطالب (طه عمر طه)‬


‫الى االستاذ (دكتور ابراهيم)‬
‫ضمن مادة (‪)Biomedical circuits and electronics‬‬
‫الفصل الدراسي الثاني‬

‫المرحلة (الرابعة) ‪ /‬الدراسة (الصباحية)‬


‫‪2020‬‬
Table of contents

Introduction ...…………. …………………....…….. (1)

What Is a State Machine …………………….…….. (2)

Types of State Machine ….…………………...…..... (4)

Moore Machine …..…….……………………...….... (4)

Mealy Machine ………………………………..…..... (5)

Harel statecharts machine ……………….…….…... (6)

UML State Machine ………………………….....…... (6)

differences between Machines…………….…......…... (7)

References ………………………………..…………... (8)


Introduction
State machine designs are widely used for sequential control logic, which forms
the core of many digital systems. State machines are required in a variety of
applications covering a broad range of performance and complexity; low-level
controls of microprocessor-to- VLSI-peripheral interfaces, bus arbitration, and
timing generation in conventional microprocessors, custom bit-slice
microprocessors, data encryption and decryption, and transmission protocols are
but a few examples. Typically, the details of control logic are the last to be
settled in the design cycle, since they are continuously affected by changing
system requirements and feature enhancements. Programmable logic is a
forgiving solution for control logic design because it allows easy modifications
to be made without disturbing the PC board layout. Its flexibility provides an
escape valve that permits design changes without impacting time-to-market.

A majority of registered PAL device applications are sequential control designs


where state machine design techniques are employed. As technology advances,
new high-speed and high-functionality devices are being introduced which
simplifies the task of state machine design. A broad range of different
functionality-and-performance solutions is available for state machine design.

1
What Is a State Machine?

A state machine is a digital device that traverses through a


predetermined sequence of states in an orderly fashion. A state is a
set of values measured at different parts of the circuit. A simple state
machine can consist of PALdevice based combinatorial logic, output
registers, and buried (state) registers. The state in such a sequencer is
determined by the values stored in the buried and/or

output registers. A general form of a state machine can be depicted as


a device shown in Figure 1. In addition to the device inputs and
outputs, a state machine consists of two essential elements:
combinatorial logic and memory (registers). This is similar to the
registered counter designs discussed previously, which are essentially
simple state machines. The memory is used to store the state of the
machine. The combinatorial logic can be viewed as two distinct
functional blocks: the next state decoder and the output decoder
(Figure 2). The next state decoder determines the next state of the
state machine while the output decoder generates the actual outputs.
Although they perform two distinct functions, these are usually
combined into one combinatorial logic array as in Figure 1.

2
Figure1: Block Diagram of a Simple State Machine.

Figure2: State Machine, with Separate Output and Next State Decoders.

The basic operation of a state machine is twofold:

1. It traverses through a sequence of states, where the next state is determined


by the next state decoder, depending upon the present state and input conditions.

2. It provides sequences of output signals based upon state transitions. The


outputs are generated by the output decoder based upon present state

and input conditions.

3
Using input signals for deciding the next state is also known as branching. In
addition to branching, complex sequencers provide the capability of repeating
sequences (looping) and subroutines. The transitions from one state to another
are called control sequencing and the logic required for deciding the next states
is called the transition function (Figure 2). The use of input signals in the
decision-making process for output generation determines the type of a state
machine.

There are two widely-known types of state machines:

Mealy and Moore. Moore state machine outputs are a function of the present
state only. In the more general Mealy-type state machines, the outputs are
functions of both the state and the input signals. The logic required is known as
the output function. For either type, the control sequencing depends upon both
states and input signals. Most practical state machines are synchronous
sequential circuits that rely on clock signals to trigger the state transitions. A
single clock is connected to all of the state and output edge-triggered flip-flops,
which allows a state change to occur on the rising edge of the clock.
Asynchronous state machines are also possible, which utilize the propagation
delay in combinatorial logic for the memory function of the state machine. Such
machines are highly susceptible to hazards, hard to design, and are seldom used.
In our discussion, we will focus solely on sequential state machines.

Types of State Machines

1. Moore machines

In automata theory, there are two basic types of finite-state machines (FSM).
One of those is called the Moore machine, named after its inventor Edward
Moore, who introduced the concept in 1956. Moore machines consist of states

4
and transitions. States can produce outputs, and the output is determined solely
by the current state, not by any input.

Figure3: Moore State Machines.

Advantages and disadvantages

1. Advantage of the Moore model is easy to code, it is


simplification of the design.
2. It leads to slower bcoz of clocking the output but leads
to stable output.
3. Moore will have more number of states compared to mealy.

2. Mealy machines

Mealy machines were invented by George H. Mealy in 1955. In comparison


with Moore machines, Mealy machines produce outputs only on transitions and
not in states. This often results in state diagrams with fewer states because more
logic can be put on transitions. Indeed, automata theory states that you can
always translate a Moore machine into a Mealy machine and vice versa, without
losing any expressiveness.

5
Figure4: Mealy State Machines.

Advantages and disadvantages

1. Mealy leads to a reduction in the number of states2. Mealy is complicated


compared to Moore.
3. Mealy is faster bcoz output will change as soon as the input
changes, but it leads to asynchronous outputs leading to
metastability.

3. Harel statecharts
Although Mealy machines can already reduce the number of required states, for
complex systems such automatons get easily unmanageable.

So basically Harel statecharts are Mealy/Moore machines extended by further


concepts that allow us to model complex systems practically.

4. The present age: UML state machines

UML state machines are based on the statechart notation introduced by David
Harel. Furthermore, the UML extends the notation of Harel statecharts by

6
object-oriented principles. Mapping this to our light switch example, in UML
we can model the possible actions of the light switch as a type with
operations turnOn(), turnOff(), setBrightness(value), and so on.

Advantages

1. Most-Used and Flexible

2. The Software Architecture Must Be Communicated Effectively

3. The abundance of UML Tools

Disadvantages

1. Formal Notation is Not Necessary

2. Ascending Degree of Complexity

3. Not Necessary in ‘Architecture-Indifferent Design’

The following table illustrates the differences between the previously described
types at a glance:

7
References

1. Gurevich, Yuri. "Sequential abstract state machines capture sequential


algorithms." ACM Transactions on Computational Logic (TOCL) 1.1 (2000):
77-111.

2. Schäfer, Timm, Alexander Knapp, and Stephan Merz. "Model checking UML
state machines and collaborations." Electronic Notes in Theoretical Computer
Science 55.3 (2001): 357-369.

3. Agrawal, Aditya, et al. "Restricting state diagrams with a set of predefined


requirements to restrict a state diagram to a state diagram of a Moore or mealy
machine." U.S. Patent No. 7,840,913. 23 Nov. 2010.

You might also like