In this lab, we are going to talk about Finite state machines, which are sequential systems, The FSMs are a generic approach for designing sequential systems, which will make your system easier to design, debug, and understand.
In this section, we are going to talk about the types of FSMs, and revise some of the concepts in the FSMs.
A Moore State Machine is a state machine that changes its outputs only by depending on the state register, which means changing the inputs will not change the output until the next clock.
Moore State Machine.[1]
A Mealy State Machine is a state machine that changes its outputs when the inputs changes, which means two different outputs could occur in the same clock cycle (If the input is not buffered).
Mealy State Machine.[1:1]
An asynchronous system (Mealy) is faster than a synchronous system (Moore) and uses less power at the cost of introducing errors, and complexity of the design.
In this course we will focus on Moore machines, note that also synthesisers will perform better when creating a synchronous system.
The state machine diagram is just a way of representing state machines, which will make it easier to read and interpolate.
You can use the open-source program qfsm
to design and simulate state machines.
http://qfsm.sourceforge.net/
Moore state machine digram.
Notice that this is a Moore state machine, the outputs will be drawn in the states, and each arrow represents the transition and its condition.
In this section, we will implement a Moore state machine using VHDL, we will follow a very know architecture which is creating three processes, this will make our code easier to read and understand.
This process will only create a register to hold our current state.
This process will convert our state code to output, notice that the process sensitivity list has only the present state and a Moore FSM the output will change only when the state changes.
Notice that this process will calculate the next state according to the current state and the outputs, thus you can find the inputs in the process sensitivity list.
Notice that we defined a State type:
Design a state machine that detects the input "0111", the state machine will have one input (which is a serial input), and one output that indicates if the input occurs for one clock cycle.
Note: Start detecting the input from left to right.
Well, this is a traditional state machine assignment, in this task, you should design a traffic light state machine which contains three lights (Green, Yellow, Red).
The state machine has 2 inputs, which indicate the following:
00
: Normal (Red -> Yellow -> Green -> Yellow -> Red).01
: Force Red.10
: Force Yellow.11
: Force Green.And three outputs (Green, Yellow, Red).
Notice that the period for Red and Green should be three times as Yellow (Which means you should repeat the states, or create a counter).
VHDL
IUG