101 Sequence Detector Using Moore Machine

Posted : admin On 1/25/2022

In the theory of computation, a Moore machine is a finite-state machine whose output values are determined only by its current state. This is in contrast to a Mealy machine, whose (Mealy) output values are determined both by its current state and by the values of its inputs. The Moore machine is named after Edward F. Moore, who presented the concept in a 1956 paper, “Gedanken-experiments on Sequential Machines.”[1]

Sequence Detector Moore AIM: Design a controller that detects the overlapping sequence “0X01” in a bit stream using moore machine. DESIGN Verilog Program- Sequence Detector 0x01 Moore implementation `timescale 1ns / 1ps ///// // Company: TMP. A sequence detector is a sequential state machine. In a Moore machine, output depends only on the present state and not dependent on the input (x). Hence in the diagram, the output is written with the states. The state diagram of a moore machine for a 101 detector is.

Formal definition[edit]

A Moore machine can be defined as a 6-tuple(Q,q0,Σ,O,δ,G){displaystyle (Q,q_{0},Sigma ,O,delta ,G)} consisting of the following:

  • A finite set of statesQ{displaystyle Q}
  • A start state (also called initial state) q0{displaystyle q_{0}} which is an element of Q{displaystyle Q}
  • A finite set called the input alphabetΣ{displaystyle Sigma }
  • A finite set called the output alphabetO{displaystyle O}
  • A transition functionδ:Q×ΣQ{displaystyle delta :Qtimes Sigma rightarrow Q} mapping a state and the input alphabet to the next state
  • An output function G:QO{displaystyle G:Qrightarrow O} mapping each state to the output alphabet

A Moore machine can be regarded as a restricted type of finite-state transducer.

Visual representation[edit]


State transition table is a table showing relation between an input and a state.[clarification needed]


The state diagram for a Moore machine or Moore diagram is a diagram that associates an output value with each state.Moore machine is an output producer.

Relationship with Mealy machines[edit]

As Moore and Mealy machines are both types of finite-state machines, they are equally expressive: either type can be used to parse a regular language.

The difference between Moore machines and Mealy machines is that in the latter, the output of a transition is determined by the combination of current state and current input (S×Σ{displaystyle Stimes Sigma } as the input to G{displaystyle G}), as opposed to just the current state (S{displaystyle S} as the input to G{displaystyle G}). When represented as a state diagram,

  • for a Moore machine, each node (state) is labeled with an output value;
  • for a Mealy machine, each arc (transition) is labeled with an output value.

Every Moore machine M{displaystyle M} is equivalent to the Mealy machine with the same states and transitions and the output function G(s,σ)GM(δM(s,σ)){displaystyle G(s,sigma )rightarrow G_{M}(delta _{M}(s,sigma ))}, which takes each state-input pair (s,σ){displaystyle (s,sigma )} and yields GM(δM(s,σ)){displaystyle G_{M}(delta _{M}(s,sigma ))}, where GM{displaystyle G_{M}} is M{displaystyle M}'s output function and δM{displaystyle delta _{M}} is M{displaystyle M}'s transition function.

However, not every Mealy machine can be converted to an equivalent Moore machine. Some can be converted only to an almost equivalent Moore machine, with outputs shifted in time. This is due to the way that state labels are paired with transition labels to form the input/output pairs. Consider a transition sisj{displaystyle s_{i}rightarrow s_{j}} from state si{displaystyle s_{i}} to state sj{displaystyle s_{j}}. The input causing the transition sisj{displaystyle s_{i}rightarrow s_{j}} labels the edge (si,sj){displaystyle (s_{i},s_{j})}. The output corresponding to that input, is the label of state si{displaystyle s_{i}}.[2] Notice that this is the source state of the transition. So for each input, the output is already fixed before the input is received, and depends solely on the present state. This is the original definition by E. Moore. It is a common mistake to use the label of state sj{displaystyle s_{j}} as output for the transition sisj{displaystyle s_{i}rightarrow s_{j}}.


Types according to number of inputs/outputs.




Simple Moore machines have one input and one output:

  • edge detector using XOR
  • clocked sequential systems (a restricted form of Moore machine where the state changes only when the global clock signal changes)

Most digital electronic systems are designed as clocked sequential systems. Clocked sequential systems are a restricted form of Moore machine where the state changes only when the global clock signal changes. Typically the current state is stored in flip-flops, and a global clock signal is connected to the 'clock' input of the flip-flops. Clocked sequential systems are one way to solve metastability problems. A typical electronic Moore machine includes a combinational logic chain to decode the current state into the outputs (lambda). The instant the current state changes, those changes ripple through that chain, and almost instantaneously the output gets updated. There are design techniques to ensure that no glitches occur on the outputs during that brief period while those changes are rippling through the chain, but most systems are designed so that glitches during that brief transition time are ignored or are irrelevant. The outputs then stay the same indefinitely (LEDs stay bright, power stays connected to the motors, solenoids stay energized, etc.), until the Moore machine changes state again.

Worked Example[edit]

101 Sequence Detector

A sequential network has one input and one output. The output becomes 1 and remains 1 thereafter when at least two 0's and two 1's have occurred as inputs.

Example moore machine

A moore machine with nine states for the above description is shown on the right. The initial state is state A, and the final state is state I. The state table for this example is as follows:

Current stateInputNext stateOutput


More complex Moore machines can have multiple inputs as well as multiple outputs.

101 Sequence Detector Using Moore Machine Pdf


In Moore's paper 'Gedanken-experiments on Sequential Machines',[1] the (n;m;p){displaystyle (n;m;p)} automata (or machines) S{displaystyle S} are defined as having n{displaystyle n} states, m{displaystyle m} input symbols and p{displaystyle p} output symbols. Nine theorems are proved about the structure of S{displaystyle S}, and experiments with S{displaystyle S}. Later, 'S{displaystyle S} machines' became known as 'Moore machines'.

At the end of the paper, in Section 'Further problems', the following task is stated:

Another directly following problem is the improvement of the bounds given at the theorems 8 and 9.

Moore's Theorem 8 is formulated as:

Given an arbitrary (n;m;p){displaystyle (n;m;p)} machine S{displaystyle S}, such that every two of its states are distinguishable from one another, then there exists an experiment of length n(n1)2{displaystyle {tfrac {n(n-1)}{2}}} which determines the state of S{displaystyle S} at the end of the experiment.

In 1957, A. A. Karatsuba proved the following two theorems, which completely solved Moore's problem on the improvement of the bounds of the experiment length of his 'Theorem 8'.

Theorem A. If S{displaystyle S} is an (n;m;p){displaystyle (n;m;p)} machine, such that every two of its states are distinguishable from one another, then there exists a branched experiment of length at most (n1)(n2)2+1{displaystyle {tfrac {(n-1)(n-2)}{2}}+1} through which one may determine the state of S{displaystyle S} at the end of the experiment.

Theorem B. There exists an (n;m;p){displaystyle (n;m;p)} machine, every two states of which are distinguishable from one another, such that the length of the shortest experiments establishing the state of the machine at the end of the experiment is equal to (n1)(n2)2+1{displaystyle {tfrac {(n-1)(n-2)}{2}}+1}.

Theorems A and B were used for the basis of the course work of a student of the fourth year, A. A. Karatsuba, 'On a problem from the automata theory', which was distinguished by testimonial reference at the competition of student works of the faculty of mechanics and mathematics of Moscow Lomonosow State University in 1958. The paper by Karatsuba was given to the journal Uspekhi Mat. Nauk on 17 December 1958 and was published there in June 1960.[3]

Until the present day (2011), Karatsuba's result on the length of experiments is the only exact nonlinear result, both in automata theory, and in similar problems of computational complexity theory.

See also[edit]

101 Sequence Detector Using Moore Machine Tools


  1. ^ abMoore, Edward F (1956). 'Gedanken-experiments on Sequential Machines'. Automata Studies, Annals of Mathematical Studies. Princeton, N.J.: Princeton University Press (34): 129–153.
  2. ^Lee, Edward Ashford; Seshia, Sanjit Arunkumar (2013). Introduction to Embedded Systems (1.08 ed.). UC Berkeley: Lulu.com. ISBN9780557708574. Retrieved 1 July 2014.CS1 maint: discouraged parameter (link)
  3. ^Karatsuba, A. A. (1960). 'Solution of one problem from the theory of finite automata'. Uspekhi Mat. Nauk (15:3): 157–159.

Further reading[edit]

  • Conway, J.H. (1971). Regular algebra and finite machines. London: Chapman and Hall. ISBN0-412-10620-5. Zbl0231.94041.CS1 maint: discouraged parameter (link)
  • Moore E. F. Gedanken-experiments on Sequential Machines. Automata Studies, Annals of Mathematical Studies, 34, 129–153. Princeton University Press, Princeton, N.J.(1956).
  • Karatsuba A. A. Solution of one problem from the theory of finite automata. Usp. Mat. Nauk, 15:3, 157–159 (1960).
  • Karatsuba A. A. Experimente mit Automaten (German) Elektron. Informationsverarb. Kybernetik, 11, 611–612 (1975).
  • Karatsuba A. A. List of research works.

External links[edit]

  • Media related to Moore machine at Wikimedia Commons
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Moore_machine&oldid=980515476'

Last time, I presented a Verilog code together with Testbench for Sequence Detector using FSM. The sequence being detected was '1011'.

This VHDL project presents a full VHDL code for Moore FSM Sequence Detector. A VHDL Testbench is also provided for simulation. The sequence to be detected is '1001'.

The Moore FSM state diagram for the sequence detector is shown in the following figure.

VHDL code for Moore FSM Sequence Detector is designed based on Moore FSM's state diagram and block diagram:

VHDL Testbench for Sequence Detector using Moore FSM:

Simulation Waveform for Moore FSM Sequence Detector in VHDL:

As shown in the simulation waveform of the VHDL Moore FSM sequence detector, the detector output only goes high when the sequence '1001' is detected.
Verilog code for Moore FSM Sequence Detector: here.
Recommended VHDL projects:
1. What is an FPGA? How VHDL works on FPGA
2. VHDL code for FIFO memory
3. VHDL code for FIR Filter
4. VHDL code for 8-bit Microcontroller
5. VHDL code for Matrix Multiplication
6. VHDL code for Switch Tail Ring Counter
7. VHDL code for digital alarm clock on FPGA
8. VHDL code for 8-bit Comparator
9. How to load a text file into FPGA using VHDL
10. VHDL code for D Flip Flop
11. VHDL code for Full Adder
12. PWM Generator in VHDL with Variable Duty Cycle
13. VHDL code for ALU
14. VHDL code for counters with testbench
15. VHDL code for 16-bit ALU
16. Shifter Design in VHDL
17. Nonlinear Lookup Table Implementation in VHDL
18. Cryptographic Coprocessor Design in VHDL
20. VHDL Code for Clock Divider on FPGA
21. Generate clock enable signal in VHDL
22. VHDL code for debouncing buttons on FPGA
23. VHDL code for Traffic light controller
24. VHDL code for a simple 2-bit comparator
25. VHDL code for a single-port RAM
26. VHDL code for Car Parking System using FSM

Sequence Detector Examples

111 Sequence Detector

27. VHDL coding vs Software Programming

101 Sequence Detector Using Moore Machine Design

28. VHDL code for MIPS Processor
29. VHDL code for Moore FSM Sequence Detector
30. VHDL code for Seven-Segment Display on Basys 3 FPGA