Modeling of Finite State Machines. Debdeep Mukhopadhyay

Similar documents
CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE

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

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

Finite-State Machine (FSM) Design

ECE 551: Digital System *

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

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

Quick Introduction to SystemVerilog: Sequental Logic

VHDL for Synthesis. Course Description. Course Duration. Goals

Verilog for High Performance

Modeling Synchronous Logic Circuits. Debdeep Mukhopadhyay IIT Madras

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

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

Problem Set 3 Solutions

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

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

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

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

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

State Machine Descriptions

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

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

Parallel versus serial execution

FSM and Efficient Synthesizable FSM Design using Verilog

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

Control in Digital Systems

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

Modeling Sequential Circuits in Verilog

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

Finite State Machines

Laboratory Finite State Machines and Serial Communication

Verilog Coding Guideline

CMPE 415 Verilog Case-Statement Based State Machines I

Mealy and Moore examples

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2

קורס VHDL for High Performance. VHDL

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

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Sequential Logic Design

Lecture 08 Finite State Machine Design Using VHDL

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

Designing Safe Verilog State Machines with Synplify

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

Digital Integrated Circuits

Writing Circuit Descriptions 8

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

VHDL: RTL Synthesis Basics. 1 of 59

Finite State Machines

Chapter 5 Registers & Counters

Lecture 32: SystemVerilog

Topics. Midterm Finish Chapter 7

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

Verilog for Synthesis Ing. Pullini Antonio

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

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

Digital Design with FPGAs. By Neeraj Kulkarni

ECEN : Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Homework #1 Solutions

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

FPGA for Software Engineers

RTL Design (Using ASM/SM Chart)

Sequential Logic Synthesis

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

Sequential Logic - Module 5

Why Should I Learn This Language? VLSI HDL. Verilog-2

CSE 502: Computer Architecture

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

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

General FSM design procedure

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences. Spring 2010 May 10, 2010

One and a half hours. Section A is COMPULSORY

EECS 270 Verilog Reference: Sequential Logic

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Student Name: Student ID: CSE 591: Advanced Hardware Design Professor: Kyle Gilsdorf

Last Lecture: Divide by 3 FSM

Storage Elements & Sequential Circuits

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

Formal Definition of Computation. Formal Definition of Computation p.1/28

Sequential Circuit Design: Principle

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

Debouncing a Switch. A Design Example. Page 1

Hardware Description Language (HDL)

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Registers and finite state machines

C A R L E T O N U N I V E R S I T Y. FINAL EXAMINATION April Duration: 3 Hours No. of Students: 108

Behavioral Modeling and Timing Constraints

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

CSE 140L Final Exam. Prof. Tajana Simunic Rosing. Spring 2008

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

Digital Design with SystemVerilog

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and

Synthesizable Verilog

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

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

Transcription:

Modeling of Finite State Machines Debdeep Mukhopadhyay

Definition 5 Tuple: (Q,Σ,δ,q 0,F) Q: Finite set of states Σ: Finite set of alphabets δ: Transition function QχΣ Q q 0 is the start state F is a set of accept states. They are also called final states.

Some Examples 0 1 1 What does this FSM do? 0 0 It accepts the empty string or any string that s with These set of strings which takes the FSM to its accepting states are often called language of the automaton.

Another Example 0 0 1 1 1 0 0 1 Accepts strings that starts and s with the same bits.

A more complicated example 0 q 1 0,<RESET> 2,<RESET> 1 2 1 0 q 0 2 1,<RESET> FSM accepts if the running sum of the input strings is a multiple of 3. RESET symbol resets the running sum to 0. q 2

Designing FSMs Its an art. Pret to be an FSM and imagine the strings are coming one by one. Remember that there are finite states. So, you cannot store the entire string, but only crucial information. Also, you do not know when the string s, so you should always be ready with an answer.

Example Design a FSM which accepts 0,1 strings which has an odd number of 1 s. You require to remember whether there are odd 1 s so far or even 1 s so far. 0 1 0 even odd 1

Example Design a FSM that accepts strings that contain 001 as substrings. There are 4 possibilities No string seen a 0 seen a 00 seen a 001

Answer 1 0 0 0 q q q 1 00 q 001 0 1 Note that their may be cases where design of FSMS are not possible. Like design an FSM for strings which has the same number of 0 s and 1 s.

How to model such FSMs? Inputs Next state logic (combinational) Clock Current State Register (sequential) Output logic (combinational) Output Simple Model of FSM

Mealy Machine/Moore Machine Inputs Next state logic (combinational) Clock Current State Register (sequential) Asynchronous Reset Mealy Outputs Output logic (combinational) Inputs Next state logic (combinational) Clock Current State Register (sequential) Asynchronous Reset Moore Outputs Output logic (combinational)

Modeling FSMs using Verilog

Issues State Encoding sequential gray Johnson one-hot

Encoding Formats No Sequential Gray Johnson One-hot 0 000 000 0000 00000001 1 001 001 0001 00000010 2 010 011 0011 00000100 3 011 010 0111 00001000 4 100 110 1111 00010000 5 101 111 1110 00100000 6 110 101 1100 01000000 7 111 100 1000 10000000

Comments on the coding styles Binary: Good for arithmetic operations. But may have more transitions, leading to more power consumptions. Also prone to error during the state transitions. Gray: Good as they reduce the transitions, and hence consume less dynamic power. Also, can be handy in detecting state transition errors.

Coding Styles Johnson: Also there is one bit change, and can be useful in detecting errors during transitions. More bits are required, increases linearly with the number of states. There are unused states, so we require either explicit asynchronous reset or recovery from illegal states (even more hardware!) One-hot: yet another low power coding style, requires more no of bits. Useful for describing bus protocols.

Good and Bad FSM Reset read write read write delay SlowROM delay SlowROM FSM_BAD FSM_GOOD FSM State Diagram

Bad Verilog always@(posedge Clock) begin parameter ST_Read=0,ST_Write=1,ST_Delay=3; integer state; case(state) ST_Read: begin Read=1; Write=0; State=ST_Write;

Bad Verilog ST_Write: begin Read=0; Write=1; if(slowram) State=ST_Delay; else State=ST_Read;

Bad Verilog ST_Delay: begin Read=0; Write=0; State=ST_Read; case

Why Bad? No reset. There are unused states in the FSM. Read and Write output assignments also infer an extra flip-flop. No default, latch is inferred. There is feedback logic.

Good verilog always @(posedge Clock) begin if(reset) CurrentState=ST_Read; else CurrentState=NextState;

Good verilog always@(currentstate or SlowRAM) begin case(currentstate) ST_Read: begin Read=1; Write=0; NextState=ST_Write;

Good Verilog ST_Write: begin Read=0; Write=1; if(slowram) NextState=ST_Delay; else NextState=ST_Read;

Good Verilog ST_Delay: begin Read=0; Write=0; NextState=ST_Read; default: begin Read=0; Write=0; NextState=ST_Read; case

One Bad and four good FSMs Reset ST0 Y=1 Y=4 ST3 Control ST1 Y=2 ST2 Y=3

Bad Verilog always @(posedge Clock or posedge Reset) begin if(reset) begin Y=1; STATE=ST0;

Bad verilog else case(state) ST0: begin Y=1; STATE=ST1; ST1: begin Y=2; if(control) STATE=ST2; else STATE=ST3; ST2: begin Y=3; STATE=ST3; ST3: begin Y=4; STATE=ST0; case Output Y is assigned under synchronous always block so extra three latches inferred.

Good FSMs Separate CS, NS and OL Combined CS and NS. Separate OL Combined NS and OL. Separate CS

always @(control or currentstate) begin NextState=ST0; case(currentstate) ST0: begin NextState=ST1; ST1: begin ST3: NextState=ST0; case Next State (NS)

Current State (CS) always @(posedge Clk or posedge reset) begin if(reset) currentstate=st0; else currentstate=nextstate;

Output Logic (OL) always @(Currentstate) begin case(currentstate) ST0: Y=1; ST1: Y=2; ST2: Y=3; ST3: Y=4;

CS+NS always@(posedge Clock or posedge reset) begin if(reset) State=ST0; else case(state) ST0: State=ST1; ST1: if(control) ST2: ST3: STATE=ST0; case default not required as it is in edge triggered always statement

CS+NS always @(STATE) begin case(state) ST0: Y=1; ST1: Y=2; ST2: Y=3; ST3: Y=4; default: Y=1; case default required as it is in combinational always statement

always @(Control or Currentstate) begin case(currentstate) ST0: begin Y=1; NextState=ST1; ST1: ST2: ST3: default: case NS+OL

NS+OL always @(posedge clock or posedge reset) begin if(reset) Currentstate=ST0; else Currentstate=NextState;