Unit 8: Sequ. ential Circuits

Similar documents
Lecture 14: State Tables, Diagrams, Latches, and Flip Flop

CS61C : Machine Structures

CS61C : Machine Structures

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

14.1. Unit 14. State Machine Design

Lecture 10: Synchronous Sequential Circuits Design

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

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

EET 310 Flip-Flops 11/17/2011 1

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

CSE370 HW6 Solutions (Winter 2010)

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

ECE 341. Lecture # 3

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

CprE 281: Digital Logic

Lecture 8: Sequential Networks and Finite State Machines

Memory, Latches, & Registers

Computers also need devices capable of Storing data and information Performing mathematical operations on such data

Memory Elements I. CS31 Pascal Van Hentenryck. CS031 Lecture 6 Page 1

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

Different encodings generate different circuits

Latches. October 13, 2003 Latches 1

Fundamentals of Digital Design

Chapter 3 Digital Logic Structures

Sequential Logic (3.1 and is a long difficult section you really should read!)

Combinational vs. Sequential. Summary of Combinational Logic. Combinational device/circuit: any circuit built using the basic gates Expressed as

Topic 8: Sequential Circuits

CPE100: Digital Logic Design I

Menu. Master-Slave Flip-Flop

EE 209 Logic Cumulative Exam Name:

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

Design of Sequential Circuits

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

Week-5. Sequential Circuit Design. Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA.

CPSC 121: Models of Computation

FSM model for sequential circuits

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

Deterministic Finite Automata

Lecture 13: Sequential Circuits, FSM

Learning Goals: In-Class. Using Logical Equivalences. Outline. Worked Problem: Even Squares

Logic and Computer Design Fundamentals. Chapter 8 Sequencing and Control

or 0101 Machine

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

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

Synchronous Sequential Circuit Design. Digital Computer Design

Finite State Machine (FSM)

CSE 105 Theory of Computation Professor Jeanne Ferrante

Digital Control of Electric Drives

ALU A functional unit

Synchronous Sequential Circuit Design

Synchronous Sequential Logic

UNIVERSITY OF WISCONSIN MADISON

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

Lecture 14 Finite state machines

Roger L. Tokheim. Chapter 8 Counters Glencoe/McGraw-Hill

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

ELCT201: DIGITAL LOGIC DESIGN

14:332:231 DIGITAL LOGIC DESIGN

Lecture 7: Logic design. Combinational logic circuits

Chapter 6 Introduction to state machines

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

Sequential Logic Circuits

Building a Computer Adder

Lecture 12: Adders, Sequential Circuits

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

CPE100: Digital Logic Design I

Adders, subtractors comparators, multipliers and other ALU elements

Finite Automata Part Two

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

Q: Examine the relationship between X and the Next state. How would you describe this circuit? A: An inverter which is synched with a clock signal.

Sequential Circuit Analysis

Digital Electronics Sequential Logic

Overview. Design Example: Automobile Lock

CPE100: Digital Logic Design I

Simplify the following Boolean expressions and minimize the number of literals:

CMPE12 - Notes chapter 2. Digital Logic. (Textbook Chapters and 2.1)"

Lecture 13: Sequential Circuits, FSM

Sequential Logic. Rab Nawaz Khan Jadoon DCS. Lecturer COMSATS Lahore Pakistan. Department of Computer Science

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

Digital Circuit Engineering

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

Topic 8: Sequential Circuits. Bistable Devices. S-R Latches. Consider the following element. Readings : Patterson & Hennesy, Appendix B.4 - B.

Laboratory Exercise #8 Introduction to Sequential Logic

Boolean Algebra and Digital Logic

Laboratory Exercise #11 A Simple Digital Combination Lock

6. Finite State Machines

Chapter 4. Sequential Logic Circuits

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

Adders, subtractors comparators, multipliers and other ALU elements

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

Finite Automata. Finite Automata

Lecture 7: Sequential Networks

Compute the Fourier transform on the first register to get x {0,1} n x 0.

Lab #10: Design of Finite State Machines

Design Example: 4-bit Sequence Detector

Sequential Logic Worksheet

Deterministic Finite Automaton (DFA)

Problem Set 9 Solutions

CS1800: Hex & Logic. Professor Kevin Gold

Deterministic Finite Automata (DFAs)

Transcription:

CPSC 121: Models of Computation Unit 8: Sequ ential Circuits Based on slides by Patrice Be lleville and Steve Wolfman

Pre-Class Learning Goals By the start of class, you s hould be able to Trace the operation of a DFA (deterministic finite-state automaton) represented as a diagram on an input, and indicate whether the DFA accepts or rejects the input. Deduce the language accepted by a simple DFA after working through h multiple l example inputs. 2

Quiz 8 feedback: Over all: Issues : Push-button light question: We will revisit this problem soon. 3

In-Class Learning G oals By the end of this unit, you should be able to: Translate a DFA into a sequential circuit that implements the DFA. Explain how and why each part of the resulting circuit works. 4

?? Related to CPSC 12 21 Bib Questions? How can we build a c omputer that is able to execute a user-defined program? Computers execute instr ructions one at a time. They need to rememberr values, unlike the circuits you designed in labs 1, 2, 3 and 4.? NOW: We are learning to build a new kind of circuits with memory that will be the key new feature we need to build full-blown computers!? 5?

Unit Outline Latches, toggles and flip-flops. DFA Example : Branch prediction. Implementing DFAs Other problems and exercises. 6

Finite-State Automa ta There are two types of Finite -State Automata: Those whose output is determined solely by the final state (Moore machines). Used to match a string to a pattern. o Input validation. o Searching text for contents. o Lexical Analysis: the first step in a compiler or an interpreter. (define (fun x) (if (<= x 0) 1 (* x (fun (- x 1))))) ( define ( fun x ) ( if ( <= x 0 ) 1 ( * x ( fun ( - x 1 ) ) ) ) ) 7

Finite-State Automa ta Those that produce output t every time the state changes (Mealy machines). Examples: o Simple ciphers o Traffic lights controller. o Predicting branching in machine-language programs A circuit that implements a finite state machine of either type needs to remember the current state: It needs memory. 8

Are Combinational Circuits Enough? Problem: Design a circuit that changes state every time a button is pushed.? 9

DFA for Push-ButtonSwitch? pressed light off light on pressed This Deterministic Finite Automaton (DFA) isn t really about accepting/rejecting; its current state is the state of the light. 10

Departures from Com mbinational Circuits MEMORY: We need to remember the light s state. EVENTS: We need to act on a button push rather than in response to an input value. 11

How Do We Remem mber? We want a circuit that: Sometimes remembers its current state. Other times loads a new state and remembers it. Sounds like a choice. What circuit element do we have for modelling choices? 12

Mux Memory Howdoweuseamux we to store a bit of memory? We can choose to remember on a control value of 0 and to load a new state ona1 1. new data??? 0 1 output control We use 0 and 1 because that s how MUXes are usually labelled. 13

Mux Memory Howdoweuseamux we to store a bit of memory? We can choose to remember on a control value of 0 and to load a new state ona1 1. old output (q ) new data (d) 0 1 output (q) control (g) We use 0 and 1 because that s how MUXes are usually labelled. 14

D Latches We call a "mux-memory" ad-latch ( recall from lab #5) When g is low, the latch retains its current value. When g is high, it changes its value to d instead. g 15

D-Latch AD-latch looks like new dataa (D) control (G) D G Q output (Q) Why does the D Latch hav ve two inputs and one output when the mux inside has THREE inputs and one output? A. The D Latch is broken as is; it should have three inputs. B. A circuit can always ignore one of its inputs. C. One of the inputs is always true. D. One of the inputs is always false. E. None of these (but the D Latch is not broken as is). 16

Push-Button Switch What signal does the butto on generate? high low 17

Push-Button Switch Complete the circuit... 18

Push-Button Switch What is wrong with our solution? A. We should have used XOR instead of NOT. B. We designed an effective random bit generator. C. The delay introduced d by th he NOT gate is too long. D. There is some other problem with the circuit. E. Nothing is wrong. 19

A Timing Problem This toll booth has a simila ar problem. What is wrong with this booth? P.S. Call this a bar, not a gate, or we'll tie ourselves in (k)nots. From MIT 6.004, Fall 2002 20

A Timing Solution Instead use this: From MIT 6.004, Fall 2002 21

D- Flip-Flops The circuit version of this im mproved tollbooth is called a D-flip-flop: When control (G, Clock ) goes from 0 (low) to 1 (high), the flip-flop loads a new value from D. Otherwise, it maintains its current value. 22

Push-Button Switch: Solution And we get the following im mproved circuit for our button and light problem: 23

Push-Button Switch: Solution Using a D- flip-flop 24

Why Abstract? Logisim (and real circuits) behave very similarly: D flip-flops, T flip-flops, J-K flip-flops, and S-R flip-flops. have lots of flip-flops that all They have slightly different implementations and one could imagine i brilliant new designs that t are radically different inside. Abstraction ti allows us to build a good design at a high-h the level without worrying about details. 25

Unit Outline Latches, toggles and flip-flops. DFA Example : Branch prediction. Implementing DFAs Other problems and exercises. 26

Computer Instruction ns How do computers really execute programs? Programs written in a high-level language (Racket, Java) are translated into machine language. g A machine-language program is a sequence of very simple instructions. o Each instruction is a sequence of 0s and 1s. o Each instruction also has a human-readable version Humans don't like looking at long sequences of 0s and 1s. The human-readable e version is not actually part of the program. 27

Computer Instruction ns Example (modified to make 1. sum 0 2. is n = 0? 3. if true go to 7 4. sum sum + n 5. n n 1 6. goto 2 it easier to understand): 7.. Some instructions like instruction 3 (called branch instructions) may tell the computer that the next instruction to execute is not the next in the sequence (4), but elsewhere (7). 28

Computer Instruction ns To speed things up, a mod dern computer starts executing an instruction before the previous one is finished. This means that when it is if true go to 7 it does not yet know if the condition is true, and hence does not know if the next in nstruction is sum sum + n or instruction number 7. executing 29

Branch Prediction: Simple Guess So we want to be able to predict the outcome of a branch instruction. If we guess wrong, then we was done. will ignore some of the work that To pre-execute a branch, the computer guesses which instruction comes next. Here s one reasonable guess: If the last branch was taken (like going to (7) from (3)), take the next. If it was not taken (like go oing to (4) from (3)), don t take the next. 30

Branch Prediction: Simple Guess Here s the corresponding DFA. (Instead of accept/reject, we care about the current state.) taken yes taken not taken not taken no taken not taken yes no the last branch was taken the last branch was not taken we predict the next branch will be taken we predict the next branch will be not taken 31

Branch Prediction: Using Confidence We now add the confidence we gain from the previous prediction : If we guessed right our confidence will be high; otherwise it will be low. Therefore, we will keep track of two pieces of info: what we will predict (F = not branch, T = branch). how confident we are that we are correct (F = not very, T = very). Once we know if the branch was taken, we update this information. For instance: If the current prediction is to branch and we are confident then we'll predict to branch again, etc. 32

DFA Example: Bran ch Prediction How many states will the Finite State Automaton have now? A. 2 B. 4 C. 8 D. Another value less than 8. E. Another value larger than 8. 33

DFA Example: Bran ch Prediction Let us fill out a truth table that describes the behaviour we want of the automaton. Current State Taken? Next State Pred Conf? Pred Conf? F F F F T F F T T T F T F F T F T T F F T F F F T T F T T T T T F T F T T T T T 34

DFA Example: Bran ch Prediction Hence we get the following DFA: not taken yes? taken not taken NO! taken not taken no? not taken taken YES! taken Note: NO! no branch with high confidence no? no branch with low confidence YES! branch with high confidence yes? branch with low confidence 35

Unit Outline Latches, toggles and flip-flops. DFA Example : Branch prediction. Implementing DFAs Other problems and exercises. 36

Abstract Template fo or a DFA Circuit Each time the clock ticks next. move from one state to the clock input store current state compute next state 37

Template for a DFA Circuit Each time the clock ticks next. move from one state to the D CLK Q Combinational circuit to calculate next state/output input Each of these lines (except the clock) may carry multiple bits; the D flip-flop may be several flip-flops to store several bits. 38

Implementing DFAs HowdoweturnaDFAinto we o a circuit? Number the states, starting with 0, and figure out how many bits you need to store the state number. Number the inputs, starting with 0, and figure out how many bits you need to represent the input. Layout enough D flip-flops to store the state (one per bit). For each state, build a combinational circuit that computes the next state (and the outp ut, if needed) given the input. Send all those into multiplexers, and use the current state as the control signal (so you only keep the correct one). Store the next state back into the D flip-flops. 39

Implementing DFAs The circuit will look like the following: Next State circuits Compute Output 40

Implementing DFA for Branch Prediction Now let us assign numbers to states and inputs. Inputs: not taken = 0 taken = 1 Transition Table: Current State input New state 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 not taken NO! 0 taken not taken not taken no? 1 p yes? 2 not taken taken YES! 3 taken taken 41

Implementing DFA for Branch Prediction Here is the basic circuit: 42

Unit Outline Latches, toggles and flip-flops. DFA Example : Branch prediction. Implementing DFAs Other problems and exercises. 43

Exercises Real numbers: We can write numbers in decimal using the format (-)? d+ (.d+)? where the ( )? mean that the part in parentheses is optional, and d+ stands for 1 or more digits. Design a DFA that will accept input strings that are valid real numbers using this format. o You can use else as a label on an edge instead of listing every character that does not appear on another edge leaving from a state. 44

Exercises Real numbers (continued) Then design a circuit that turns a LED on if the input is a valid real number, and off otherwise. o Hint: Logisim has a keyboard component you can use. o Hint: my DFA for this problem has 6 states. Design a DFA for a vending machine that sells one of three items (lemon juice, whiteboard markers, and corn flour) for 35 each. It should accept 5, 10 and 25 coins, and does not need to return change. 45

Quiz #9 Due Date: Check Announc cements. Reading for the Quiz Textbook sections: Epp, 4th edition: 5.1 to 5.4 Epp, 3rd edition: 4.1 to 4.44 Rosen, 6th edition: 4.1, 4.2 Rosen, 7th edition: 5.1, 5.2 46