Finite State Machines

Similar documents
Finite State Machines

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

Behavioral Modeling and Timing Constraints

Multi-Output Circuits: Encoders, Decoders, and

ECE 551: Digital System *

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines

State Machine Descriptions

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

VHDL Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

Lecture 08 Finite State Machine Design Using VHDL

Finite State Machines (FSM) Description in VHDL. Review and Synthesis

EE 231 Fall EE 231 Homework 8 Due October 20, 2010

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

Behavioral Modeling and Timing Constraints

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date:

Counters, Timers and Real-Time Clock

Finite-State Machine (FSM) Design

Digital System Design with SystemVerilog

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines

Finite State Machines

Timing in synchronous systems

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control

FSM and Efficient Synthesizable FSM Design using Verilog

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

Sequential Logic Implementation. Mealy vs. Moore Machines. Specifying Outputs for a Mealy Machine. Specifying Outputs for a Moore Machine

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Creating Safe State Machines

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1. Your name 2/13/2014

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Instructor: Mohsen Imani. Slides from Tajana Simunic Rosing

FPGA for Software Engineers

EECS Components and Design Techniques for Digital Systems. Lec 07 PLAs and FSMs 9/ Big Idea: boolean functions <> gates.

Blocking(=) vs Nonblocking (<=) Assignment. Lecture 3: Modeling Sequential Logic in Verilog HDL. Procedural assignments

Digital Design Using Digilent FPGA Boards -- Verilog / Active-HDL Edition

Used to perform operations many times. See previous Parallel to Serial Example

Control in Digital Systems

RTL Design (Using ASM/SM Chart)

: : (91-44) (Office) (91-44) (Residence)

Programable Logic Devices

Modeling Concepts. Introduction

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines

Outline. EECS Components and Design Techniques for Digital Systems. Lec 11 Putting it all together Where are we now?

Sequential Circuits. inputs Comb FFs. Outputs. Comb CLK. Sequential logic examples. ! Another way to understand setup/hold/propagation time

Multi-Output Circuits: Encoders, Decoders, and

CprE 583 Reconfigurable Computing

V1 - VHDL Language. FPGA Programming with VHDL and Simulation (through the training Xilinx, Lattice or Actel FPGA are targeted) Objectives

Laboratory Finite State Machines and Serial Communication

Verilog for High Performance

Finite State Machines (FSMs) and RAMs and CPUs. COS 116, Spring 2011 Sanjeev Arora

Last Lecture: Divide by 3 FSM

Mealy and Moore examples

Final Exam Review. b) Using only algebra, prove or disprove the following:

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design

CHAPTER - 2 : DESIGN OF ARITHMETIC CIRCUITS

PDHonline Course G349. State Machines. Mark A. Strain, P.E. PDH Online PDH Center

ECEU530. Homework 4 due Wednesday Oct 25. ECE U530 Digital Hardware Synthesis. VHDL for Synthesis with Xilinx. Schedule

RealDigital. Problem Set #7 S1 S2 S3 Y Z X Y + Y Z X Z

VHDL for Synthesis. Course Description. Course Duration. Goals

Designing Safe Verilog State Machines with Synplify

ECE 551 Digital System Design and Synthesis. Instructor: Kewal K. Saluja. Midterm Exam

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Sequential Logic Design

Sequential Logic - Module 5

FSM-based Digital Design using Veriiog HDL

Sign here to give permission for your test to be returned in class, where others might see your score:

Introduction to Verilog and ModelSim. (Part 6 State Machines)

Code No: 07A3EC03 Set No. 1

Music. Numbers correspond to course weeks EULA ESE150 Spring click OK Based on slides DeHon 1. !

FINITE STATE MACHINES (FSM) DESCRIPTION IN VHDL. Cristian Sisterna UNSJ

Laboratory Exercise 7

Numbering Systems. Number Representations Part 1

Sequential Circuit Design: Principle

Storage Elements & Sequential Circuits

B.10 Finite State Machines B.10

R07. Code No: V0423. II B. Tech II Semester, Supplementary Examinations, April

CS 151 Final. Q1 Q2 Q3 Q4 Q5 Total Credit Score. Instructions: Student ID. (Last Name) (First Name) Signature

Modeling of Finite State Machines. Debdeep Mukhopadhyay

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

Lecture #1: Introduction

DIGITAL SYSTEM DESIGN

Summary of FPGA & VHDL

Lecture 32: SystemVerilog

Digital Design with SystemVerilog

ECE 545 Lecture 12. Datapath vs. Controller. Structure of a Typical Digital System Data Inputs. Required reading. Design of Controllers

PINE TRAINING ACADEMY

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

Lecture 12 VHDL Synthesis

Lab 1: Verilog Synthesis and FSMs

problem maximum score 1 10pts 2 8pts 3 10pts 4 12pts 5 7pts 6 7pts 7 7pts 8 17pts 9 22pts total 100pts

EITF35 - Introduction to Structured VLSI Design (Fall ) 7. Assignment 3 - Arithmetic Logic Unit (ALU)

Luleå University of Technology Kurskod SMD152 Datum Skrivtid

General FSM design procedure

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING QUESTION BANK NAME OF THE SUBJECT: EE 2255 DIGITAL LOGIC CIRCUITS

Sequential Circuit Design: Principle

2015 Paper E2.1: Digital Electronics II

The University of Alabama in Huntsville ECE Department CPE Midterm Exam February 26, 2003

Transcription:

Lab Workbook Introduction (FSM) are sequential circuit used in many digital systems to control the behavior of systems and dataflow paths. Examples of FSM include control units and sequencers. This lab introduces the concept of two types of FSMs, Mealy and Moore, and the modeling styles to develop such machines. Please refer to the PlanAhead tutorial on how to use the PlanAhead tool for creating projects and verifying digital circuits. Objectives After completing this lab, you will be able to: Model Mealy FSMs Model Moore FSMs Mealy FSM Part 1 A finite-state machine (FSM) or simply a state machine is used to design both computer programs and sequential logic circuits. It is conceived as an abstract machine that can be in one of a finite number of user-defined states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition; this is called a transition. A particular FSM is defined by a list of its states, and the triggering condition for each transition. The behavior of state machines can be observed in many devices in modern society performing a predetermined sequence of actions depending on a sequence of events with which they are presented. Simple examples are vending machines which dispense products when the proper combination of coins are deposited, elevators which drop riders off at upper floors before going down, traffic lights which change sequence when cars are waiting, and combination locks which require the input of combination numbers in the proper order. The state machines are modeled using two basic types of sequential networks- Mealy and Moore. In a Mealy machine, the output depends on both the present (current) state and the present (current) inputs. In Moore machine, the output depends only on the present state. A general model of a Mealy sequential machine consists of a combinatorial network, which generates the outputs and the next state, and a state register which holds the present state as shown below. The state register is normally modeled as D flip-flops. The state register must be sensitive to a clock edge. The other block(s) can be modeled either using the always procedural block or a mixture of the always procedural block and dataflow modeling statements; the always procedural block will have to be sensitive to all inputs being read into the block and must have all output defined for every branch in order to model it as a combinatorial block. The two blocks Mealy machine can be viewed as Here are the state diagram of a parity checker Mealy machine and the associated model. www.xilinx.com/university Nexys3 10-1

Lab Workbook type state_type is (S0, S1); signal state, next_state : state_type; SYNC_PROC : process (clk) if rising_edge(clk) then if (reset = '1') then state <= S0; state <= next_state; NEXT_STATE_DECODE : process (state, x) The three blocks Mealy machine and the associated model are shown below. Nexys3 10-2 www.xilinx.com/university

Lab Workbook type state_type is (S0, S1); signal state, next_state : state_type; SYNC_PROC : process (clk) if rising_edge(clk) then if (reset = '1') then state <= S0; state <= next state; OUTPUT_DECODE : process (state, x) if (x = '0') then NEXT_STATE_DECODE : process (state, x) if (x = '0') then The state assignments can be of one-hot, binary, gray-code, and other types. Usually, the synthesis tool will determine the type of the state assignment, but user can also force a particular type by changing the synthesis property as shown below. The state assignment type will have an impact on the number of bits used in the state register; one-hot encoding using maximum number of bits but decodes very fast to compact (binary) encoding using smallest number of bits but taking longer to decode. www.xilinx.com/university Nexys3 10-3

Lab Workbook 1-1. Design a sequence detector implementing a Mealy state machine using three always blocks. The Mealy state machine has one input (ain) and one output (y out ). The output y out is 1 if and only if the total number of 1s received is divisible by 3 (hint: 0 is inclusive, however, reset cycle(s) do not count as 0- see in simulation waveform time=200). Develop a testbench and verify the model through a behavioral simulation. Use SW0 as the clock input, SW1 as the ain input, the BTNU button as reset input to the circuit, number of 1s count on LED7:LED4, and LED0 as the y out output. Go through the design flow, generate the bitstream, and download it into the Nexys3 board. Verify the functionality. Moore FSM Part 2 A general model of a Moore sequential machine is shown below. Its output is generated from the state register block. The next state is determined using the present (current) input and the present (current) state. Here the state register is also modeled using D flip-flops. Normally Moore machines are described using three blocks, one of which must be a sequential and the other two can be modeled using always blocks or a combination of always and dataflow modeling constructs. Here is the state graph of the same parity checker to be modeled as a Moore machine. The associate model is shown below. Nexys3 10-4 www.xilinx.com/university

Lab Workbook type state_type is (S0, S1); signal state, next_state : state_type; SYNC_PROC : process (clk) if rising_edge(clk) then if (reset = '1') then state <= S0; state <= next_state; OUTPUT_DECODE : process (state) NEXT_STATE_DECODE : process (state, x) if (x = '0') then 2-1. Design a sequence detector implementing a Moore state machine using three always blocks. The Moore state machine has two inputs (ain[1:0]) and one output (yout). The output yout s as 0 and remains a constant value unless one of the following input sequences occurs: www.xilinx.com/university Nexys3 10-5

Lab Workbook (i) The input sequence ain[1:0] = 01, 00 causes the output to become 0 (ii) The input sequence ain[1:0] = 11, 00 causes the output to become 1 (iii) The input sequence ain[1:0] = 10, 00 causes the output to toggle. Develop a testbench (similar to the waveform shown below) and verify the model through a behavioral simulation. Use SW0 as the clock input, SW2- SW1 as the ain[1:0] input, the BTNU button as reset input to the circuit, and LED0 as the yout output. Go through the design flow, generate the bitstream, and download it into the Nexys3 board. Verify the functionality. Mealy FSM Using ROM Part 3 A Mealy sequential machine can also be implemented using a ROM memory as shown below. The ROM memory holds the next state and output content. The external inputs and the current state form the address input to the ROM. The ROM typically is implemented using LUTs instead of Block RAM since LUTs give a better utilization ratio resulting from a smaller number of states in a design. 3-1. Design a specific counts counter (counting sequence listed below) using ROM to develop a Mealy state machine. Develop a testbench and verify the model through behavioral simulation. Use SW0 as the clock input, the BTNU button as reset input to the circuit, and LED2:LED0 as the count output of the counter. Go through the design flow, generate the bitstream, and download it into the Nexys3 board. Verify the functionality. The counting sequence will be: 000, 001, 011, 101, 111, 010 (repeat) 000, Conclusion In this lab, you learned Mealy and Moore state machine modeling methodologies. You designed and implemented sequence detector, a sequence generator, and code converters using the two and three always blocks styles. Nexys3 10-6 www.xilinx.com/university