Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Similar documents
FSM and Efficient Synthesizable FSM Design using Verilog

ECE 551: Digital System *

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

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

Quick Introduction to SystemVerilog: Sequental Logic

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

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

Finite State Machines

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

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

Testbenches for Sequential Circuits... also, Components

Finite State Machines

Last Lecture: Divide by 3 FSM

RTL Design (Using ASM/SM Chart)

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

Digital Design with SystemVerilog

Control in Digital Systems

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

State Machine Descriptions

Sequential Logic Design

Lecture 32: SystemVerilog

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

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

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

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

Mealy and Moore examples

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

Laboratory Exercise 7

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

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

Digital Integrated Circuits

VHDL for Synthesis. Course Description. Course Duration. Goals

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

Modeling of Finite State Machines. Debdeep Mukhopadhyay

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

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

Verilog for High Performance

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

Finite-State Machine (FSM) Design

World Class Verilog & SystemVerilog Training

Designing Safe Verilog State Machines with Synplify

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

Verilog Coding Guideline

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

CprE 583 Reconfigurable Computing

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

Modeling Sequential Circuits in Verilog

CSE 502: Computer Architecture

Abstraction of State Elements. Sequential Logic Implementation. Forms of Sequential Logic. Finite State Machine Representations

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

Bulletproofing FSM Verification Automated Approach to Detect Corner Case Issues in an FSM Design

Sequential Logic Synthesis

Verilog for Synthesis Ing. Pullini Antonio

Debouncing a Switch. A Design Example. Page 1

Writing Circuit Descriptions 8

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Registers and finite state machines

Synthesizable Verilog

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

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

קורס VHDL for High Performance. VHDL

Problem Set 3 Solutions

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

CSE140L: Components and Design Techniques for Digital Systems Lab

ECEN 468 Advanced Logic Design

Synthesis of Combinational and Sequential Circuits with Verilog

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Digital Design with SystemVerilog

CSE140L: Components and Design

HDLs and SystemVerilog. Digital Computer Design

Chap 6 Introduction to HDL (d)

FPGA for Software Engineers

EEL 4783: HDL in Digital System Design

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

Parallel versus serial execution

Verilog introduction. Embedded and Ambient Systems Lab

Sequential Logic - Module 5

Lecture 08 Finite State Machine Design Using VHDL

Sequential Circuit Design: Principle

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

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

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

Digital Integrated Circuits

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Introduction to Verilog/System Verilog

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

HDL Design Cube. Synthesis and VHDL

Building Bigger Systems: Hardware Threads

CS6710 Tool Suite. Verilog is the Key Tool

HDL Compiler Directives 7

University of Technology

Laboratory Finite State Machines and Serial Communication

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

Transcription:

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA 2017-2018

Objectives Summary of finite state machines (Mealy, Moore) Description of FSMs in System Verilog Design of control blocks based on FSMs Exercise: semaphore

Overview Finite State Machine Design Mealy Moore Implicit Explicit

FSM Models & Types Explicit Declares a state register that stores the FSM state May not be called state might be a counter! Implicit Describes state implicitly by using multiple event controls Moore Outputs depend on state only (synchronous) Mealy Outputs depend on inputs and state (asynchronous) Outputs can also be registered (synchronous)

Mealy & Moore FSMs (contd.) Mealy Machine Only Combinational Logic Sequential Logic Circuit Combinational Logic Next State Logic Next Present State FF s State Output Logic outputs CLK

Binary Encoded or One Hot Encoding Binary Encoded FSM (Highly Encoded) One Hot Encoding 110 S4 IDLE 000 S1 001 10000 S4 IDLE 00001 S1 00010 010 S3 S2 011 01000 S3 S2 00100

Binary Encoded or One Hot Encoding A binary-encoded FSM design only requires as many flip-flops as are needed to uniquely encode the number of states in the state machine. Number of FF if(log2(number of states) == integer) else required FF = log2(number of states) required FF = integer(log2(#states))+1;

Binary Encoded or One Hot Encoding A onehot FSM design requires a flip-flop for each state in the design and only one flip-flop (the flip-flop representing the current or "hot" state) is set at a time in a onehot FSM design. For a state machine with 9-16 states, a binary FSM only requires 4 flip-flops while a onehot FSM requires a flip-flop for each state in the design (9-16 flip-flops).

FSM Coding Goals The FSM coding style should be easily modified to change state encodings and FSM styles. The coding style should be compact. The coding style should be easy to code and understand. The coding style should facilitate debugging. The coding style should yield efficient synthesis results.

Two Always Block FSM Style (Good Style) One of the best Verilog coding styles is to code the FSM design using three always blocks: one for the sequential state register one for the combinational next-state onefor combinational output logic. Mealy Machine Only Combinational Logic Sequential Logic Circuit Combinational Logic Next State Logic Next Present State FF s State Output Logic outputs CLK

State Diagram S0 reset = 1 a = 0 b = 0 a = 1/ Z = 1 S1 Y=1 S2 b = 1/ Z = 1 Outputs Y and Z are 0, unless specified otherwise. We don t care about the value of b in S0, or the value of a in S1, or either a or b in S2. Is this Mealy or Moore?

State Diagram: Mealy! a = 0 b = x/ Y = 0, Z = 0 S0 a = 1 b = x/ Y = 0, Z = 1 a = x b = 0/ Y = 1, Z = 0 S1 Outputs Y and Z are 0, unless specified otherwise. We don t care about the value of b in S0, or the value of a in S1, or either a or b in S2. reset = 1 ab = xx/ YZ = 00 S2 a = x b = 1/ Y = 1, Z = 1 Is this Mealy or Moore?

Mealy FSM Inputs Next State and Output Logic Outputs State Register Current State FF

Mealy Verilog Part 1 module fsm_mealy ( input logic clk, input logic reset, input logic a, input logic b, output logic Y, output logic Z); enum { S0, S1, S2 } state, next_state; always_ff@(posedge clk) begin if (reset) state <= S0; else state <= next_state; end //continued on next slide

Mealy Verilog Part 2 // next state & output logic always_comb begin Y = 0; Z = 0; case (state) S0: if (a) begin next_state = S1; Z = 1; end else next_state = S0; S1: begin Y = 1; if (b) begin next_state = S2; Z = 1; end else next_state = S1; end S2: next_state = S0; default: begin next_state = S0; Y = 1 b1; Z = 1 b1; end endcase endmodule

Moore FSM Inputs Next State Logic Output Logic Outputs State Register Current State FF Next State

State Diagram: Moore a = 0 b = 0 Outputs Y and Z are 0, unless specified otherwise. S0 a = 1 S1 Y=1 If an input isn t listed for a transition, we don t care about its value for that transition reset = 1 b = 1 S2 Z=1

Moore Verilog Part 1 module fsm_moore ( input logic clk, input logic reset, input logic a, input logic b, output logic Y, output logic Z ); always_ff@(posedge clk) begin if (reset) state <= S0; else state <= next_state; end //continued on next slide

Moore Verilog Part 2 //next state & output logic always@(state or a or b) case (state) S0: if (a) next_state = S1; else next_state = S0; S1: Y = 1; if (b) next_state = S2; else next_state = S1; S2: Z = 1; next_state = S0; default: next_state = S0; endcase endmodule

Exercise Desig, using SystemVerilog hardware description language, a digital circuit implementing the functionality of a controller for a beverage dispensing machine. The IO interface of the digital circuit is the following: module vending ( input logic input logic input logic input logic output logic ); clk, rstn, dime, niche, out endmodule The dispensing machine only accepts 5 cents (nichel) and 10 cents (dime) coins. Once the amount of 15 cents is reached the machine activates a signal to enable the release of the beverage (output). The machine does not give back change. It is not allowed to insert more than one coin for a given clock cycle.