---
description: In this lab, we are going to talk about state machines, and how to implement state machines using registers and flip-flops.
---
<h1 style='border: none'><center>Digital Design Lab 9</center></h1>
<h2 style='border: none'><center>More about State Machines</center></h2>
<h5><center>The Islamic University of Gaza<br>Engineering Faculty<br>Department of Computer Engineering</center></h5>
<h6>Author: Mohammed Nafiz ALMadhoun<span style="float:right">2021/12/14</span></h6>
---
## Introduction
<p style='text-align:justify'>
In this lab, we are going to talk about state machines, and how to implement state machines using registers and flip-flops.
</p>
## State Machines
The state machine is a sequence of states which defines the current state, and what has to be done to move from one state to another.
### Type of State Machines
As you might know, there are two types of state machines, the first one is mealy state machines (In which the inputs affect the outputs directly), and Moore state machines (In which only the state affect the outputs).
<center>
![Mealy, Moore state machines [1]](https://i.imgur.com/5EB1ZQu.png =400x)
Mealy, Moore state machines [^1]
</center>
Note that you could design any state machine using Moore, or mealy designs, in general, the mealy is easier but it introduces a lot of errors in high-speed machines.
<div style="page-break-after: always;"></div>
### State digram
In this section, we will design a `101` sequence detector, first, we will design it using Moore state machine
<center>

101 Sequance Detector Moore
</center>
<center>

101 Sequance Detector Mealy
</center>
Notice that in the mealy design, the input and the states are not synchronized, so usually in a mealy state machine, we will connect the inputs to a d-latch before connecting it to the state machine itself.
<div style="page-break-after: always;"></div>
## Lab Tasks
### Task 1: Money Counter!
Imagine that you have a device with three sensors, one for each coin type (1NIS, 2NIS, 5NIS), your task is to implement the state machine that counts the final amount, you could use a regular state machine, or come up with a design that implements in using a counter!
The device might look something like this:
<center>

Dummy Coins Counter.
</center>
And you have 3 sensors for each tube (1NIS, 2NIS, 5NIS).
Hope you enjoyed this semester.
[^1]: Digital Design - Morris Mano 5th
###### tags: `Digital Design` `Digital` `IUG` `Computer Engineering`
<center>End Of Lab 9</center>