EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

Similar documents
EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

EECS150 - Digital Design Lecture 10 - Interfacing. Recap and Topics

Outline. EECS150 - Digital Design Lecture 27 - Asynchronous Sequential Circuits. Cross-coupled NOR gates. Asynchronous State Transition Diagram

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Lecture 11: Synchronous Sequential Logic

EECS150 - Digital Design Lecture 3 Synchronous Digital Systems Review. Announcements

Logic Design II (17.342) Spring Lecture Outline

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

Digital Fundamentals: A Systems Approach

Chapter 5: Synchronous Sequential Logic

More design examples, state assignment and reduction. Page 1

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Chapter 5. Introduction

Chapter 5 Synchronous Sequential Logic

Section 6.8 Synthesis of Sequential Logic Page 1 of 8

CS8803: Advanced Digital Design for Embedded Hardware

1. Convert the decimal number to binary, octal, and hexadecimal.

Universal Asynchronous Receiver- Transmitter (UART)

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

Universidad Carlos III de Madrid Digital Electronics Exercises

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

Chapter 2. Digital Circuits

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

ELCT201: DIGITAL LOGIC DESIGN

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

Digital System Design

Chapter 3. Boolean Algebra and Digital Logic

Advanced Digital Logic Design EECS 303

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

CPS311 Lecture: Sequential Circuits

Asynchronous (Ripple) Counters

EEC 118 Lecture #9: Sequential Logic. Rajeevan Amirtharajah University of California, Davis Jeff Parkhurst Intel Corporation

Finite State Machine Design

Digital Electronics II 2016 Imperial College London Page 1 of 8

Metastability Analysis of Synchronizer

CHAPTER 6 COUNTERS & REGISTERS

WEEK 10. Sequential Circuits: Analysis and Design. Page 1

EECS 373 Design of Microprocessor-Based Systems

Lec 24 Sequential Logic Revisited Sequential Circuit Design and Timing

Unit 11. Latches and Flip-Flops

Sequential Design Basics

INTEGRATED CIRCUITS. AN219 A metastability primer Nov 15

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

Synchronous Sequential Logic

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

Counters

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

Practice Homework Problems for Module 3

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS 150 Spring 2000

UC Berkeley CS61C : Machine Structures

CS3350B Computer Architecture Winter 2015

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

FPGA Implementation of Sequential Logic

Final Exam review: chapter 4 and 5. Supplement 3 and 4


Review of digital electronics. Storage units Sequential circuits Counters Shifters

CSE115: Digital Design Lecture 23: Latches & Flip-Flops


CSE Latches and Flip-flops Dr. Izadi. NOR gate property: A B Z Cross coupled NOR gates: S M S R Q M

Synchronous Sequential Logic

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 3 Logistics

Logic Design Viva Question Bank Compiled By Channveer Patil

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 2 Logistics

2 Sequential Circuits

EECS 373 Design of Microprocessor-Based Systems

6. Sequential Logic Flip-Flops

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

L5 Sequential Circuit Design

CS8803: Advanced Digital Design for Embedded Hardware

Clock and Asynchronous Signals

6.S084 Tutorial Problems L05 Sequential Circuits

EECS 270 Final Exam Spring 2012

Dr. Shahram Shirani COE2DI4 Midterm Test #2 Nov 19, 2008

ECE 301 Digital Electronics

Introduction to Sequential Circuits

Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

CS61C : Machine Structures

Laboratory Exercise 7

Digital Logic & Computer Design CS Professor Dan Moldovan Spring Chapter 3 :: Sequential Logic Design

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS150, Spring 2011

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Lecture 8: Sequential Logic

P U Q Q*

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

EECS 373 Design of Microprocessor-Based Systems

RS flip-flop using NOR gate

Sequential Logic Circuits

D Latch (Transparent Latch)

FIFO Memories: Solution to Reduce FIFO Metastability

Synchronous Sequential Logic

Note that none of the above MAY be a VALID ANSWER.

Go BEARS~ What are Machine Structures? Lecture #15 Intro to Synchronous Digital Systems, State Elements I C

ECE 263 Digital Systems, Fall 2015

Combinational / Sequential Logic

1.b. Realize a 5-input NOR function using 2-input NOR gates only.

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

Transcription:

EECS150 - Digital Design Lecture 15 Finite State Machines October 18, 2011 Elad Alon Electrical Engineering and Computer Sciences University of California, Berkeley http://www-inst.eecs.berkeley.edu/~cs150 Fall 2011 EECS150 Lecture 15 Page 1 Announcements Homework #7 due Thursday Ensure you start studying for the midterm! No new homework this week (Don t forget about project next checkpoint due 1 week after midterm) Midterm next Thurs. 6pm sharp Elad will hold a review session next Mon. evening Time/location TBD Fall 2011 EECS150 Lecture 15 Page 2

Asynchronous Inputs and Metastability Fall 2011 EECS150 Lecture 15 Page 3 Asynchronous Inputs to Synchronous Systems Many synchronous systems need to interface to asynchronous input signals Examples: Brute force solution: Fall 2011 EECS150 Lecture 15 Page 4

Synchronizer Circuit Fall 2011 EECS150 Lecture 15 Page 5 Synchronizer Circuit: What Not To Do Fall 2011 EECS150 Lecture 15 Page 6

Source of Synchronizer Failures Fall 2011 EECS150 Lecture 15 Page 7 Synchronizer Failure & Metastability Fall 2011 EECS150 Lecture 15 Page 8

Synchronizer Failure & Metastability If the system uses a synchronizer output while the output is still in the indeterminate (metastable) state synchronizer failure. Initial versions of several commercial ICs have suffered from metastability problems: AMD9513 system timing controller AMD9519 interrupt controller Zilog Z-80 Serial I/O interface Intel 8048 microprocessor AMD 29000 microprocessor Fall 2011 EECS150 Lecture 15 Page 9 Synchronizer Failure Solution Only real solution : WAIT LONG ENOUGH Long enough, according to Wakerly, is so that the mean time between synchronizer failures is several orders of magnitude longer than the designer s expected length of employment! In practice, can reduce probability of synchronizer failure to incredibly small values Fall 2011 EECS150 Lecture 15 Page 10

Reliable Synchronizer Design The probability that a flip-flop stays in the metastable state decreases exponentially with time. Therefore, any scheme that delays using the signal can be used to decrease the probability of failure. In practice, delaying the signal by a cycle is usually sufficient: If the clock period is greater than metastability resolution time plus FF2 setup time, FF2 gets a synchronized version of ASYNCIN. Multi-cycle synchronizers (using counters or more cascaded flipflops) are even better but often overkill. Fall 2011 EECS150 Lecture 15 Page 11 Now on to FSMs Fall 2011 EECS150 Lecture 15 Page 12

FSM Implementation FFs form state register number of states <= 2 number of flip-flops CL (combinational logic) calculates next state and output Remember: The FSM follows exactly one edge per cycle. So far we have learned how to implement in Verilog. Now we will learn how to design by hand at the gate level. Fall 2011 EECS150 Lecture 15 Page 13 Parity Checker Example A string of bits has even parity if the number of 1 s in the string is even. Design a circuit that accepts a bit-serial stream of bits and outputs a 0 if the parity thus far is even and outputs a 1 if odd: Next we take this example through the formal design process. But first, can you guess a circuit that performs this function? Fall 2011 EECS150 Lecture 15 Page 14

Parity Checker Example A string of bits has even parity if the number of 1 s in the string is even. Design a circuit that accepts a bit-serial stream of bits and outputs a 0 if the parity thus far is even and outputs a 1 if odd: We will next we take this example through the formal design process. But first, can you guess a circuit that performs this function? Fall 2011 EECS150 Lecture 15 Page 15 Formal Design Process State Transition Diagram circuit is in one of two states. transition on each cycle with each new input, over exactly one arc (edge). Output depends on which state the circuit is in. Fall 2011 EECS150 Lecture 15 Page 16

State Transition Table: present state Formal Design Process next OUT IN state EVEN 0 0 EVEN EVEN 0 1 ODD ODD 1 0 ODD ODD 1 1 EVEN Invent a code to represent states: Let 0 = EVEN state, 1 = ODD state present state (ps) OUT IN next state (ns) 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 0 Derive logic equations from table (how?): OUT = PS NS = PS xor IN Fall 2011 EECS150 Lecture 15 Page 17 Formal Design Process Fall 2011 EECS150 Lecture 15 Page 18

Review of Design Steps: Formal Design Process 1. Specify circuit function (English) 2. Draw state transition diagram 3. Write down symbolic state transition table 4. Write down encoded state transition table 5. Derive logic equations 6. Derive circuit diagram Register to hold state Combinational Logic for Next State and Outputs Fall 2011 EECS150 Lecture 15 Page 19 State Encoding In general: # of possible FSM state = 2 # of FFs Example: state1 = 01, state2 = 11, state3 = 10, state4 = 00 However, often more than log 2 (# of states) FFs are used, to simplify logic at the cost of more FFs. Extreme example is one-hot state encoding. Fall 2011 EECS150 Lecture 15 Page 20

One-hot encoding of states. One FF per state. State Encoding Why one-hot encoding? Simple design procedure. Circuit matches state transition diagram (example next page). Often can lead to simpler and faster next state and output logic. Why not do this? Can be costly in terms of FFs for FSMs with large number of states. FPGAs are FF rich, therefore one-hot state machine encoding is often a good approach. Fall 2011 EECS150 Lecture 15 Page 21 Even Parity Checker Circuit: One-hot encoded FSM Circuit generated through direct inspection of the STD. In General: FFs must be initialized for correct operation (only one 1) Fall 2011 EECS150 Lecture 15 Page 22

Another Ex: One-Hot Encoded Combination Lock Fall 2011 EECS150 Lecture 15 Page 23 General FSM form: FSM Implementation Notes All examples so far generate output based only on the present state: Commonly named Moore Machine (If output functions include both present state and input then called a Mealy Machine) Fall 2011 EECS150 Lecture 15 Page 24

Finite State Machines Example: Edge Detector Bit are received one at a time (one per cycle), such as: 000111010 time CLK Design a circuit that asserts its output for one cycle when the input bit stream changes from 0 to 1. IN FSM OUT Try two different solutions. Fall 2011 EECS150 Lecture 15 Page 25 State Transition Diagram Solution A ZERO CHANGE ONE IN PS NS OUT 0 00 00 0 1 00 01 0 0 01 00 1 1 01 11 1 0 11 00 0 1 11 11 0 Fall 2011 EECS150 Lecture 15 Page 26

Solution A, circuit derivation ZERO CHANGE ONE IN PS NS OUT 0 00 00 0 1 00 01 0 0 01 00 1 1 01 11 1 0 11 00 0 1 11 11 0 Fall 2011 EECS150 Lecture 15 Page 27 Solution B Output depends not only on PS but also on input, IN IN PS NS OUT Let ZERO=0, ONE=1 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 NS = IN, OUT = IN PS What s the intuition about this solution? Fall 2011 EECS150 Lecture 15 Page 28

Edge detector timing diagrams Solution A: output follows the clock Solution B: output changes with input rising edge and is asynchronous wrt the clock. Fall 2011 EECS150 Lecture 15 Page 29 FSM Comparison Solution A Moore Machine output function only of PS maybe morestates (why?) synchronous outputs no glitches one cycle delay full cycle of stable output Solution B Mealy Machine output function of both PS & input maybe fewer states asynchronous outputs if input glitches, so does output output immediately available output may not be stable long enough to be useful (below): If output of Mealy FSM goes through combinational logic before being registered, the CL might delay the signal and it could be missed by the clock edge. Fall 2011 EECS150 Lecture 15 Page 30

Final Notes on Moore versus Mealy 1. A given state machine could have both Moore and Mealy style outputs. Nothing wrong with this, but you need to be aware of the timing differences between the two types. 2. The output timing behavior of the Moore machine can be achieved in a Mealy machine by registering the Mealy output values: Fall 2011 EECS150 Lecture 15 Page 31 General FSM Design Process with Verilog Implementation Design Steps: 1. Specify circuit function (English) 2. Draw state transition diagram 3. Write down symbolic state transition table 4. Assign encodings (bit patterns) to symbolic states 5. Code as Verilog behavioral description Use parameters to represent encoded states. Use separate always blocks for register assignment and CL logic block. Use case for CL block. Within each case section assign all outputs and next state value based on inputs. Note: For Moore style machine make outputs dependent only on state not dependent on inputs. Fall 2011 EECS150 Lecture 15 Page 32