DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Similar documents
DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

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

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

Sequential Logic - Module 5

[VARIABLE declaration] BEGIN. sequential statements

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 3

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

CprE 583 Reconfigurable Computing

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

Lecture 08 Finite State Machine Design Using VHDL

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

ELCT 501: Digital System Design

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

Sequential Statement

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 3

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

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

State Machine Descriptions

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

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

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

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

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

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs

Inferring Storage Elements

CS/EE Homework 7 Solutions

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

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

Problem Set 10 Solutions

Lectures 11 & 12: Synchronous Sequential Circuits Minimization

VHDL Examples Mohamed Zaky

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

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

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

VHDL: RTL Synthesis Basics. 1 of 59

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

Timing in synchronous systems

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

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

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

Pollard s Tutorial on Clocked Stuff in VHDL

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

CprE 583 Reconfigurable Computing

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

Digital Systems Design

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

CCE 3202 Advanced Digital System Design

Control and Datapath 8

Hardware Description Language VHDL (1) Introduction

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

Summary of FPGA & VHDL

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

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

EL 310 Hardware Description Languages Midterm

Introduction to VHDL #3

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

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

Computer-Aided Digital System Design VHDL

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

Sequential Circuit Design: Principle

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

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

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

COVER SHEET: Total: Regrade Info: 1 (8 points) 2 ( 8 points) 3 (16 points) 4 (16 points) 5 (16 points) 6 (16 points) 7 (16 points) 8 (8 points)

CCE 3202 Advanced Digital System Design

Lecture 12 VHDL Synthesis


3 Designing Digital Systems with Algorithmic State Machine Charts

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

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

Finite-State Machine (FSM) Design

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

8 Register, Multiplexer and

VHDL And Synthesis Review

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Multiplication Simple Gradeschool Algorithm for 16 Bits (32 Bit Result)

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

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

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

Written exam for IE1204/5 Digital Design Thursday 29/

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

Finite State Machines

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

Introduction to VHDL. Yvonne Avilés Colaboration: Irvin Ortiz Flores Rapid System Prototyping Laboratory (RASP) University of Puerto Rico at Mayaguez

Mid-Term Exam Solutions

Concurrent & Sequential Stmts. (Review)

Contents. Chapter 9 Datapaths Page 1 of 28

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

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

Written Re-exam with solutions for IE1204/5 Digital Design Friday 10/

Finite State Machines

CS303 LOGIC DESIGN FINAL EXAM

CMPT 250: Computer Architecture. Using LogicWorks 5. Tutorial Part 1. Somsubhra Sharangi

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

VHDL VS VERILOG.

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

Constructing VHDL Models with CSA

ECE 551: Digital System *

COE 405 Behavioral Descriptions in VHDL

ECOM 4311 Digital Systems Design

Transcription:

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6 FINITE STATE MACHINES (FSMs) Moore Machines Mealy Machines

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 exist many different styles. The style explained 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 (S1, S2, S10) example with 10 states signal y: state; Then, we define a signal of type state (e.g. y ). This signal can only take values from S1 to S10. 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.

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

2-bit counter 2-bit counter 2 Q elsif ('event and ='1') then case y is when S1 => y <= S2; when S2 => y <= S3; when S3 => y <= S4; when S4 => y <= S1; end case; end if; end process; Process that defines the state transitions Note that the state transitions only occur on the rising edge Outputs: process (y) case y is when S1 => Q <= "00"; when S2 => Q <= "01"; when S3 => Q <= "10"; when S4 => Q <= "11"; end case; end process; end bhv; 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.

Moore Machine Example: stop BCD counter 4 Q BCD counter with stop signal: A BCD counter can be defined by a state machine. If the stop signal ( stop ) is asserted, the count stops. If stop is not asserted, the count continues. = '0' stop=0 0 0 1 S1 S2 S3 S4 Q = 0 Q = 1 Q = 2 Q = 3 1 S10 Q = 9 0 stop=1 1 1 1 1 1 0 S5 Q = 4 1 S9 Q = 8 Q = 7 S8 S7 Q = 6 Q = 5 S6 0 1 0 0 0

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

elsif ('event and ='1') then case y is when S1 => if stop='1' then y<=s1; else y<=s2; end if; when S2 => if stop='1' then y<=s2; else y<=s3; end if; when S3 => if stop='1' then y<=s3; else y<=s4; end if; when S4 => if stop='1' then y<=s4; else y<=s5; end if; when S5 => if stop='1' then y<=s5; else y<=s6; end if; when S6 => if stop='1' then y<=s6; else y<=s7; end if; when S7 => if stop='1' then y<=s7; else y<=s8; end if; when S8 => if stop='1' then y<=s8; else y<=s9; end if; when S9 => if stop='1' then y<=s9; else y<=s10; end if; when S10 => if stop='1' then y<=s10; else y<=s1; 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: stop BCD counter 4 Q Outputs: process (y) case y is when S1 => Q <= "0000"; when S2 => Q <= "0001"; when S3 => Q <= "0010"; when S4 => Q <= "0011"; when S5 => Q <= "0100"; when S6 => Q <= "0101"; when S7 => Q <= "0110"; when S8 => Q <= "0111"; when S9 => Q <= "1000"; when S10 => Q <= "1001"; end case; end process; end bhv; 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.

MEALY MACHINE Example: sequence detector ( 11010 ) with overlap. x Detector '11010' z State Diagram: 5 states = '0' 0/0 1/0 Notation: x/z S1 0/0 S2 1/0 1/0 0/1 1/0 S3 0/0 0/0 S5 S4 1/0

MEALY MACHINE Example: equence detector ( 11010 ) with overlap. library ieee; use ieee.std_logic_1164.all; x Detector '11010' z entity my_seq_detect is port (,, x: in std_logic; z: out std_logic); end my_seq_detect; architecture bhv of my_seq_detect is Custom datatype definition: state with 5 possible values: S1 to S5 type state is (S1,S2,S3,S4,S5); signal y: state; Definition of signal y of type state. Transitions: process (,, x) Process that defines the state transitions if = '0' then -- asynchronous signal y <= S1; -- initial state

MEALY MACHINE Example: sequence detector ( 11010 ) with overlap. x Detector '11010' z elsif ('event and ='1') then case y is when S1 => if x = '1' then y<=s2; else y<=s1; end if; when S2 => if x = '1' then y<=s3; else y<=s1; end if; when S3 => if x = '1' then y<=s3; else y<=s4; end if; when S4 => if x = '1' then y<=s5; else y<=s1; end if; when S5 => if x = '1' then y<=s3; else y<=s1; end if; end case; end if; end process; Note that the state transitions depend on the input signal x Process that defines the state transitions Note that the state transitions only occur on the rising edge

MEALY MACHINE Example: sequence detector ( 11010 ) with overlap. x Detector '11010' z Outputs: process (x,y) z <= '0'; case y is when S1 => when S2 => when S3 => when S4 => when S5 => if x = '0' then z <= '1'; end if; end case; end process; end bhv; Note that the output depends on the current state and the input x, hence this is a Mealy machine. Process that defines the outputs