DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Similar documents
DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Sequential Logic - Module 5

Lecture 08 Finite State Machine Design Using VHDL

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

CprE 583 Reconfigurable Computing

[VARIABLE declaration] BEGIN. sequential statements

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 3

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

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

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 3

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

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

Summary of FPGA & VHDL

State Machine Descriptions

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

ELCT 501: Digital System Design

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

The University of Alabama in Huntsville Electrical and Computer Engineering CPE/EE 422/522 Spring 2005 Homework #6 Solution

Problem Set 10 Solutions

CCE 3202 Advanced Digital System Design

3 Designing Digital Systems with Algorithmic State Machine Charts

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

Pollard s Tutorial on Clocked Stuff in VHDL

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs

Sequential Statement

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

Inferring Storage Elements

CCE 3202 Advanced Digital System Design

IT T35 Digital system desigm y - ii /s - iii

CS/EE Homework 7 Solutions

Lectures 11 & 12: Synchronous Sequential Circuits Minimization

Digital Systems Design

EL 310 Hardware Description Languages Midterm

Control Unit: Binary Multiplier. Arturo Díaz-Pérez Departamento de Computación Laboratorio de Tecnologías de Información CINVESTAV-IPN

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

EECE-4740/5740 Advanced VHDL and FPGA Design Lecture 4. Cristinel Ababei Dept. of Electrical and Computer Engr. Marquette University

Introduction to VHDL #3

VHDL Examples Mohamed Zaky

VHDL: RTL Synthesis Basics. 1 of 59

EECE 353: Digital Systems Design Lecture 10: Datapath Circuits

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

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

Timing in synchronous systems

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

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1 Solutions

Luleå University of Technology Kurskod SMD152 Datum Skrivtid

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

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution March 2, 2006

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution Spring 2016

CprE 583 Reconfigurable Computing

ECE 545 Lecture 11 Addendum

Outline. Finite State Machine. 2. Representation of FSM. 1. Overview on FSM

Control and Datapath 8

Using ModelSim to Simulate Logic Circuits in VHDL Designs. 1 Introduction. For Quartus II 13.0

Synthesis from VHDL. Krzysztof Kuchcinski Department of Computer Science Lund Institute of Technology Sweden

Hardware Description Language VHDL (1) Introduction

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

Solutions - Homework 4 (Due date: November 9:30 am) Presentation and clarity are very important!

Counters. Counter Types. Variations. Modulo Gray Code BCD (Decimal) Decade Ring Johnson (twisted ring) LFSR

Finite-State Machine (FSM) Design

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 6 Combinational and sequential circuits

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

Finite State Machines

ECE 551: Digital System *

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

EEL 4712 Digital Design Test 2 Spring Semester 2008

CSC / EE Digital Systems Design. Summer Sample Project Proposal 01

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

Computer-Aided Digital System Design VHDL

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

Sequential Circuit Design: Principle

Senior Project Design Review: Internal Hardware Design of a Microcontroller in VLSI

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2004

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

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

Written exam for IE1204/5 Digital Design Thursday 29/

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

CS303 LOGIC DESIGN FINAL EXAM

R07

Finite State Machines

(ii) Simplify and implement the following SOP function using NOR gates:

Lecture 12 VHDL Synthesis


PALMiCE FPGA Probing Function User's Manual

Lab 3: Standard Combinational Components

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

COVER SHEET: Total: Regrade Info: Problem#: Points. 7 (14 points) 6 (7 points) 9 (6 points) 10 (21 points) 11 (4 points)

Using Library Modules in VHDL Designs

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Nanosistemų programavimo kalbos 5 paskaita. Sekvencinių schemų projektavimas

Using Library Modules in VHDL Designs. 1 Introduction. For Quartus II 12.1

Design a 4 bit-adder. Then design a 4-7 decoder to show the outputs. Output Sum(4 bits) Adder. Output carry(1 bit)

Using Library Modules in VHDL Designs

1. What is y-chart? ans: The y- chart consists of three domains:- behavioral, structural and geometrical.

EEL 4712 Digital Design Test 1 Spring Semester 2007

Transcription:

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6 FINITE STATE MACHINES (FSMs) Moore Machines Mealy Machines Algorithmic State Machine (ASM) charts

FINITE STATE MACHINES (FSMs) Classification: Moore Machine: Outputs depend only on the current state of the circuit. Mealy Machine: Outputs depend on the current state of the circuit as well as the inputs of the circuit. The circuit must always start from an initial state. Thus, there should be a signal. The figure depicts a generic state machine: Only for Mealy Machine Inputs Combinatorial Circuit Flip Flops Q (States) Combinatorial Circuit Outputs

FINITE STATE MACHINES (FSMs) VHDL Coding: There eist many different styles. The style eplained here considers two processes: one for the state transitions, and another for the outputs. The first step is to have the state diagram ready. The coding then just simply follows the state diagram. We need to define a custom user data type (e.g., state ) to represent the states type state is (S, S2, S) eample with states signal y: state; Then, we define a signal of type state (e.g. y ). This signal can only take values from S to S. Two processes must be considered: One where state transitions occur on the edge. One where the outputs are defined based on the current state and input signals.

Eample: 2-bit counter Moore-type FSM Count: 2-bit library ieee; use ieee.std_logic_64.all; entity my_2bitcounter is port (, : in std_logic; Q: out std_logic_vector ( downto )); end my_2bitcounter; architecture bhv of my_2bitcounter is counter Custom datatype definition: state with 4 possible values: S to S4 = '' S Q = 2 S2 Q = Q type state is (S,S2,S3,S4); signal y: state; Definition of signal y of type state. S4 Q = 3 S3 Q = 2 Transitions: process (, ) if = '' then -- asynchronous signal y <= S; -- initial state Process that defines the state transitions

Eample: 2-bit counter elsif ('event and ='') then case y is when S => y <= S2; when S2 => y <= S3; when S3 => y <= S4; when S4 => y <= S; end case; end if; end process; Outputs: process (y) case y is when S => Q <= ""; when S2 => Q <= ""; when S3 => Q <= ""; when S4 => Q <= ""; end case; end process; end bhv; my_2bitcounter.zip: my_2bitcounter.vhd, tb_my_2bitcounter.vhd Process that defines the state transitions. Note that the state transitions only occur on the rising edge Note that the outputs only depend on the current state, hence this is a Moore machine Process that defines the outputs. Note that the output is not controlled by the edge, only by the current state

Eample: BCD counter with stop signal Moore-type FSM If the stop signal is asserted, the count stops. If stop is not asserted, the count continues. stop BCD counter 4 Q = '' stop= S S2 S3 S4 Q = Q = Q = 2 Q = 3 S Q = 9 stop= S5 Q = 4 S9 Q = 8 Q = 7 S8 S7 Q = 6 Q = 5 S6

BCD Counter with stop signal VHDL code: Moore FSM library ieee; use ieee.std_logic_64.all; entity bcd_count is port (,, stop: in std_logic; Q: out std_logic_vector (3 downto )); end bcd_count; architecture bhv of bcd_count is type state is (S,S2,S3,S4,S5,S6,S7,S8,S9,S); signal y: state; Custom datatype definition: state with possible values: S to S Definition of signal y of type state. Transitions: process (,, stop) if = '' then -- asynchronous signal y <= S; -- initial state Process that defines the state transitions

elsif ('event and ='') then case y is when S => if stop='' then y<=s; else y<=s2; end if; when S2 => if stop='' then y<=s2; else y<=s3; end if; when S3 => if stop='' then y<=s3; else y<=s4; end if; when S4 => if stop='' then y<=s4; else y<=s5; end if; when S5 => if stop='' then y<=s5; else y<=s6; end if; when S6 => if stop='' then y<=s6; else y<=s7; end if; when S7 => if stop='' then y<=s7; else y<=s8; end if; when S8 => if stop='' then y<=s8; else y<=s9; end if; when S9 => if stop='' then y<=s9; else y<=s; end if; when S => if stop='' then y<=s; else y<=s; end if; end case; end if; end process; Note that the state transitions depend on the stop signal stop Process that defines the state transitions Note that the state transitions only occur on the rising edge

BCD Counter with stop signal VHDL code: Outputs: process (y) case y is when S => Q <= ""; when S2 => Q <= ""; when S3 => Q <= ""; when S4 => Q <= ""; when S5 => Q <= ""; when S6 => Q <= ""; when S7 => Q <= ""; when S8 => Q <= ""; when S9 => Q <= ""; when S => Q <= ""; end case; end process; end bhv; bcd_count.zip: bcd_count.vhd, tb_bcd_count.vhd stop BCD counter Note that the outputs only depend on the current state, hence this is a Moore machine Process that defines the outputs Note that the output is not controlled by the rising edge, only by the current state. 4 Q

Eample: LED sequence Moore-type FSM Sequence:,,,,,. The FSM includes an enable that allows for state transitions. This FSM requires 6 states, i.e. 3 flip flops. The 6-bit output is generated by a combinational circuit (decoder). E E Finite State Machine DO 8 = E= E= E= S E= S2 E= S3 DO= DO= DO= E= E= S6 E= S5 E= S4 DO= DO= DO= my_ledseq.zip: my_ledseq.vhd, tb_my_ledseq.vhd E= E= E=

Eample: Sequence detector with overlap Mealy-type FSM It detects the sequence State Diagram: 5 states Detector '' z = '' / / Notation: /z S / S2 / / / / S3 / / S5 S4 /

Eample: Sequence detector with overlap VHDL Code: Mealy FSM library ieee; use ieee.std_logic_64.all; entity my_seq_detect is port (,, : in std_logic; z: out std_logic); end my_seq_detect; architecture bhv of my_seq_detect is Detector '' Custom datatype definition: state with 5 possible values: S to S5 z type state is (S,S2,S3,S4,S5); signal y: state; Definition of signal y of type state. Transitions: process (,, ) if = '' then -- asynchronous signal y <= S; -- initial state Process that defines the state transitions

Eample: Sequence detector with overlap VHDL Code: Mealy FSM Detector '' z elsif ('event and ='') then case y is when S => if = '' then y<=s2; else y<=s; end if; when S2 => if = '' then y<=s3; else y<=s; end if; when S3 => if = '' then y<=s3; else y<=s4; end if; when S4 => if = '' then y<=s5; else y<=s; end if; when S5 => if = '' then y<=s3; else y<=s; end if; end case; end if; end process; Note that the state transitions depend on the input signal Process that defines the state transitions Note that the state transitions only occur on the rising edge

Eample: Sequence detector with overlap VHDL Code: Mealy FSM Detector '' z Outputs: process (,y) z <= ''; case y is when S => when S2 => when S3 => when S4 => when S5 => if = '' then z <= ''; end if; end case; end process; end bhv; Note that the output depends on the current state and the input, hence this is a Mealy machine. Process that defines the outputs my_seq_detect.zip: my_seq_detect.vhd, tb_my_seq_detect.vhd

ALGORITHMIC STATE MACHINE (ASMs) charts This is an efficient way to represent Finite State Machines. We use the detector as an eample here. Detector '' z S = = '' / / S2 Notation: /z S / S2 / / S3 / / S3 S4 S5 / / S4 / S5 z