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

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

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

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

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

ECE 551: Digital System *

Sequential Logic Design

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

Laboratory Exercise 7

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

FSM and Efficient Synthesizable FSM Design using Verilog

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

Quick Introduction to SystemVerilog: Sequental Logic

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

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

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

Control in Digital Systems

Finite State Machines

Digital Integrated Circuits

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

Finite State Machines

Finite-State Machine (FSM) Design

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

Mealy and Moore examples

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

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

ECEN 468 Advanced Logic Design

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

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

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

Parallel versus serial execution

Digital Design with SystemVerilog

RTL Design (Using ASM/SM Chart)

Last Lecture: Divide by 3 FSM

Digital Integrated Circuits

Finite State Machines

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

Modeling Sequential Circuits in Verilog

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

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

Verilog Coding Guideline

Registers and finite state machines

EECS 151/251A: SRPING 2017 MIDTERM 1

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

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

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

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

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

General FSM design procedure

Course Topics - Outline

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

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

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

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

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

Design of Digital Circuits ( L) ETH Zürich, Spring 2017

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

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

Synthesizable Verilog

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

CSE140L: Components and Design Techniques for Digital Systems Lab

Verilog introduction. Embedded and Ambient Systems Lab

B.10 Finite State Machines B.10

General FSM design procedure

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

Modeling of Finite State Machines. Debdeep Mukhopadhyay

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Verilog for High Performance

Lecture 08 Finite State Machine Design Using VHDL

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

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

CSE140L: Components and Design

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Lecture 32: SystemVerilog

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

EECS 270 Verilog Reference: Sequential Logic

Lecture #1: Introduction

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

Topics. Midterm Finish Chapter 7

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

Digital design laboratory 5

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.

Chap 6 Introduction to HDL (d)

One and a half hours. Section A is COMPULSORY

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

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

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

ECEN 468 Advanced Digital System Design

Building Bigger Systems: Hardware Threads

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

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

Register Transfer Level in Verilog: Part I

CS 61C Summer 2012 Discussion 11 State, Timing, and CPU (Solutions)

ECE 595Z Digital Systems Design Automation

ECE Digital Design Laboratory. Lecture 3 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

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

Verilog for Synthesis Ing. Pullini Antonio

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

Transcription:

ECE 2300 Digital Logic & Computer Organization Spring 2018 More Finite State Machines Lecture 9: 1

Announcements Prelab 3(B) due tomorrow Lab 4 to be released tonight You re not required to change partner(s) from this lab onwards Lecture 9: 2

Example: Procedural Assignments reg Y, Z; always @ (posedge clk) begin Y = ~Z; Z = A & B; end Blocking assignments = reg Y, Z; always @ (posedge clk) begin Y <= ~Z; Z <= A & B; end Nonblocking assignments A B A B Z Y Z Y Lecture 9: 3

FSM Design Procedure (1) Understand the problem statement and determine inputs and outputs (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 This lecture (5) Simulate the circuit to test its operation Lecture 9: 4

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 9: 5

State Diagrams Reset Moore Init Got1 Got11 Got111 Out = 1 Reset Mealy Init Got1 Got11 Out = 1 Lecture 9: 6

Transition/Output Table Shows the next state (S * ) and output values for each combination of current state (S) and inputs Used to derive the minimized state transition (S * ) and output Boolean equations Lecture 9: 7

Reset Moore Transition/Output Table 1 Init Got1 Got11 Got111 Out = 1 Current State (S) Next State (S * ) Out Init Init Got1 0 Got1 Init Got11 0 Got11 Init Got111 0 Got111 Init Got111 1 Version 1: uses descriptive state names Lecture 9: 8

Reset Moore Transition/Output Table 2 Init Got1 Got11 Got111 Out = 1 [00] [01] [10] [11] S1 S0 S1 * S0 * Out 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 1 0 0 1 1 1 Version 2: uses state binary encodings Lecture 9: 9

Minimized Equations for S* and Out S1 S0 S1 * S0 * Out 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 1 0 0 1 1 1 Lecture 9: 10

Mealy Transition/Output Table 1 Reset Init Got1 Got11 Out = 1 Current State (S) Next State (S * ), Out Init Init, 0 Got1, 0 Got1 Init, 0 Got11, 0 Got11 Init, 0 Got11, 1 Version 1: uses descriptive state names Lecture 9: 11

Mealy Transition/Output Table 2 Reset Init Got1 Got11 [00] [01] [10] Out = 1 S1 S0 S1 * S0 *, Out 0 0 0 0, 0 0 1, 0 0 1 0 0, 0 1 0, 0 1 0 0 0, 0 1 0, 1 Version 2: uses state binary encodings Lecture 9: 12

Minimized Equations for S * and Out S1 * S0 *, Out S1 S0 0 0 0 0, 0 0 1, 0 0 1 0 0, 0 1 0, 0 1 0 0 0, 0 1 0, 1 Lecture 9: 13

FSMs in Verilog <module statement> <input and output declarations> <reg declarations> <parameter or typedef statement> <always block for next state> Suggested coding style for FSM <always block for output> <always block for state FFs> endmodule Lecture 9: 14

Reset Moore FSM in Verilog Init Got1 Got11 Got111 Out = 1 [00] [01] [10] [11] module PatDetectMoore (Clk, In, Reset, Out); input Clk, In, Reset; output Out; reg Out; reg [1:0] Scurr, Snext; parameter [1:0] Init = 2'b00, Got1 = 2'b01, Got11 = 2'b10, Got111 = 2'b11; Lecture 9: 15

Reset Moore FSM in Verilog Init Got1 Got11 Got111 Out = 1 [00] [01] [10] [11] always @ (In, Scurr) begin case (Scurr) Init: if (In == 1) Snext = Got1; else Snext = Init; Got1: if (In == 1) Snext = Got11; else Snext = Init; Got11: if (In == 1) Snext = Got111; else Snext = Init; Got111: if (In == 1) Snext = Got111; else Snext = Init; default: Snext = Init; endcase end next state comb logic Lecture 9: 16

Reset Moore FSM in Verilog Init Got1 Got11 Got111 Out = 1 [00] [01] [10] [11] always @ (Scurr) if (Scurr == Got111) Out = 1; else ; output comb logic always @ (posedge Clk) if (Reset == 1) Scurr <= Init; else Scurr <= Snext; clock state FFs (synchronous reset) endmodule Lecture 9: 17

Reset Mealy FSM in Verilog Init Got1 Got11 [00] [01] [10] module PatDetectMealy (Clk, In, Reset, Out); input Clk, In, Reset; output Out; Out = 1 reg Out; reg [1:0] Scurr, Snext; parameter [1:0] Init = 2'b00, Got1 = 2'b01, Got11 = 2'b10; Lecture 9: 18

Reset Mealy FSM in Verilog always @ (In, Scurr) begin case (Scurr) Init: if (In == 1) Snext = Got1; else Snext = Init; Got1: if (In == 1) Snext = Got11; else Snext = Init; Got11: if (In == 1) Snext = Got11; else Snext = Init; default: Snext = Init; endcase end Init Got1 Got11 [00] [01] [10] Out = 1 next state comb logic Lecture 9: 19

Reset Mealy FSM in Verilog Init Got1 Got11 [00] [01] [10] always @ (Scurr, In) if ((Scurr == Got11) && (In == 1)) Out = 1; else ; Out = 1 output comb logic always @ (posedge Clk) if (Reset == 1) Scurr <= Init; else Scurr <= Snext; clock state FFs (synchronous reset) endmodule Lecture 9: 20

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 9: 21

Pushbutton Lock: Moore State Diagram Output: UL=1 with sequence X1, X2, X2 Input: 00 (neither), 10 (X1), 01 (X2), 11 (reset) 0 0 0 1 X1 X1-X2 UL = 0 UL = 0 [01] [10] 0 0 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 Init UL = 0 [00] 1 1 X1-X2-X2 UL = 1 [11] 0 0 0 1 1 0 Lecture 9: 22

Moore Transition/Output Table 1 Current State (S) Input 0 0 (neither) Next State (S*) Input 0 1 (X2) Input 1 0 (X1) Input 1 1 (reset) Init Init Init X1 Init 0 X1 X1 X1-X2 Init Init 0 X1-X2 X1,X2 X1-X2-X2 Init Init 0 X1-X2-X2 X1-X2-X2 X1-X2-X2 X1-X2-X2 Init 1 Version 1: uses descriptive state names UL Lecture 9: 23

Moore Transition/Output Table 2 S1 S0 Input 0 0 Input 0 1 S1* S0* UL Input 1 0 Input 1 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 Version 2: uses state binary encodings Lecture 9: 24

Pushbutton Lock: Mealy State Diagram Output: UL=1 with sequence X1, X2, X2 Input: 00 (neither), 10 (X1), 01 (X2), 11 (reset) 0 0 / UL=0 1 0 / UL=0 X1 0 1 / UL=0 X1-X2 [01] [10] 1 1 1 0 / UL=0 1 1 1 0 / UL=0 0 1 / UL=0 0 0 / UL=0 0 0 0 1 1 1 / UL=0 Init [00] 1 1 / UL=0 X1-X2-X2 [11] 0 0 0 1 1 0 / UL=1 Lecture 9: 25

Mealy Transition/Output Table S1* S0*, UL S1 S0 Input 0 0 Input 0 1 Input 1 0 Input 1 1 0 0 0 0, 0 0 0, 0 0 1, 0 0 0, 0 0 1 0 1, 0 1 0, 0 0 0, 0 0 0, 0 1 0 1 0, 0 1 1, 0 0 0, 0 0 0, 0 1 1 1 1, 1 1 1, 1 1 1, 1 0 0, 0 uses state binary encodings Lecture 9: 26

FSM for D Flip-Flop D = 0 D CLK Q State0 State1 Q = 0 Q = 1 [0] [1] D = 1 D = 0 D = 1 Input: D Output: Q Clock is implicit in the state diagram Moore state diagram Lecture 9: 27

Analyzing the FSM S0* S1* What does this FSM do? Lecture 9: 28

Transition and Output Equations S 0 * = S 1 * = Out = S0* S1* Lecture 9: 29

1. Complete the transition/output table and state diagram Exercise: State Diagram 2. Identify the functionality of the FSM (Hint: Pattern detector?) S 0 * = In S 1 * = In S 1 S 0 +In S 0 Out = S 1 S 0 [00] [11] Out = 1 S1 S0 [01] [10] S1* S0* Out 0 0 0 1 0 0 0 0 1 0 1 1 0 0 1 0 0 1 1 1 Lecture 9: 30

Next Time H&H 2.9, 4.6, 4.9 More FSMs Timing, Clocking Lecture 9: 31