Docsity

State Machine Modelling for Sequence Detection in VHDL: Mealy and Moore Styles, Study Guides, Projects, Research of Physics

Partial preview of the text

Download State Machine Modelling for Sequence Detection in VHDL: Mealy and Moore Styles and more Study Guides, Projects, Research Physics in PDF only on Docsity!

EITF35 - Introduction to Structured VLSI Design

(Fall 2013)

State Machine Modelling

(Sequence Detector)

Teacher: Dr. Liang Liu

Lab Instructors :

Steffen Malkowsky

Hemanth Prabhu

Chenxin Zhang

Rakesh Gangarajaiah

v.1.0.

Abstract

This document describes basic state machines for both Mealy and Moore style.

This document is an instructional manual for lab work, which is part of course

EITF35 โ€œ Introduction to Structured VLSI โ€ at EIT, LTH. The lab will give the stu-

dents a stint to practice developing state machines in VHDL. A simulation that prove

functionality will be carried out using QuestaSim VHDL simulator. The files for

testbench and stimuli can be downloaded from the course homepage.

Contents 1 Sequence Detector for the sequence โ€˜1011โ€™ 3 1.1 Introduction................................. 3 1.2 Objectives.................................. 3 1.3 Design Example............................... 3 1.4 Testbench.................................. 6 2 Assignment 7

  • When in initial state (s0) the machine gets the input of โ€˜1โ€™ it jumps to the next state with the output equal to โ€™0โ€™. If the input is โ€˜0โ€™ it stays in the same state.
  • When in 2nd state (s1) the machine gets an input of โ€˜0โ€™ it jumps to the 3rd state with the output equal to โ€˜0โ€™. If it gets an input of โ€˜1โ€™ it stays in the same state.
  • When in the 3rd state (s2) the machine gets an input of โ€˜1โ€™ it jumps to the 4th state with the output equal to โ€˜0โ€™. If the input received is โ€˜0โ€™ it goes back to the initial state.
  • When in the 4th state (s3) the machine gets an input of โ€˜1โ€™ it jumps back to the 2nd state, with the output equal to โ€˜1โ€™. If the input received is โ€˜0โ€™ it goes back to the 3rd state. Following is the behaviour description of the sequencer for a Moore style implemen- tation and the state diagram is shown in figure 2:
  • In initial state (s0) the output of the detector is โ€˜0โ€™. When machine gets the input of โ€˜1โ€™ it jumps to the next state. If the input is โ€˜0โ€™ it stays in the same state.
  • In 2nd state (s1) the output of the detector is โ€˜0โ€™. When machine gets an input of โ€˜0โ€™ it jumps to the 3rd state. If it gets an input of โ€˜1โ€™ it stays in the same state.
  • In the 3rd state (s2) the output of the detector is โ€˜0โ€™. When machine gets an input of โ€˜1โ€™ it jumps to the 4th state. If the input received is โ€˜0โ€™ it goes back to the initial state.
  • In the 4th state (s3) the output of the detector is โ€˜0โ€™. When machine gets an input of โ€˜1โ€™ it jumps to the 5th state. If the input received is โ€˜0โ€™ it goes back to the 3rd state.
  • In the 5th state the output of the detector is โ€˜1โ€™. When machine gets an input of โ€˜0โ€™ it jumps to the 3rd state, otherwise it jumps to the 2nd state. 1 1 1 0 0 1 1 0 0 0 S 1 S 0 S 0 S 0 S 0 Figure 2: Moore State Machine for Detecting a Sequence of โ€˜1011โ€™ After designing the state machines the models have to be transformed into VHDL code describing the architecture. Therefore, it is helpful to get an understanding about the building blocks. Figure 3 shows the entity for the sequence detector to be developed. The two blocks inside, i.e., the combinational and the register block are build out of the two processes used within the architecture in VHDL. The combinational block decides the next state of the FSM according to the current state and the input as well as drives the output according to the state (and input for Mealy implementation). The register block saves the current state of the FSM. This structure can be used to write the VHDL code.

d_in

combinational

register

current state^ next_state

sequence_decoder

clk

rst

0^ d_out

1 0 1

Figure 3: Block diagram clarifying the basic building blocks of an FSM

An example code is shown in Listing 1. This template can be used to code the FSM for

this first assignment. All names for entity, processes and signals have been chosen so they

are comparable to the block diagram in Fig. 3.

Listing 1: An example code for coding an FSM in VHDL

1 use ieee.std_logic_1164.all; 2 3 entity sequence_decoder is 4 5 port ( 6 clk : in std_logic; 7 n_rst : in std_logic; 8 d_in : in std_logic; 9 d_out : out std_logic); 10 11 end sequence_decoder; 12 13 architecture sequence_decoder_arch of sequence_decoder is 14 15 -- Define a enumeration type for the states 16 type state_type is (s0, s1, s2, s4); 17 18 -- Define the needed internal signals 19 signal current_state, next_state : state_type; 20 21 begin -- sequence_decoder_arch 22 23 -- purpose: Implements the registers for the sequence decoder 24 -- type : sequential 25 -- inputs : clk, rst, next_state 26 -- outputs: current_state 27 reg: process (clk, rst) -- The register process 28 begin -- process register 29 if rst = โ€™1โ€™ then -- asynchronous reset (active high) 30 current_state <= ???; 31 elsif clkโ€™event and clk = โ€™1โ€™ then -- rising clock edge

stimuli.txt

test

(FSM_test.vhd)

FILE_READ

(file_read.vhd)

parallel-to-

serial

conversion

Moore / Mealy

FSM

CLOCKGENERATOR

(clockgenerator.vhd)

d_in clk rst d_out Figure 4: Block diagram of the testing environment 2 Assignment You have to perform the following tasks and in-order to get approved on this assignment you are required to complete all tasks in time:

  1. Submit the state diagram for both Mealy and Moore implementation before lab for the assigned sequence. This is a prerequisite to get access to the labs. Deadline 2013-09-10.
  2. Implement the same algorithm for detection of the sequence in VHDL using both Mealy and Moore implementation.
  3. Show the simulation of the design in the LAB using QuestaSim. Deadline 2013- 09-13. The sequences will be distributed for each lab group during the second lecture (2013- 09-03). (All the files needed to test the implementations are placed in โ€œS:\assignment_1\โ€ folder, a stimuli file is also provided. You can also download these files from the course web page.)