EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

Similar documents
Models for representing sequential circuits

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process

Ch 7. Finite State Machines. VII - Finite State Machines Contemporary Logic Design 1

EECS150 - Digital Design Lecture 23 - FSMs & Counters

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

Lecture 10: Synchronous Sequential Circuits Design

Example: vending machine

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec 09 Counters Outline.

EEE2135 Digital Logic Design

Synchronous Sequential Circuit Design. Digital Computer Design

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary

Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

Chapter 6. Synchronous Sequential Circuits

Generalized FSM model: Moore and Mealy

CprE 281: Digital Logic

EECS150 - Digital Design Lecture 15 SIFT2 + FSM. Recap and Outline

Present Next state Output state w = 0 w = 1 z A A B 0 B A C 0 C A C 1

Adders allow computers to add numbers 2-bit ripple-carry adder

Example: A vending machine

Different encodings generate different circuits

EECS150 - Digital Design Lecture 16 Counters. Announcements

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BENG (HONS) ELECTRICAL & ELECTRONICS ENGINEERING EXAMINATION SEMESTER /2017

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 9 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

EECS150 - Digital Design Lecture 17 - Sequential Circuits 3 (Counters)

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value

Review Problem 1. should be on. door state, false if light should be on when a door is open. v Describe when the dome/interior light of the car

Sequential Synchronous Circuit Analysis

ECE 341. Lecture # 3

Design of Datapath Controllers

FSM Optimization. Counter Logic Diagram Q1 Q2 Q3. Counter Implementation using RS FF 10/13/2015

Fundamentals of Digital Design

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

Synchronous Sequential Circuit Design. Dr. Ehab A. H. AL-Hialy Page 1

Last lecture Counter design Finite state machine started vending machine example. Today Continue on the vending machine example Moore/Mealy machines

The Design Procedure. Output Equation Determination - Derive output equations from the state table

Sequential logic and design

Digital Logic and Design (Course Code: EE222) Lecture 19: Sequential Circuits Contd..

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

CSE370: Introduction to Digital Design

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


ENGG 1203 Tutorial _03 Laboratory 3 Build a ball counter. Lab 3. Lab 3 Gate Timing. Lab 3 Steps in designing a State Machine. Timing diagram of a DFF

ALU, Latches and Flip-Flops

Finite State Machine (FSM)

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

ELEC Digital Logic Circuits Fall 2014 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10)

Lecture 8: Sequential Networks and Finite State Machines

Synchronous Sequential Logic

Total time is: 1 setup, 2 AND, 3 XOR, 1 delay = (1*1) + (2*2) + (3*3) + (1*1) = 15ns

Digital Design. Sequential Logic

CSC 322: Computer Organization Lab

6. Finite State Machines

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 7 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Clocked Sequential Circuits UNIT 13 ANALYSIS OF CLOCKED SEQUENTIAL CIRCUITS. Analysis of Clocked Sequential Circuits. Signal Tracing and Timing Charts

14.1. Unit 14. State Machine Design

Digital Logic Design - Chapter 5

Chapter 5 Synchronous Sequential Logic

Clocked Synchronous State-machine Analysis

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

ELEN Electronique numérique

10/12/2016. An FSM with No Inputs Moves from State to State. ECE 120: Introduction to Computing. Eventually, the States Form a Loop

Mealy & Moore Machines

LOGIC CIRCUITS. Basic Experiment and Design of Electronics

Digital Control of Electric Drives

CPE100: Digital Logic Design I

CSE140: Components and Design Techniques for Digital Systems. Midterm Information. Instructor: Mohsen Imani. Sources: TSR, Katz, Boriello & Vahid

Chapter 4 Part 2 Sequential Circuits

Analysis of clocked sequential networks

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

FSM model for sequential circuits

Appendix A: Digital Logic. Principles of Computer Architecture. Principles of Computer Architecture by M. Murdocca and V. Heuring

Sequential vs. Combinational

Laboratory Exercise #11 A Simple Digital Combination Lock

Finite State Machine. By : Ali Mustafa

CS221: Digital Design. Dr. A. Sahu. Indian Institute of Technology Guwahati

COE 202: Digital Logic Design Sequential Circuits Part 4. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

FSM Examples. Young Won Lim 11/6/15

Topic 8: Sequential Circuits

or 0101 Machine

FYSE420 DIGITAL ELECTRONICS

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

EGR224 F 18 Assignment #4

UNIT 8A Computer Circuitry: Layers of Abstraction. Boolean Logic & Truth Tables

WORKBOOK. Try Yourself Questions. Electrical Engineering Digital Electronics. Detailed Explanations of

COE 202: Digital Logic Design Sequential Circuits Part 3. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

ECE380 Digital Logic. Synchronous sequential circuits

COE 202: Digital Logic Design Sequential Circuits Part 3. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Lecture 7: Sequential Networks

CE1911 LECTURE FSM DESIGN PRACTICE DAY 1

CPE100: Digital Logic Design I

Logic. Combinational. inputs. outputs. the result. system can

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

State and Finite State Machines

Finite State Machines CS 64: Computer Organization and Design Logic Lecture #15 Fall 2018

Chapter 5 Synchronous Sequential Logic

Lab #10: Design of Finite State Machines

Transcription:

EECS 150 - Components and Design Techniques for Digital Systems FSMs 9/11/2007 Sarah Bird Electrical Engineering and Computer Sciences University of California, Berkeley Slides borrowed from David Culler Fa04 and Randy Katz Sp07

Sequential Logic Implementation Models for representing sequential circuits Finite-state machines (Moore and Mealy) Representation of memory (states) Changes in state (transitions) Design procedure State diagrams State transition table Next state functions CS 150 - Fall 2007 Moore and Mealy Machines - 2

Recall: What makes Digital Systems tick? Combinational Logic clk time CS 150 - Fall 2007 Moore and Mealy Machines - 3

Abstraction of State Elements Divide circuit into combinational logic and state Localize feedback loops and make it easy to break cycles Implementation of storage elements leads to various forms of sequential logic Inputs Combinational Logic Outputs State Inputs Storage Elements State Outputs CS 150 - Fall 2007 Moore and Mealy Machines - 4

Forms of Sequential Logic Asynchronous sequential logic state changes occur whenever state inputs change (elements may be simple wires or delay elements) Synchronous sequential logic state changes occur in lock step across all storage elements (using a periodic waveform - the clock) CS 150 - Fall 2007 Moore and Mealy Machines - 5 Clock

Finite State Machine Representations States: determined by possible values in sequential storage elements Transitions: change of state Clock: controls when state can change by controlling storage elements Sequential Logic 001 In = 0 In = 1 100 010 In = 1 In = 0 Sequences through a series of states Based on sequence of values on input signals Clock period defines elements of sequence 110 111 CS 150 - Fall 2007 Moore and Mealy Machines - 6

Can Any Sequential System be Represented with a State Diagram? Shift Register Input value shown on transition arcs Output values shown within state node IN CLK OUT1 OUT2 OUT3 D Q D Q D Q 1 100 110 1 0 1 1 1 0 000 1 010 101 0 111 1 0 0 0 1 0 001 011 0 CS 150 - Fall 2007 Moore and Mealy Machines - 7

Two Kinds of FSMs Moore Machine vs Mealy Machine Output (t) = Output (t) = G( state(t)) G( state(t), Input ) Input Input state state Combinational Logic state(t+1) = F ( state(t), input(t)) state(t+1) = F ( state(t), input) State / out Input State Input / Out CS 150 - Fall 2007 Moore and Mealy Machines - 8

Counters are Simple Finite State Machines Counters Proceed thru well-defined state sequence in response to enable Many types of counters: binary, BCD, Gray-code 3-bit up-counter: 000, 001, 010, 011, 100, 101, 110, 111, 000,... 3-bit down-counter: 111, 110, 101, 100, 011, 010, 001, 000, 111,... 001 010 011 000 3-bit up-counter 100 111 110 101 CS 150 - Fall 2007 Moore and Mealy Machines - 9

Verilog Upcounter module binary_cntr (q, clk) inputs clk; outputs [2:0] q; reg [2:0] q; reg [2:0] p; always @(q) //Calculate next state case (q) 3 b000: p = 3 b001; 3 b001: p = 3 b010; 3 b111: p = 3 b000; endcase always @(posedge clk) //next becomes current state q <= p; endmodule CS 150 - Fall 2007 Moore and Mealy Machines - 10

How Do We Turn a State Diagram into Logic? Counter Three flip-flops to hold state Logic to compute next state Clock signal controls when flip-flop memory can change Wait long enough for combinational logic to compute new value Don't wait too long as that is low performance OUT1 OUT2 OUT3 CLK D Q D Q D Q "1" CS 150 - Fall 2007 Moore and Mealy Machines - 11

FSM Design Procedure Start with counters Simple because output is just state Simple because no choice of next state based on input State diagram to state transition table Tabular form of state diagram Like a truth-table State encoding Decide on representation of states For counters it is simple: just its value Implementation Flip-flop for each state bit Combinational logic based on encoding CS 150 - Fall 2007 Moore and Mealy Machines - 12

FSM Design Procedure: State Diagram to Encoded State Transition Table Tabular form of state diagram Like a truth-table (specify output for all input combinations) Encoding of states: easy for counters just use value 000 001 111 010 3-bit up-counter 110 011 101 100 current state next state 0 000 001 1 1 001 010 2 2 010 011 3 3 011 100 4 4 100 101 5 5 101 110 6 6 110 111 7 7 111 000 0 CS 150 - Fall 2007 Moore and Mealy Machines - 13

Implementation D flip-flop for each state bit Combinational logic based on encoding C3 C2 C1 N3 N2 N1 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 0 0 0 notation to show function represent input to D-FF N1 := C1' N2 := C1C2' + C1'C2 := C1 xor C2 N3 := C1C2C3' + C1'C3 + C2'C3 := C1C2C3' + (C1' + C2')C3 := (C1C2) xor C3 N3 C3 N2 C3 N1 C3 0 0 1 1 0 1 1 0 1 1 1 1 C1 0 1 0 1 C1 1 0 0 1 C1 0 0 0 0 C2 C2 CS 150 - Fall 2007 Moore and Mealy Machines - 14 C2

Parity Checker FSM bit stream IN CLK Parity Checker OUT 0 if even parity 1 if odd parity example: 0 0 1 1 1 0 1 even even odd even odd odd even time 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. CS 150 - Fall 2007 Moore and Mealy Machines - 15

Formal Design Process State Transition Table: present state 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 CS 150 - Fall 2007 Moore and Mealy Machines - 16

Formal Design Process Logic equations from table: OUT = PS NS = PS xor IN Review of Design Steps: 1. Circuit functional specification Circuit Diagram: 2. State Transition Diagram 3. Symbolic State Transition Table ps ns 4. Encoded State Transition Table 5. Derive Logic Equations XOR gate for ns calculation DFF to hold present state no logic needed for output 6. Circuit Diagram FFs for state CL for NS and OUT CS 150 - Fall 2007 Moore and Mealy Machines - 17

Another example Door combination lock: punch in 3 values in sequence and the door opens; if there is an error the lock must be reset; once the door opens the lock must be reset inputs: sequence of input values, reset outputs: door open/close memory: must remember combination or always have it available as an input CS 150 - Fall 2007 Moore and Mealy Machines - 18

Sequential example: abstract control Finite-state diagram States: 5 states reset represent point in execution of machine each state has outputs Transitions: 6 from state to state, 5 self transitions, 1 global changes of state occur when clock says it s ok based on value of inputs Inputs: reset, new, results of comparisons Output: open/closed closed C1!=value C2!=value C3!=value & new & new & new S1 S2 S3 OPEN C1=value & new closed C2=value & new closed C3=value & new closed open ERR not new not new not new CS 150 - Fall 2007 Moore and Mealy Machines - 19

Sequential example (cont d): finite-state machine Finite-state machine generate state table (much like a truth-table) closed ERR Symbolic states reset closed mux=c1 not equal not equal & new not equal & new & new S1 S2 S3 OPEN closed closed open mux=c2 mux=c3 equal & new equal & new equal & new not new not new not new next reset new equal state state mux open/closed 1 S1 C1 closed 0 0 S1 S1 C1 closed 0 1 0 S1 ERR closed 0 1 1 S1 S2 C2 closed 0 0 S2 S2 C2 closed 0 1 0 S2 ERR closed 0 1 1 S2 S3 C3 closed 0 0 S3 S3 C3 closed 0 1 0 S3 ERR closed 0 1 1 S3 OPEN closed 0 OPEN OPEN open 0 ERR ERR closed CS 150 - Fall 2007 Moore and Mealy Machines - 20 Encoding?

Sequential example: encoding Encode state table state can be: S1, S2, S3, OPEN, or ERR needs at least 3 bits to encode: 000, 001, 010, 011, 100 and as many as 5: 00001, 00010, 00100, 01000, 10000 choose 4 bits: 0001, 0010, 0100, 1000, 0000 binary One-hot Encode outputs output mux can be: C1, C2, or C3 needs 2 to 3 bits to encode choose 3 bits: 001, 010, 100 output open/closed can be: open or closed needs 1 or 2 bits to encode choose 1 bits: 1, 0 hybrid CS 150 - Fall 2007 Moore and Mealy Machines - 21

Sequential example (cont d): encoding Encode state table state can be: S1, S2, S3, OPEN, or ERR choose 4 bits: 0001, 0010, 0100, 1000, 0000 output mux can be: C1, C2, or C3 choose 3 bits: 001, 010, 100 output open/closed can be: open or closed choose 1 bits: 1, 0 next reset new equal state state mux open/closed 1 0001 001 0 0 0 0001 0001 001 0 0 1 0 0001 0000 0 0 1 1 0001 0010 010 0 0 0 0010 0010 010 0 0 1 0 0010 0000 0 0 1 1 0010 0100 100 0 0 0 0100 0100 100 0 0 1 0 0100 0000 0 0 1 1 0100 1000 1 0 1000 1000 1 0 0000 0000 0 CS 150 - Fall 2007 Moore and Mealy Machines - 22 good choice of encoding! mux is identical to last 3 bits of next state open/closed is identical to first bit of state

State Minimization Fewer states may mean fewer state variables High-level synthesis may generate many redundant states Two state are equivalent if they are impossible to distinguish from the outputs of the FSM, i. e., for any input sequence the outputs are the same Two conditions for two states to be equivalent: 1) Output must be the same in both states 2) Must transition to equivalent states for all input combinations CS 150 - Fall 2007 Moore and Mealy Machines - 23

Sequential Logic Implementation Summary Models for representing sequential circuits Abstraction of sequential elements Finite state machines and their state diagrams Inputs/outputs Mealy, Moore, and synchronous Mealy machines Finite state machine design procedure Deriving state diagram Deriving state transition table Determining next state and output functions Implementing combinational logic CS 150 - Fall 2007 Moore and Mealy Machines - 24