CPSC 121: Models of Computation 2008/9 Winter Term 2

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.
Sequential Circuits1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
Circuits require memory to store intermediate data
Dr. ClincyLecture1 Appendix A – Part 2: Logic Circuits Current State or output of the device is affected by the previous states Circuit Flip Flops New.
Lecture 22: Sequential Circuits Today’s topic –Clocks and sequential circuits –Finite state machines 1.
LOGIC GATES ADDERS FLIP-FLOPS REGISTERS Digital Electronics Mark Neil - Microprocessor Course 1.
CPSC 121: Models of Computation
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Introduction to Induction Steve Wolfman 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 DFAs in Depth Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Sequential Circuits (“Mealy Machines”) Steve Wolfman, based on notes by Patrice Belleville.
CS 300 – Lecture 3 Intro to Computer Architecture / Assembly Language Sequential Circuits.
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 A Working Computer Slides based on work by Bob Woodham and others.
1 Sequential Circuits Registers and Counters. 2 Master Slave Flip Flops.
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Building & Designing Sequential Circuits Steve Wolfman, based on notes by Patrice Belleville.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 8: Sequential Circuits.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Introduction to State Machine
Chapter 3 Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Complete Example.
Basic Concepts of Sequential Circuits Section Lecture 01.
Registers; State Machines Analysis Section 7-1 Section 5-4.
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.
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.
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.
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.
Digital Logic Structures: Chapter 3 COMP 2610 Dr. James Money COMP
Sequential logic circuits First Class 1Dr. AMMAR ABDUL-HAMED KHADER.
Digital Design - Sequential Logic Design
Basics of Logic gates - Part 2
Combinational circuits
FLIP FLOPS Binary unit capable of storing one bit – 0 or 1
The 8085 Microprocessor Architecture
Registers and Counters
AS Computer Studies Finite State Machines 1.
CPSC 121: Models of Computation 2016W2
Clocks A clock is a free-running signal with a cycle time.
Computer Organization
Copyright © Cengage Learning. All rights reserved.
Analysis of Clocked Sequential Circuit
The 8085 Microprocessor Architecture
COMP541 Sequential Logic – 2: Finite State Machines
Sequential Logic and Flip Flops
Chapter 4 Gates and Circuits.
Sequential Logic and Flip Flops
Boolean Algebra and Digital Logic
Instructor: Alexander Stoytchev
CSE 370 – Winter Sequential Logic - 1
Lecture 15 Logistics Last lecture Today HW4 is due today
Instructor: Alexander Stoytchev
Introduction to Sequential Circuits
CSE 370 – Winter Sequential Logic-2 - 1
Instructor: Alexander Stoytchev
The 8085 Microprocessor Architecture
ECE 352 Digital System Fundamentals
Flip-Flops.
Sequential circuit analysis
CPSC 121: Models of Computation
CPSC 121: Models of Computation 2008/9 Winter Term 2
EGR 2131 Unit 12 Synchronous Sequential Circuits
CPSC 121: Models of Computation
Announcements Assignment 7 due now or tommorrow Assignment 8 posted
Finite State Machine Continued
Presentation transcript:

CPSC 121: Models of Computation 2008/9 Winter Term 2 Sequential Circuits (“Mealy Machines”) Steve Wolfman, based on notes by Patrice Belleville and others

Lecture Prerequisites Read Section 12.2 pages 745-747 and “Designing a Finite Automaton” on 752-754 (skipping part b of the examples). We’ll reread and revisit this later; focus on getting a strong intuitive sense of how DFAs work. Solve problems like Exercise Set 12.2 #1, #12a-c, #13a-c, and #14-19a. Complete the open-book, untimed quiz on Vista that was due before class.

Learning Goals: “Pre-Class” We are mostly departing from the readings for next class to talk about a new kind of circuit on our way to a full computer: sequential circuits. The pre-class goals are to be able to: Trace the operation of a deterministic finite-state automaton (represented as a diagram) on an input, including indicating whether the DFA accepts or rejects the input. Deduce the language accepted by a simple DFA after working through multiple example inputs.

Quiz 8: Does this accept the empty string? a,b,c b 1 a 2 a 3 b,c c

Learning Goals: In-Class 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. Discuss point of learning goals.

Problem: Toggle Light Switch Problem: Design a circuit to control a light so that the light changes state any time its “push-button” switch is pressed. (Like the light switches in Dempster.)

Concept Q: Toggle Switch How many gates does the circuit take? One Two Three None of these (b/c it’s a different number) None of these (b/c it can’t be done)

A “DFA” for the Light Switch toggle light off light on toggle This “DFA” isn’t really about accepting/rejecting. Instead, its current state indicates the state of the light.

Departures from Combinational Circuits We need memory so we can “remember” what state the light is in. We need to act on an event (a button push/toggle) rather than in response to an input value.

Worked Problem: Muxy Memory Worked Problem: How can we use a mux to store a bit of memory? Let’s have it output the stored bit when the control is 0 and load a new value when the control is 1. ??? output new data 1 control

Worked Problem: Muxy Memory Worked Problem: How can we use a mux to store a bit of memory? Let’s have it output the stored bit when the control is 0 and load a new value when the control is 1. old output (Q’) output (Q) new data (D) 1 control (G) This violates our basic combinational constraint: no cycles.

Worked Problem: Truth Table for Muxy Memory (AKA D Latch) Worked Problem: Write a truth table for the D Latch. G D Q' Q 1

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

Worked Problem: Truth Table for Muxy Memory (AKA D Latch) Worked Problem: Write a truth table for the D Latch. G D Q' Q 1 Like a “normal” mux table, but Q' then takes on Q’s value.

D Latch Symbol + Semantics When G is low, the latch maintains its memory. When G is high, the latch loads a new value from D. old output (Q’) output (Q) new data (D) 1 control (G)

D Latch Symbol + Semantics When G is low, the latch maintains its memory. When G is high, the latch loads a new value from D. old output (Q’) output (Q) new data (D) 1 control (G)

D Latch Symbol + Semantics When G is low, the latch maintains its memory. When G is high, the latch loads a new value from D. D G Q new data (D) output (Q) control (G)

Using the D Latch for Circuits with Memory Problem: What do we send into G? D G Q Combinational Circuit to calculate next state ?? input output

Using the D Latch for Our Light Switch Problem: What do we send into G? D G Q current light state ?? input output

“pulse” when button is pressed A Timing Problem Problem: What do we send into G? D G 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 Problem, Metaphor (from MIT 6.004, Fall 2002) What’s wrong with this tollbooth?

A Timing Solution, Metaphor (from MIT 6.004, Fall 2002) Is this one OK?

“pulse” when button is pressed A Timing Problem Problem: What do we send into G? D G 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 (Almost) D G Q D G Q ?? output Any time we disable the first latch, we enable the second latch a moment later. Any time we enable the first latch, we disable the second latch a moment later (but not so long that any “cars” get through).

A Timing Solution (Almost) Problem: What do we send into G? D G Q D G Q ?? output Unfortunately, our second latch enables (and so our solution loads new data) when the input signal goes low. We want it to work when the input goes high. So...

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

Master/Slave D Flip-Flop Symbol + Semantics When CLK goes from low to 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 low to 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 low to 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 low to high, the flip-flop loads a new value from D. Otherwise, it maintains its current value. D Q new data output clock signal

A Timing Solution D Q button press signal output

General Implementation of DFAs as “Mealy Machines” Each time the clock “ticks” move from one state to the next. D Q Combinational circuit to calculate next state/output CLK input output Each of these lines (except the clock) may carry multiple bits; the D flip-flop may be several flip-flops to store several bits.

A Mealy-Style “DFA” for the Light Switch toggle, on no toggle, on off state on state no toggle, off toggle, off This “DFA” isn’t really about accepting/rejecting. Instead, we output a “command” to the light on every transition.

How to Implement a DFA as a “Mealy Machine” (Re-)Number the states, starting with 0. Figure out how many bits you need to store the state number. Use that many D flip-flops to store the state. For each state, build a combinational circuit that determines the next state and the output given the input. (So, you’re building a separate circuit for each state!) Send all those “next states” and outputs from the circuits into multiplexers, and use the current state as the control signal. Send the output of the multiplexer back into your flip-flops.

Light Switch to Mealy Machine: Step 1 toggle, on no toggle, on 1 no toggle, off toggle, off

Light Switch to Mealy Machine: Step 2 toggle, on no toggle, on 1 no toggle, off toggle, off We only need 1 bit to store the state number, since there are only two states.

Light Switch to Mealy Machine: Step 3 We always use this pattern. In this case, we only need one bit of flip-flops. D Q Combinational circuit to calculate next state/output CLK input output

Light Switch to Mealy Machine: Step 4 Our input is toggle. If toggle is true, then the button was toggled on this clock cycle. If not, the button was not toggled. Our output indicates whether the light should be on or off this cycle. If we’re in state 0, output is false (off) if we didn’t toggle and true (on) if we did. If we’re in state 1, output is true (on) if we didn’t toggle and false (off) if we did.

Light Switch to Mealy Machine: Step 4 Our input is toggle. If toggle is true, then the button was toggled on this clock cycle. If not, the button was not toggled. Our output indicates whether the light should be on or off this cycle. In either state, our next state switches if we did toggle and stays the same if we didn’t.

Light Switch to Mealy Machine: Step 4 new state State 0 toggle output new state State 1 toggle output

Light Switch to Mealy Machine: Step 4 new state/ output State 0 toggle new state/ output State 1 toggle Since they’re identical, we collapse them. They’re not always identical!

Light Switch to Mealy Machine: Step 5 state new state/ output toggle 1 Note: moved the select line to the top of the mux to make the next drawing cleaner...

Light Switch to Mealy Machine: Step 6 1 toggle, on toggle, off no toggle, off no toggle, on D Q CLK 1 toggle output

Steps to Build a Powerful Machine (Re-)Number the states, starting with 0. Figure out how many bits you need to store the state number. Use that many D flip-flops to store the state. For each state, build a combinational circuit that determines the next state and the output given the input. (So, you’re building a separate circuit for each state!) Send all those “next states” and outputs from the circuits into multiplexers, and use the current state as the control signal. Send the output of the multiplexer back into your flip-flops.

How Powerful Is a DFA? How does a DFA compare to a modern computer? Can a DFA take a DFA as input and run it?

Where We’ll Go From Here... We’ll come back to DFAs again later in lecture. In two upcoming labs, you’ll: Build a circuit to perform a practical task using techniques like these. Explore how to build something like a DFA that can run other DFAs... a general purpose computer.

Learning Goals: In-Class 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. Discuss point of learning goals.

Next Lecture Learning Goals: Pre-Class By the start of class, you should be able to: Convert sequences to and from explicit formulas that describe the sequence. Convert sums to and from summation/”sigma” notation. Convert products to and from product/”pi” notation. Manipulate formulas in summation/product notation by adjusting their bounds, merging or splitting summations/products, and factoring out values. TENTATIVE

Next Lecture Prerequisites Read Section 4.1. Note: 4.1 is background information. We don’t intend to directly assess this material, but assignment and exam questions may require skills and knowledge from 4.1 to answer. Solve problems like Exercise Set 4.1, #1-8, 12-14, 18-31, 37-44, 52-60. Complete the open-book, untimed quiz on Vista that’s due before the next class. TENTATIVE

(on your own or if we have time) More problems to solve... (on your own or if we have time)

Problem: Traffic Light Problem: Design a DFA with outputs to control a set of traffic lights.

Problem: Traffic Light Problem: 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 toggle when it goes off. Variants to try: - Pedestrian cross-walks - Turn signals - Inductive sensors to indicate presence of cars - Left-turn signals