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

Similar documents
EECS150 - Digital Design Lecture 23 - FSMs & Counters

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

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

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

Lecture 10: Synchronous Sequential Circuits Design

Generalized FSM model: Moore and Mealy

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

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

Example: vending machine

EECS150 - Digital Design Lecture 16 Counters. Announcements

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

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

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

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

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

State Graphs FSMs. Page 1

EECS 151/251A Fall 2018 Digital Design and Integrated Circuits. Instructor: John Wawrzynek & Nicholas Weaver. Lecture 5 EE141

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

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

Synchronous Sequential Circuit Design

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

Synchronous Sequential Circuit Design. Digital Computer Design

Chapter 6. Synchronous Sequential Circuits

FSM model for sequential circuits

Module 10: Sequential Circuit Design

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

Models for representing sequential circuits

Lecture 14 Finite state machines

Finite State Machine (FSM)

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output of

L10 State Machine Design Topics

Sequential Logic Optimization. Optimization in Context. Algorithmic Approach to State Minimization. Finite State Machine Optimization

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

Different encodings generate different circuits

Digital Logic Design - Chapter 5

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

State and Finite State Machines

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

Final Exam. ECE 25, Spring 2008 Thursday, June 12, Problem Points Score Total 90

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

Laboratory Exercise #11 A Simple Digital Combination Lock

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

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

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

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

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

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

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

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

EECS 270 Midterm Exam 2 Fall 2009

State & Finite State Machines

ECE380 Digital Logic. Synchronous sequential circuits

CE1911 LECTURE FSM DESIGN PRACTICE DAY 1

Design of Datapath Controllers

Example: A vending machine

EECS 270 Midterm 2 Exam Answer Key Winter 2017

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

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

Sequential Circuit Design

EEE2135 Digital Logic Design

CPE100: Digital Logic Design I

Timing Constraints in Sequential Designs. 63 Sources: TSR, Katz, Boriello & Vahid

Let s now begin to formalize our analysis of sequential machines Powerful methods for designing machines for System control Pattern recognition Etc.

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

15.1 Elimination of Redundant States

ALU, Latches and Flip-Flops

PAST EXAM PAPER & MEMO N3 ABOUT THE QUESTION PAPERS:

EGR224 F 18 Assignment #4

EE 209 Logic Cumulative Exam Name:


FSM Examples. Young Won Lim 11/6/15

For smaller NRE cost For faster time to market For smaller high-volume manufacturing cost For higher performance

Introduction EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 6: Sequential Logic 3 Registers & Counters 5/9/2010

Sequential logic and design

CPE100: Digital Logic Design I

State & Finite State Machines

Lecture 8: Sequential Networks and Finite State Machines

14.1. Unit 14. State Machine Design

CSE 140 Midterm 2 Tajana Simunic Rosing. Spring 2008

Chapter 5 Synchronous Sequential Logic

CprE 281: Digital Logic

Sequential Synchronous Circuit Analysis

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

Digital Circuits ECS 371

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

Analysis of Clocked Sequential Circuits

Chapter 6 Introduction to state machines

UC Berkeley College of Engineering, EECS Department CS61C: Representations of Combinational Logic Circuits

FYSE420 DIGITAL ELECTRONICS

EECS150 - Digital Design Lecture 21 - Design Blocks

CSE 140: Components and Design Techniques for Digital Systems. Lecture 9: Sequential Networks: Implementation

Ch 9. Sequential Logic Technologies. IX - Sequential Logic Technology Contemporary Logic Design 1

or 0101 Machine

State Machines ELCTEC-131

CSC 322: Computer Organization Lab

ECE 341. Lecture # 3

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

CS61c: Representations of Combinational Logic Circuits

Fundamentals of Digital Design

Transcription:

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: EECS150 - Digital Design Lecture 9 - Finite State Machines 1 February 15, 25 John Wawrzynek Can you guess a circuit that performs this function? Spring 25 EECS150 - Lec09-FSM1 Page 1 Spring 25 EECS150 - Lec09-FSM1 Page 2 bit stream IN CLK Parity Checker OUT 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. 0 if even parity 1 if odd parity example: 0 0 1 1 1 0 1 even even odd even odd odd even time Spring 25 EECS150 - Lec09-FSM1 Page 3 State Transition Table: present next state 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 Spring 25 EECS150 - Lec09-FSM1 Page 4 1

Logic equations from table: OUT = PS NS = PS xor IN Circuit Diagram: XOR gate for ns calculation DFF to hold present state no logic needed for output ps ns Review of Design Steps: 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 FFs for state CL for NS and OUT Spring 25 EECS150 - Lec09-FSM1 Page 5 Spring 25 EECS150 - Lec09-FSM1 Page 6 Finite State Machines (FSMs) FSM Implementation FSM circuits are a type of sequential circuit: output depends on present and past inputs fect of past inputs is represented by the current state Behavior is represented by State Transition Diagram: traverse one edge per clock cycle. 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. Spring 25 EECS150 - Lec09-FSM1 Page 7 Spring 25 EECS150 - Lec09-FSM1 Page 8 2

Combination Lock Example Announcements Exam next Tuesday (2/22) in class: Special review session Monday (2/21) 5-7pm, 125 Cory Check webpage for information on exam room assignment. Exam coverage HW / Quiz Used to allow entry to a locked room: 2-bit serial combination. Example 01,: 1. Set switches to 01, press ENTER 2. Set switches to, press ENTER 3. OPEN is asserted (OPEN=1). If wrong code, ERROR is asserted (after second combo word entry). Press Reset at anytime to try again. Spring 25 EECS150 - Lec09-FSM1 Page 9 Spring 25 EECS150 - Lec09-FSM1 Page Combinational Lock STD Symbolic State Transition Table RESET ENTER COM1 COM2 Preset State Next State OPEN ERROR 0 0 * * START START 0 0 0 1 0 * START BAD1 0 0 0 1 1 * START OK1 0 0 0 0 * * OK1 OK1 0 0 0 1 * 0 OK1 BAD2 0 0 0 1 * 1 OK1 OK2 0 0 0 * * * OK2 OK2 1 0 0 0 * * BAD1 BAD1 0 0 0 1 * * BAD1 BAD2 0 0 0 * * * BAD2 BAD2 0 1 1 * * * * START 0 0 Assume the ENTER button when pressed generates a pulse for only one clock cycle. Spring 25 EECS150 - Lec09-FSM1 Page Decoder logic for checking combination (01,): Spring 25 EECS150 - Lec09-FSM1 Page 12 3

ENTER COM1 COM2 PS2 PS1 PS0 NS2 NS1 NS0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 1 0 0 1 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 Encoded ST Table Assign states: START=0, OK1=1, OK2=0 BAD1=0, BAD2=1 Omit reset. Assume that primitive flip-flops has reset input. Rows not shown have don t cares in output. Correspond to invalid PS values. ab = ab = ab = NS2 NS1 NS0 01 01 01 01 ab = ab = ab = 01 What are the output functions for OPEN and ERROR? Spring 25 EECS150 - Lec09-FSM1 Page 13 01 01 01 ab = ab = ab = 01 01 01 01 General FSM form: FSM Implementation Notes All examples so far generate output based only on the present state: Commonly name Moore Machine (If output functions include both present state and input then called a Mealy Machine) Spring 25 EECS150 - Lec09-FSM1 Page 14 State Encoding One-hot encoding of states. One FF per state. State Encoding In general: # of possible FSM state = 2 # of FFs Example: state1 = 01, state2 =, state3 =, state4 = 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. 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, therore one-hot state machine encoding is often a good approach. Spring 25 EECS150 - Lec09-FSM1 Page 15 Spring 25 EECS150 - Lec09-FSM1 Page 16 4

Even Parity Checker Circuit: One-hot encoded FSM One-hot encoded combination lock Circuit generated through direct inspection of the STD. In General: FFs must be initialized for correct operation (only one 1) Spring 25 EECS150 - Lec09-FSM1 Page 17 Spring 25 EECS150 - Lec09-FSM1 Page 18 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. Spring 25 EECS150 - Lec09-FSM1 Page 19 Moore FSMs in Verilog module FSM1(clk, rst, in1, in2,, out1, out2, ); input clk, rst, in1, in2, ; output out1, out2, ; parameter dault=2'bxx; parameter s1=2'b; parameter s2=2'b01; reg out1, out2, ; reg [1:0] ps, ns; If you deviate from this template, do so only with care. For example, for some FSMs you might simplify the code by factoring out common output assignments from the cases: always @(posedge clk) if (rst) ps <= s0; else ps <= ns; always @(ps in1 in2 ) case (ps) s1 : begin out1 = ; out2 = ; if (in1 && in2 ) ns = s2; else ns = s2; end s2 : begin end dault: begin out1 = 1 bx; ns = dault; end always @(ps in1 in2 ) begin out1 = 1 b0; case (ps) sn: begin out1 = 1 b1; Similar example is unlock and error outputs in combo lock. Spring 25 EECS150 - Lec09-FSM1 Page 20 5