CPSC 121: Models of Computation

Slides:



Advertisements
Similar presentations
1 Introduction Sequential circuit –Output depends not just on present inputs (as in combinational circuit), but on past sequence of inputs Stores bits,
Advertisements

Digital Design - Sequential Logic Design Chapter 3 - Sequential Logic Design.
Chapter 1 — Computer Abstractions and Technology — 1 Lecture 7 Carry look ahead adders, Latches, Flip-flops, registers, multiplexors, decoders Digital.
1 Lecture 20 Sequential Circuits: Latches. 2 Overview °Circuits require memory to store intermediate data °Sequential circuits use a periodic signal to.
October 16, 2002Flip-flops1 Summary : Latches A sequential circuit has memory. It may respond differently to the same inputs, depending on its current.
Circuits require memory to store intermediate data
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 5 – Sequential Circuits Part 1 – Storage.
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits – I Flip-Flops A sequential circuit is a logic components whose outputs.
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
LOGIC GATES ADDERS FLIP-FLOPS REGISTERS Digital Electronics Mark Neil - Microprocessor Course 1.
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
Henry Hexmoor1 Chapter 7 Henry Hexmoor Registers and RTL.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Sequential Circuits (“Mealy Machines”) Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Sequential Circuits (“Mealy Machines”) Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Benjamin Israel Notes heavily borrowed from Steve Wolfman’s,
Computer ArchitectureFall 2008 © August 20 th, Introduction to Computer Architecture Lecture 2 – Digital Logic Design.
Chapter 1 Program Design
Sequential circuit design
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
Some Useful Circuits Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
COE 202: Digital Logic Design Sequential Circuits Part 1
CS1Q Computer Systems Lecture 8
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Building & Designing Sequential Circuits Steve Wolfman, based on notes by Patrice Belleville.
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
1 Boolean Algebra & Logic Gates. 2 Objectives Understand the relationship between Boolean logic and digital computer circuits. Learn how to design simple.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 8: Sequential Circuits.
1 Lecture 22 Sequential Circuits Analysis. 2 Combinational vs. Sequential  Combinational Logic Circuit  Output is a function only of the present inputs.
Introduction to State Machine
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Latches & Flip-Flops.
CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information.
Basic Concepts of Sequential Circuits Section Lecture 01.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
1 Lecture #11 EGR 277 – Digital Logic Ch. 5 - Synchronous Sequential Logic There are two primary classifications of logic circuits: 1.Combinational logic.
1Sequential circuit design Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA by Erol Sahin and Ruken Cakici.
Sequential Logic Computer Organization II 1 © McQuain A clock is a free-running signal with a cycle time. A clock may be either high or.
CS1Q Computer Systems Lecture 8
CO5023 Latches, Flip-Flops and Decoders. Sequential Circuit What does this do? The OUTPUT of a sequential circuit is determined by the current output.
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
CSE 140: Components and Design Techniques for Digital Systems Lecture 7: Sequential Networks CK Cheng Dept. of Computer Science and Engineering University.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
CS151 Introduction to Digital Design Chapter 5: Sequential Circuits 5-1 : Sequential Circuit Definition 5-2: Latches 1Created by: Ms.Amany AlSaleh.
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
REGISTER TRANSFER LANGUAGE (RTL) INTRODUCTION TO REGISTER Registers1.
5-1-2 Synchronous counters. Learning Objectives: At the end of this topic you will be able to: draw a block diagram showing how D-type flip-flops can.
Sequential Circuit Design 05 Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA.
COMBINATIONAL AND SEQUENTIAL CIRCUITS Guided By: Prof. P. B. Swadas Prepared By: BIRLA VISHVAKARMA MAHAVDYALAYA.
Chapter 3 Boolean Algebra and Digital Logic T103: Computer architecture, logic and information processing.
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
Mealy and Moore Machines Lecture 8 Overview Moore Machines Mealy Machines Sequential Circuits.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
CPSC 121: Models of Computation 2008/9 Winter Term 2
Digital Design - Sequential Logic Design
Combinational circuits
REGISTER TRANSFER LANGUAGE (RTL)
CPSC 121: Models of Computation 2016W2
Clocks A clock is a free-running signal with a cycle time.
COMP541 Sequential Logic – 2: Finite State Machines
Assistant Prof. Fareena Saqib Florida Institute of Technology
Sequential Circuits: Flip-Flops
CSE 370 – Winter Sequential Logic - 1
The Processor Lecture 3.1: Introduction & Logic Design Conventions
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
Sequential circuit analysis
CPSC 121: Models of Computation
EGR 2131 Unit 12 Synchronous Sequential Circuits
CPSC 121: Models of Computation
Registers Today we’ll see some common sequential devices: counters and registers. They’re good examples of sequential analysis and design. They are also.
Finite State Machine Continued
Instructor: Michael Greenbaum
Presentation transcript:

CPSC 121: Models of Computation Unit 8: Sequential Circuits

Pre-Class Learning Goals By the start of class, you should 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 multiple example inputs. Unit 8 - Sequential Circuits

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

In-Class Learning Goals 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. Unit 8 - Sequential Circuits

Related to CPSC 121 Bib Questions ? ? Related to CPSC 121 Bib Questions How can we build a computer that is able to execute a user-defined program? Computers execute instructions one at a time. They need to remember 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! Unit 8 - Sequential Circuits

Unit Outline Sequential Circuits :Latches, and flip-flops. DFA Example Implementing DFAs How Powerful are DFAs? Other problems and exercises. Unit 8 - Sequential Circuits

Problem: Light Switch ? Problem: Design a circuit to control a light so that the light changes state any time its “push-button” switch is pressed. ? Unit 8 - Sequential Circuits

DFA for Push-Button Switch ? DFA for Push-Button Switch 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.

Problem: Light Switch ? Problem: Design a circuit to control a light so that the light changes state any time its “push-button” switch is pressed. Identifying inputs/outputs: consider these possible inputs and outputs: Input1: the button was pressed Input2: the button is down Output1: the light is on Output2: the light changed states Which are most useful for this problem? Input1 and Output1 Input1 and Output2 Input2 and Output1 Input2 and Output2 None of these [2011W1] REPEAT of the Lecture 2 question on light switches, but this time it’s the EVENT of button press that we care about AND (both as input and as output) the state of the light (being on or off).

Departures from Combinational 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.

How Do We Remember? We want a circuit that: Sounds like a choice. 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? A MUX

“Mux Memory” How do we use a mux to store a bit of memory? We choose to remember on a control value of 0 and to load a new state on a 1. ??? output new data 1 control We use “0” and “1” because that’s how MUXes are usually labelled.

“Mux Memory” How do we use a mux to store a bit of memory? We choose to remember on a control value of 0 and to load a new state on a 1. old output (Q’) output (Q) new data (D) 1 control (G) This violates our basic combinational constraint: no cycles.

Truth Table for “Muxy Memory” Fill in the MM’s truth table: a. b. c. d. e. G D Q' 1 Q 1 Q 1 Q 1 X Q 1 None of these

Truth Table for “Muxy Memory” Worked Problem: Write a truth table for the MM: G D Q' Q 1 Like a “normal” mux table, but what happens when Q'  Q?

Truth Table for “Muxy Memory” Worked Problem: Write a truth table for the MM: G D Q' Q 1 Q' “takes on” Q’s value at the “next step”.

D Latches We call a "mux-memory" a D-latch ( recall from lab #5) When G is 0, the latch retains its current value. When G is 1, the latch loads a new value from D. old output (Q’) output (Q) new data (D) 1 control (G) Unit 8 - Sequential Circuits

D Latch When G is 0, the latch maintains its memory. When G is 1, the latch loads a new value from D. D Q G new data (D) output (Q) control (G)

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

Using the D Latch for Circuits with Memory Problem: What goes in the cloud? What do we send into G? D Combinational Circuit to calculate next state Q ?? G input We assume we just want Q as the output.

Push-Button Switch What signal does the button generate? high low Unit 8 - Sequential Circuits

Using the D Latch for Our Light Switch Problem: What do we send into G? D G Q current light state ?? output T if the button is down, F if it’s up. T if the button is up, F if it’s down. Neither of these.

Using the D Latch for Our Light Switch Problem: What should be the next state of the light? D G Q current light state “pulse” when button is pressed ?? output button pressed

Using the D Latch for Our Light Switch Problem: Will this work? D G Q current light state “pulse” when button is pressed ?? output button pressed

Push-Button Switch What is wrong with our solution? We should have used XOR instead of NOT. As long as the button is down, D flows to Q, and it flows through the NOT gate and back to D...which is bad! The delay introduced by the NOT gate is too long. As long as the button is down, Q flows to D, and it flows back to Q... and Q (the output) does not change! There is some other problem with the circuit. Unit 8 - Sequential Circuits

A Timing Problem This toll booth has a similar 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 Unit 8 - Sequential Circuits

A Timing Solution Is this OK? From MIT 6.004, Fall 2002 Unit 8 - Sequential Circuits

A Timing Problem Problem: What do we send into G? D Q current light state “pulse” when button is pressed output button pressed As long as the button is down, D flows to Q flows through the NOT gate and back to D... which is bad!

A Timing Solution (Almost) D G Q D G Q Never raise both “bars” at the same time. output button pressed

A Timing Solution D G Q D G Q ?? output The two latches are never enabled at the same time (except for the moment needed for the NOT gate on the left to compute, which is so short that no “cars” get through).

A Timing Solution D G Q D G Q button press signal output button pressed

Button/Clock is LO (unpressed) 1 D G Q 1 D G Q 1 output LO We’re assuming the circuit has been set up and is “running normally”. Right now, the light is off (i.e., the output of the right latch is 0).

Button goes HI (is pressed) 1 D G Q 1 D G Q 1 output HI 1 This stuff is processing a new signal.

Propagating signal.. left NOT, right latch 1 D G Q 1 D G Q 1 output HI 1 This stuff is processing a new signal.

Propagating signal.. right NOT (steady state) D G Q 1 D G Q 1 output HI 1 Why doesn’t the left latch update? Its D input is 0. Its G input is 0. Its Q output is 1. It should update!

Button goes LO (released) D G Q 1 D G Q 1 output LO This stuff is processing a new signal.

Propagating signal.. left NOT D G Q 1 D G Q 1 1 output LO This stuff is processing a new signal.

Propagating signal.. left latch (steady state) D G Q D G Q 1 1 output LO And, we’re done with one cycle. How does this compare to our initial state?

Master/Slave D Flip-Flop Symbol + Semantics When CLK goes from 0 (low) to 1 (high), the flip-flop loads a new value from D. Otherwise, it maintains its current value. new data (D) D G Q D G Q output (Q) control or “clock” signal (CLK)

Master/Slave D Flip-Flop Symbol + Semantics When CLK goes from 0 (low) to 1 (high), the flip-flop loads a new value from D. Otherwise, it maintains its current value. new data (D) D G Q D G Q output (Q) control or “clock” signal (CLK)

Master/Slave D Flip-Flop Symbol + Semantics When CLK goes from 0 (low) to 1 (high), the flip-flop loads a new value from D. Otherwise, it maintains its current value. new data (D) output (Q) control or “clock” signal (CLK)

Master/Slave D Flip-Flop Symbol + Semantics When CLK goes from 0 (low) to 1 (high), the flip-flop loads a new value from D. Otherwise, it maintains its current value. D Q clock signal output new data We rearranged the clock and D inputs and the output to match Logisim. Below we use a slightly different looking flip-flop.

Push-Button Switch: Solution Using a D- flip-flop Unit 8 - Sequential Circuits

Why Abstract? Logisim (and real circuits) have lots of flip-flops that all behave very similarly: D flip-flops, T flip-flops, J-K flip-flops, and S-R flip-flops. They have slightly different implementations… and one could imagine brilliant new designs that are radically different inside. Abstraction allows us to build a good design at a high-level without worrying about the details. Plus… it means you only need to learn about D flip-flops’ guts. The others are similar enough so we can just take the abstraction for granted.

Unit Outline Sequential Circuits :Latches, and flip-flops. DFA Example Implementing DFAs How Powerful are DFAs? Other problems and exercises. Unit 8 - Sequential Circuits

Finite-State Automata 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. Input validation. Searching text for contents. 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 <= 1 * - Unit 8 - Sequential Circuits

Finite-State Automata Those that produce output every time the state changes (Mealy machines). Examples: Simple ciphers Traffic lights controller. 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. Unit 8 - Sequential Circuits

DFA Example Suppose we want to design a Finite State Automaton with input alphabet {a, b} that accepts the sets of all strings that contain exactly two b's. How many states will the DFA have? 2 4 8 Another value less than 8. Another value larger than 8. Unit 8 - Sequential Circuits

The DFA Can you check that it is correct? Can we design a circuit for it? Unit 8 - Sequential Circuits

Unit Outline Latches, toggles and flip-flops. DFA Example Implementing DFAs How Powerful are DFAs? Other problems and exercises. Unit 8 - Sequential Circuits

Abstract Template for a DFA Circuit Each time the clock “ticks” move from one state to the next. store current state compute next state clock input

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

Implementing DFAs in General Number the states and figure out b: the number of bits needed to store the state number. Lay out b D flip-flops. Together, their memory is the state as a binary number. For each state, build a combinational circuit that determines the next state given the input. Send the next states into a MUX with the current state as the control signal: only the appropriate next state gets used! Use the MUX’s output as the new state of the flip-flops. With a separate circuit for each state, they’re often very simple! Unit 8 - Sequential Circuits

Implementing the example: Step 1 What is b (the number of 1-bit flip-flops needed to represent the state)? 0, no memory needed 1 2 3 None of these As always, we use numbers to represent the inputs: a = 0 b = 1

Just Truth Tables... Reminder: a = 0 b = 1 What’s in this row? 0 0 0 1 Current State input New state 1 What’s in this row? 0 0 0 1 1 0 1 1 None of these.

Just Truth Tables... Reminder: a = 0 b = 1 Current State input New state 1

Implementing the example: Step 2 We always use this pattern. In this case, we need two flip-flops. D Q D Q Combinational circuit to calculate next state/output CLK input Let’s switch to Logisim schematics...

Implementing the example: Step 3 D D Q ?? CLK sleft input ??? sright input

Implementing the example: Step 4 sleft ??? sright input

Implementing the example: Step 5 (easier than 4!) The MUX “trick” here is much like in the ALU from lab! What is the next state for each current state?? EMPHASIZE that the labels on the mux inputs are NOT input values; they’re just telling us which state’s new value feeds into that wire.

Implementing the example: Step 4 sleft sright input sleft' sright' 1 What is the next state for each current state?? [2011W1] TODO: consider moving the question elsewhere to uncover input pin? (On this AND subsequent slides.) In state number 0, what should be the new value of sleft? Hint: look at the DFA, not at the circuit! input ~input 1 None of these.

Implementing the example : Step 4 sleft sright input sleft' sright' 1 What is the next state for each current state?? In state number 1, what’s the new value of sleft? input ~input 1 None of these.

Implementing the example : Step 4 sleft sright input sleft' sright' 1 What is the next state for each current state?? In state number 2, what’s the new value of sleft? input ~input 1 None of these.

Implementing the example : Step 4 sleft sright input sleft' sright' 1 What is the next state for each current state?? In state number 3, what’s the new value of sleft? input ~input 1 None of these.

Just Truth Tables... sleft sright input sleft' sright' 1

Implementing the example : Step 4 Current State input New state 1 In state number 0, what’s the new value of sright? input ~input 1 None of these.

Implementing the example: Complete

Outline Sequential Circuits :Latches, and flip-flops. DFA Example Implementing DFAs How Powerful are DFAs? Other problems and exercises.

How Powerful Is a DFA? DFAs can model situations with a finite amount of memory, finite set of possible inputs, and particular pattern to update the memory given the inputs. How does a DFA compare to a modern computer? Modern computer is more powerful. DFA is more powerful. They’re the same.

Where We’ll Go From Here... We’ll come back to DFAs again later in lecture. In lab you have been and will continue to explore what you can do once you have memory and events. And, before long, how you combine these into a working computer! Also in lab, you’ll work with a widely used representation equivalent to DFAs: regular expressions.

Unit Outline Sequential Circuits :Latches, and flip-flops. DFA Example Implementing DFAs How Powerful are DFAs? Other problems and exercises. Unit 8 - Sequential Circuits

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. 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. Unit 8 - Sequential Circuits

Exercises Real numbers (continued) Then design a circuit that turns a LED on if the input is a valid real number, and off otherwise. Hint: Logisim has a keyboard component you can use. Hint: my DFA for this problem has 6 states. Design a DFA with outputs to control a set of traffic lights. Thought: try allowing an output that sets a timer which in turn causes an input like our “button press” when it goes off. Variants to try: - Pedestrian cross-walks - Turn signals - Inductive sensors to indicate presence of cars - Left-turn signals Unit 8 - Sequential Circuits

Quiz #9 Due Date: Check Announcements. Reading for the Quiz Textbook sections: Epp, 4th edition: 5.1 to 5.4 Epp, 3rd edition: 4.1 to 4.4 Rosen, 6th edition: 4.1, 4.2 Rosen, 7th edition: 5.1, 5.2 Unit 8 - Sequential Circuits