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

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

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

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

ECE 551: Digital System *

Finite-State Machine (FSM) Design

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

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

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

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

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

Parallel versus serial execution

Quick Introduction to SystemVerilog: Sequental Logic

Finite State Machines

Digital Integrated Circuits

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

EN164: Design of Computing Systems Lecture 07: Lab Foundations / Verilog 3

Modeling Sequential Circuits in Verilog

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

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?

ECEN 468 Advanced Logic Design

Control in Digital Systems

Mealy and Moore examples

Sequential Logic Design

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

EECS 151/251A: SRPING 2017 MIDTERM 1

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

Last Lecture: Divide by 3 FSM

FSM and Efficient Synthesizable FSM Design using Verilog

Laboratory Exercise 7

Verilog Synthesis and FSMs. UCB EECS150 Fall 2010 Lab Lecture #3

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

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Finite State Machines

Techniques for Digital Systems Lab. Verilog HDL. Tajana Simunic Rosing. Source: Eric Crabill, Xilinx

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

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

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

Synthesizable Verilog

Announcements. Midterm 2 next Thursday, 6-7:30pm, 277 Cory Review session on Tuesday, 6-7:30pm, 277 Cory Homework 8 due next Tuesday Labs: project

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

Verilog for Synthesis Ing. Pullini Antonio

Behavioral Modeling and Timing Constraints

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

EECS 270 Verilog Reference: Sequential Logic

EECS150 - Digital Design Lecture 10 Logic Synthesis

VHDL: RTL Synthesis Basics. 1 of 59

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

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

Verilog Execution Semantics

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

Lecture 24: Sequential Logic Design. Let s refresh our memory.

Behavioral Modeling and Timing Constraints

Verilog for High Performance

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

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

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

Digital Integrated Circuits

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

Finite State Machines

Modeling of Finite State Machines. Debdeep Mukhopadhyay

EECS150, Fall 2004, Midterm 1, Prof. Culler. Problem 1 (15 points) 1.a. Circle the gate-level circuits that DO NOT implement a Boolean AND function.

Sequential Logic. Reminder: Lab #2 due Thursday Fall 2016 Lecture 4

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

General FSM design procedure

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

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

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

L11: Major/Minor FSMs

CSE140L: Components and Design Techniques for Digital Systems Lab

Homework deadline extended to next friday

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

Registers and finite state machines

Verilog Tutorial. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

Verilog Tutorial 9/28/2015. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Sequential Logic. Use Explicit Port Declarations. Verilog Summary. Examples

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

CSE140L: Components and Design

CSCB58 - Lab 3. Prelab /3 Part I (in-lab) /2 Part II (in-lab) /2 TOTAL /8

ECEN 468 Advanced Digital System Design

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

EECS150 - Digital Design Lecture 10 Logic Synthesis

EN2911X: Reconfigurable Computing Lecture 06: Verilog (3)

Writing Circuit Descriptions 8

Chapter 9: Sequential Logic Modules

EEL 4783: HDL in Digital System Design

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

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

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

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

Chapter 10. case studies in sequential logic design

Intro to HW Design & Externs for P4àNetFPGA. CS344 Lecture 5

Digital Design with SystemVerilog

Lecture 32: SystemVerilog

Problem Set 2 Solutions

General FSM design procedure

Transcription:

ECE 2300 Digital Logic & Computer Organization Spring 2018 More Verilog Finite Machines Lecture 8: 1

Prelim 1, Thursday 3/1, 1:25pm, 75 mins Arrive early by 1:20pm Review sessions Announcements Monday 2/26, 7:00pm, PHL 407 Tuesday 2/27, 7:00pm, PHL 407 Coverage: Lecture 1~7, HW 1~3 Sample prelim released on CMS Solutions to HW 1 & 2 released on CMS HW3 solution to be released on Sunday TA-led Verilog tutorial Next Tuesday (2/27) Bring your laptop! Lecture 8: 2

Review: Verilog Design Styles Structural A module is built from other (sub-)modules via instance statements Behavioral Use continuous assignments and/or procedural code in always blocks to indicate what actions to take Lecture 8: 3

Review: Procedural Assignments Blocking assignments ( = ) Simulation behavior: Right-hand side (RHS) evaluated sequentially; assignment to LHS is immediate Nonblocking assignment ( <= ) Simulation behavior: RHS evaluated in parallel (order doesn t matter); assignment to LHS is delayed until end of always block reg Y, Z; always @ (posedge clk) begin Y = A & B; Z = ~Y; end Blocking assignments Y next = A & B Z next = ~(A & B) reg Y, Z; always @ (posedge clk) begin Y <= A & B; Z <= ~Y; end Nonblocking assignments Z next = ~Y // the old Y Y next = A & B Lecture 8: 4

Review: Procedural Assignments reg Y, Z; always @ (posedge clk) begin Y = A & B; Z = ~Y; end Blocking assignments Corresponding circuit diagrams reg Y, Z; always @ (posedge clk) begin Y <= A & B; Z <= ~Y; end Nonblocking assignments A B A B Y Z Y Z Y and Z are flip-flops in actual hardware Lecture 8: 5

Net and Variable Types We will mainly use two data type classes wire: represents a physical connection (or net) between hardware elements A stateless way of connected two elements Can only be used to model combinational logic Cannot be used in the left-hand side in an always block reg: similar to wires, but can be used to store information (or state) like registers This is used in the behavioral style only Can be used to model both combinational & sequential logic Cannot be used in the left-hand side of a continuous assignment statement Lecture 8: 6

(Improperly Created) Inferred Latches You re recommended to ensure that each variable within an always block gets assigned a value (under all possible conditions) Otherwise, the Verilog compiler assumes that the last value should be used, and will create a latch reg dout; always @(din, c) begin /* dout not always assigned a value; latch inferred */ if (c == 1'b1) dout = din; end reg dout; always @(din, c) begin /* dout assigned a value in both conditions, latch not inferred */ if (c == 1'b1) dout = din; else dout = ~din; end Lecture 8: 7

Finite Machine Current Inputs Combinational Logic Outputs Next A Finite Machine (FSM) is an abstract representation of a sequential circuit The state embodies the condition of the system at this particular time The combinational logic determines the output and next state values The output values may depend only on the current state value, or on the current state and input values Lecture 8: 8

Elements of an FSM 1. A finite number of inputs 2. A finite number of outputs 3. A finite number of states 4. A specification of all state transitions Current Inputs Combinational Logic Outputs Next Can be described by a state diagram Lecture 8: 9

FSM: General Form Inputs Combinational Logic Outputs Inputs and current state determine state transitions Current FF Next Output changes determined by changes in Current state, or Current state + inputs FF CLK Lecture 8: 10

Moore Machine Output Combinational Logic Outputs Inputs Next Combinational Logic Outputs only depend on current state value Current FF Next FF Lecture 8: 11

Mealy Machine Output Combinational Logic Outputs Inputs Next Combinational Logic Outputs depend on input and current state values Current FF Next FF Lecture 8: 12

Diagram Visual specification of an FSM Bubble for every state Arcs showing state transitions Input values shown on the arcs Output values shown within the bubbles (Moore) or on the arcs (Mealy) Clock input implicit (always present, triggering state transitions) Moore FSM Mealy FSM Reset 0 1 Reset 0/0 1 S0 0 0 S1 0 1 0 S2 1 1/0 S0 0/0 1/1 S1 Lecture 8: 13

Moore Diagram Moore FSM Reset 0 1 S0 0 0 S1 0 1 1 0 S2 1 1 input, 1 output, 3 states Bubble for each state transitions (arcs) for each input value Input values on the arcs Output values within the bubbles Starts at S0 when Reset asserted Lecture 8: 14

Mealy Diagram Mealy FSM Reset 0/0 1/0 S0 0/0 1/1 S1 1 input, 1 output, 2 states Bubble for each state transitions (arcs) for each input value Input values on the arcs (first number) Output values on the arcs (second number) Starts at S0 when Reset asserted Lecture 8: 15

FSM Design Procedure (1) Understand the problem statement and determine inputs and outputs This lecture (2) Identify states and create a state diagram (3) Determine the number of required D FFs (4) Implement combinational logic for outputs and next state (5) Simulate the circuit to test its operation Lecture 8: 16

Example FSM: Pattern Detector Monitors the input, and outputs a 1 whenever a specified input pattern is detected Example: Output a 1 whenever 111 is detected on the input over 3 consecutive clock cycles Overlapping patterns also detected (1111...) Input In Output Out Reset causes FSM to start in initial state Clock input not shown (always present) Lecture 8: 17

111 Pattern Detector: Moore Diagram Lecture 8: 18

111 Pattern Detector: Mealy Diagram Lecture 8: 19

Example FSM: Pushbutton Lock Two pushbutton inputs, X1 and X2 One output, UL ( Unlock ) UL = 1 when X1 is pushed, followed by X2 being pushed twice (X1, X2, X2) Represent X1 and X2 as two bit input 00: neither button pushed 10: X1 pushed 01: X2 pushed 11: both pushed, reset the lock Lecture 8: 20

Pushbutton Lock: Moore Diagram Output: UL=1 with (X1, X2, X2) Input: 00 (neither), 10 (X1), 01 (X2), 11 (reset) Lecture 8: 21

Readings Before Next Class Tuesday 2/27: Verilog Tutorial Tutorial C: Introduction to Verilog and Quartus II Tuesday 3/6: More Finite Machines H&H 4.9 Lecture 8: 22