Schaltwerke und Automaten

Similar documents
Sequentielle Schaltelemente

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Combinational vs Sequential

Chapter 5 Synchronous Sequential Logic

CPS311 Lecture: Sequential Circuits

CSE140: Components and Design Techniques for Digital Systems. More D-Flip-Flops. Tajana Simunic Rosing. Sources: TSR, Katz, Boriello & Vahid

Logic Design ( Part 3) Sequential Logic- Finite State Machines (Chapter 3)

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

Problems with D-Latch

MC9211 Computer Organization

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

Introduction to Digital Logic Missouri S&T University CPE 2210 Flip-Flops

Computer Architecture and Organization

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

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

CS8803: Advanced Digital Design for Embedded Hardware

Principles of Computer Architecture. Appendix A: Digital Logic

UNIT IV. Sequential circuit

Chapter 5: Synchronous Sequential Logic

Advanced Digital Logic Design EECS 303

Unit 11. Latches and Flip-Flops

Sequential Logic. E&CE 223 Digital Circuits and Systems (A. Kennings) Page 1

cascading flip-flops for proper operation clock skew Hardware description languages and sequential logic

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

Sequential Logic Circuits

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

1. Convert the decimal number to binary, octal, and hexadecimal.

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

Introduction to Sequential Circuits

EMT 125 Digital Electronic Principles I CHAPTER 6 : FLIP-FLOP

D Latch (Transparent Latch)

UNIT III. Combinational Circuit- Block Diagram. Sequential Circuit- Block Diagram

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 2 Logistics

Chapter Contents. Appendix A: Digital Logic. Some Definitions

2 Sequential Circuits

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

Final Exam review: chapter 4 and 5. Supplement 3 and 4

RS flip-flop using NOR gate

Lecture 11: Synchronous Sequential Logic

Flip-Flops. Because of this the state of the latch may keep changing in circuits with feedback as long as the clock pulse remains active.

Combinational / Sequential Logic

Logic Design. Flip Flops, Registers and Counters

RS flip-flop using NOR gate

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

Chapter 8 Sequential Circuits

The word digital implies information in computers is represented by variables that take a limited number of discrete values.

Experiment 8 Introduction to Latches and Flip-Flops and registers

Chapter 5 Sequential Circuits

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

Chapter 11 State Machine Design

Name Of The Experiment: Sequential circuit design Latch, Flip-flop and Registers

CHAPTER 4: Logic Circuits

Lecture 8: Sequential Logic

FLIP-FLOPS AND RELATED DEVICES

CSE Latches and Flip-flops Dr. Izadi. NOR gate property: A B Z Cross coupled NOR gates: S M S R Q M

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

ELCT201: DIGITAL LOGIC DESIGN

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

CS8803: Advanced Digital Design for Embedded Hardware

Chapter. Synchronous Sequential Circuits

CHAPTER 4: Logic Circuits

`COEN 312 DIGITAL SYSTEMS DESIGN - LECTURE NOTES Concordia University

FPGA Implementation of Sequential Logic

EKT 121/4 ELEKTRONIK DIGIT 1

(CSC-3501) Lecture 7 (07 Feb 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement

Chapter 3 Unit Combinational

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

ELE2120 Digital Circuits and Systems. Tutorial Note 7

Review of digital electronics. Storage units Sequential circuits Counters Shifters

Synchronous Sequential Logic. Chapter 5

Universidad Carlos III de Madrid Digital Electronics Exercises

Introduction to Microprocessor & Digital Logic

INTRODUCTION TO SEQUENTIAL CIRCUITS

Digital Logic Design I

ECE 25 Introduction to Digital Design. Chapter 5 Sequential Circuits ( ) Part 1 Storage Elements and Sequential Circuit Analysis

Synchronous Sequential Logic

Flip-Flops and Sequential Circuit Design

Chapter 3 Unit Combinational

CHAPTER1: Digital Logic Circuits

Vignana Bharathi Institute of Technology UNIT 4 DLD

Digital Circuit Engineering

Digital Circuits ECS 371

Administrative issues. Sequential logic

ELCT201: DIGITAL LOGIC DESIGN

CS 151 Final. Instructions: Student ID. (Last Name) (First Name) Signature

Switching Theory And Logic Design UNIT-IV SEQUENTIAL LOGIC CIRCUITS

CHAPTER 6 COUNTERS & REGISTERS

ECE 341. Lecture # 2

Synchronous Sequential Logic

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) COUNTERS

EE292: Fundamentals of ECE

Sequential logic. Circuits with feedback. How to control feedback? Sequential circuits. Timing methodologies. Basic registers

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 3 Logistics

Logic Design II (17.342) Spring Lecture Outline

MODULE 3. Combinational & Sequential logic

Transcription:

Schaltwerke und Automaten Grundlagen der technischen Informatik Wintersemester 28/9 Folien asierend auf F. Vahid und S. Werner Wintersemester 28/9

Review - Bit Storage Using an SR Latch Does the circuit to the right, with cross-coupled NOR gates, do what we want? Yes! How did someone come up with that circuit? Maye just trial and error, a it of insight... S (set) R (reset) SR latch Q S= t S= t S= t S= t Recall NOR Q Q Q Q X R= R= R= R= S R t Q Wintersemester 28/9 2

Review - Level-Sensitive D Latch SR latch requires careful design to ensure SR= never occurs D S S D latch D latch relieves designer of that urden Inserted inverter ensures R always opposite of S C R R Q D C S R D Q C Q D latch symol Q Wintersemester 28/9 3

Review - D Flip-Flop Flip-flop: Bit storage that stores on clock edge One design possiility master-servant Clk = master enaled, loads D, appears at Qm. Servant disaled. Clk = Master disaled, Qm stays same. Servant latch enaled, loads Qm, appears at Qs. Thus, value at D (and hence at Qm) when Clk changes from to gets stored into servant D latch D Dm Qm Cm master Clk D latch Ds Cs D flip-flop Clk Qs Qs Q D/Dm Q Cm Qm/Ds servant Cs Qs Wintersemester 28/9 4

Review - Basic Register Typically, we store multi-it items e.g., storing a 4-it inary numer Register: multiple flip-flops sharing clock signal From this point, we ll use registers for it storage No need to think of latches or flip-flops But now you know what s inside a register I3 I2 I I 4-it register D Q D Q D Q D Q I3 I2 I I reg(4) Q3 Q2 Q Q Q3 Q2 Q Q Wintersemester 28/9 5

Finite-State Machines (FSMs) and Controllers Want sequential circuit with particular ehavior over time Example: Laser timer Pushing utton causes x= for exactly 3 clock cycles Precisely-timed laser pulse How? Let s try three flip-flops = gets stored in first D flipflop Then 2nd flip-flop on next cycle, then 3rd flip-flop on next OR the three flip-flop outputs, so x should e for three cycles Controller x laser patient D Q D Q D Q Bad jo what if utton pressed a second time during those 3 cycles? x Wintersemester 28/9 6

Need a Better Way to Design Sequential Circuits Also ad ecause of ad-hoc design process How create other sequential circuits? Need A way to capture desired sequential ehavior A way to convert such ehavior to a sequential circuit Like we had for designing cominational circuits Step : Capture ehavior Step 2: Convert to circuit Step Capture the function 2A: Create equations 2B: Implement as a gateased circuit Description Create a truth tale or equations, whichever is most natural for the given prolem, to descrie the desired ehavior of each output of the cominational logic. This sustep is only necessary if you captured the function using a truth tale instead of equations. Create an equation for each output y ORing all the minterms for that output. Simplify the equations if desired. For each output, create a circuit corresponding to the output s equation. (Sharing gates among multiple outputs is OK optionally.) Wintersemester 28/9 7

Capturing Sequential Circuit Behavior as FSM Finite-State Machine (FSM) Descries desired ehavior of sequential circuit Akin to Boolean equations for cominational ehavior List states, and transitions among states Example: Toggle x every clock cycle Two states: Lo (x=), and Hi (x=) Transition from Lo to Hi, or Hi to Lo, on rising clock edge (^) Arrow points to initial state (when circuit first starts) state Outputs: Wintersemester 28/9 x Lo Hi Lo Hi Lo Hi Lo Hi cycle cycle 2 cycle 3 cycle 4 Lo Outputs: x x= ^ x= Lo Hi ^ Hi Lo Hi 8

Definitionen Schaltnetz (cominational circuit): Verknüpfung mehrerer Eingangsvarialen ohne Rückkopplung des Ergenisses Schaltwerk (sequential circuit): Mindestens ein Ausgang ist von vorherigem Zustand der Schaltung ahängig (Rückkopplung) Speicher Beispiel: Zustandsautomat (Finite-State Machine), auch: endlicher Automat Formale Betrachtung: Ermöglicht Synthese von Schaltwerken Modell eines Verhaltens, estehend aus Zuständen, Zustandsüergängen und Aktionen Grafische Darstellung üer Zustandsgraphen Wintersemester 28/9 9

FSM Example: Three Cycles High System Want,,,,,,,,... For one clock cycle each Capture as FSM Four states:, first, second, third Transition on rising clock edge to next state Outputs: x x= ^ x= ^ x= ^ x= Off On On2 On3 ^ State Off On On2 On3 Off On On2 On3 Off Outputs : x Wintersemester 28/9

Three-Cycles High System with Button Input Four states Wait in Off while is ( *^) When is (*^), transition to On Sets x= Next two clock edges, transition to On2, then On3 x= for three cycles after utton pressed Inputs: State Inputs: x= Off Off *^ x= On ^ Outputs: x '*^ x= On2 ^ ^ x= On3 Off Off Off Off On On2 On3 Off Outputs: x Wintersemester 28/9

FSM Simplification: Rising Clock Edges Implicit Every edge ANDed with rising clock edge What if we wanted a transition without a rising edge? We don t consider such asynchronous FSMs less common, and advanced topic Only consider synchronous FSMs rising edge on every transition Inputs: ; Outputs: x x= Off *^ x= ^ On Inputs: ; Outputs: x x= Off * ^ x= On2 ^ ^ x= On3 Note: Transition with no associated condition thus transitions to next state on next clock cycle x= On x= On2 x= On3 Wintersemester 28/9 2

FSM Definition FSM consists of Set of states Ex: {Off, On, On2, On3} Set of inputs, set of outputs Ex: Inputs: {}, Outputs: {x} Initial state Ex: Off Set of transitions Each with condition Descries next states Ex: Has 5 transitions Set of actions Sets outputs in each state Ex: x=, x=, x=, and x= Inputs: ; Outputs: x x= Off x= On x= On2 x= On3 We often draw FSM graphically, known as state diagram Can also use tale (state tale), or textual languages Wintersemester 28/9 3

FSM Example: Secure Car Key Many new car keys include tiny computer chip When key turned, car s computer (under engine hood) requests identifier from key Key transmits identifier Else, computer doesn t start car FSM Wait until computer requests ID (a=) Transmit ID (in this case, ) r= Inputs: a; Outputs: r Wait a a K K2 K3 K4 r= r= r= r= Wintersemester 28/9 4

FSM Example: Secure Car Key (cont.) Nice feature of FSM Can evaluate output ehavior for different input sequence Timing diagrams show states and output values for different input waveforms r= Wait a a Inputs: a; K K2 K3 K4 r= r= r= r= Q: Determine states and r value for given input waveform: Outputs: r Inputs a State Wait Wait K K2 K3 K4 Wait Wait Inputs a State Wait Wait K K2 K3 K4 Wait K Outputs r Outputs r Wintersemester 28/9 5

Ex: Earlier Flight-Attendant Call Button Previously uilt using SR latch, then D flip-flop Capture desired it storage ehavior using FSM instead Clear and precise description of desired ehavior We ll later convert to a circuit Call utton Cancel utton Inputs: Call, Cncl Bit Storage Outputs: L Blue light Call' L= Call L= LightOff LightOn Cncl*Call' (Cncl*Call')' Wintersemester 28/9 6

How To Capture Desired Behavior as FSM List states Give meaningful names, show initial state Optionally add some transitions if they help Create transitions For each state, define all possile transitions leaving that state. Refine the FSM Execute the FSM mentally and make any needed improvements. Wintersemester 28/9 7

FSM Capture Example: Code Detector Unlock door (u=) only when uttons pressed in sequence: start, then red, lue, green, red Input from each utton: s, r, g, Also, output a indicates that some colored utton pressed Capture as FSM List states Some transitions included Start Red Green Blue Wait Wait for start utton u= s s' Start u= ar Red u= s r g a Wait for first colored utton Code detector a ag ar Blue Green u= u= u Door lock Inputs: s,r,g,,a Outputs: u Red2 u= Wintersemester 28/9 8

FSM Capture Example: Code Detector Capture as FSM List states Create transitions Start Red Green Blue s r g a Code detector u Door lock Wait Inputs: s,r,g,,a Outputs: u u= s u= ar Start a' s' ar' Red u= a Blue ag Green ar Red2 u= u= u= Wintersemester 28/9 9

FSM Capture Example: Code Detector Capture as FSM List states Create transitions Repeat for remaining states Refine FSM Mentally execute Works for normal sequence Check unusual cases What happens if all colored uttons pressed at once? Door opens! Change conditions: other uttons NOT pressed also u= s u= ar Wait Start Red u= a' s' Start Red Green Blue Wintersemester 28/9 s r g a Code detector ar' a' ag' ar' u Door lock Inputs: s,r,g,,a Outputs: u a ag ar Blue Green Red2 a' a' a' u= u= u= 2

FSM Capture Example: Code Detector Start Red Green Blue s r g a Code detector u Door lock u= s Wait Start u= ar'g' Red u= a' s' a(r'g')' a(r'g')' a(gr'')' a(r'g')' Inputs: s,r,g,,a Outputs: u ar'g' agr'' ar'g' Blue Green Red2 a' a' a' u= u= u= Wintersemester 28/9 2

Controller Design Converting FSM to sequential circuit Circuit called controller (Steuerwerk) Standard controller architecture State register stores encoding of current state Cominational logic computes outputs and next state from inputs and current state Rising clock edge takes controller to next state I FSM inputs General form Controller Cominational logic S m m-it state register m O FSM outputs N Wintersemester 28/9 22

Controller Design Process Step : Capture ehavior Step 2: Convert to circuit Step Capture the FSM 2A: Set up architecture 2B: Encode the states 2C: Fill in the truth tale 2D: Implement cominational logic Description Create an FSM that descries the desired ehavior of the controller. Use state register of appropriate width and cominational logic. The logic s inputs are the state register its and the FSM inputs; outputs are next state its and the FSM outputs. Assign unique inary numer (encoding) to each state. Usually use fewest its, assign encoding to each state y counting up in inary. Translate FSM to truth tale for cominational logic such that the logic will generate the outputs and next state signals for the given FSM. Implement the cominational logic using any method. Wintersemester 28/9 23

Controller Design: Laser Timer Example Step : Capture the FSM Already done Step 2A: Set up architecture 2-it state register (for 4 states) Input, output x Next state signals n, n Step 2B: Encode the states Any encoding with each state unique will work Inputs: ; Outputs: x x= Off FSM inputs x= x= x= On On2 On3 Cominational logic s s n n x FSM outputs a State register Wintersemester 28/9 24

Controller Design: Laser Timer Example (contd) Step 2C: Fill in truth tale Inputs: ; Outputs: x x= Off x= x= x= On On2 On3 FSM inputs Cominational logic s s n n x FSM outputs State register Wintersemester 28/9 25

Controller Design: Laser Timer Example (contd) Step 2D: Implement cominational logic FSM inputs Cominational logic s s n n x FSM outputs State register x = s + s (note that x= if s= or s=) n = s s + s s + ss + ss n = s s + ss n = s s + ss + ss n = s s + ss Wintersemester 28/9 26

Controller Design: Laser Timer Example (contd) Step 2D: Implement cominational logic (cont) FSM inputs Cominational Logic Cominational logic s s n n x FSM outputs x n State register n s s State register x = s + s n = s s + ss n = s s + ss Wintersemester 28/9 27

Understanding the Controller s Behavior x= Off x= x= x= On On2 On3 x= Off x= x= x= On On2 On3 x= Off x= x= x= On On2 On3 s s x n n s s x n n s s x n n State= State= State= Inputs: Outputs: x Wintersemester 28/9 28

Controller Example: Button Press Synchronizer cycle cycle2 cycle3 cycle4 i Button press synchronizer controller o Inputs: i Outputs: o Want simple sequential circuit that converts utton press to single cycle duration, regardless of length of time that utton was actually pressed We assumed such an ideal utton press signal in earlier example, like the utton in the laser timer controller Wintersemester 28/9 29

Controller Example: Button Press Synchronizer (contd) FSM inputs: i; FSM outputs: o i i i A B i C i i o= o= o= Step : Capture FSM FSM inputs: i; FSM outputs: o i i i i i i o= o= o= Step 2B: Encode states A B FSM inputs C unused Cominational logic Inputs Outputs s i s i Cominational logic s n n s State register o o n n FSM outputs Step 2C: Fill in truth tale Step 2A: Set up architecture n = s si + ssi n = s s i o = s si + s si = ss i Cominational logic s s State register Step 2D: Implement cominational logic o n n Wintersemester 28/9 3

Controller Example: Sequence Generator Want generate sequence,,,, (repeat) Each value for one clock cycle Common, e.g., to create pattern in 4 lights, or control magnets of a stepper motor Inputs: none; Outputs: w,x,y,z wxyz= wxyz= A B wxyz= D Step : Create FSM C wxyz= Step 2C: Fill in truth tale Cominational logic s s State register n n Step 2A: Set up architecture w = s x = ss y = s s z = s n = s xor s n = s Wintersemester 28/9 w xy z s s State register Inputs: none; Outputs: w,x,y,z wxyz= wxyz= A B wxyz= D C wxyz= Step 2B: Encode states Step 2D: Implement cominational logic n w x y z n 3

Controller Example: Secure Car Key Step Wait r= a Inputs: a; Outputs: r a K K2 K3 K4 r= r= r= r= a (from earlier example) r Step 2A Cominational logic s2 s s State register n2 n n Inputs: a; Outputs: r Step 2B r= a a r= r= r= r= We ll omit Step 2D Wintersemester 28/9 Step 2C 32

Converting a Circuit to FSM (Reverse Engineering) x What does this circuit do? s s State register Work ackwards n n y z 2D: Circuit to eqns y=s z = ss n=(s xor s)x n=(s *s )x 2C: Truth tale 2B: (Un)encode states Pick any state names you want 2A: Set up arch already done Wintersemester 28/9 : FSM (get from tale) x A D A yz= D yz= D yz= Outputs:y, z B C B yz= C yz= Inputs: x; Outputs:y, z x A B yz= x x x x C states with outputs and transitions states states with outputs yz= yz= 33

Moore vs. Mealy FSMs Moore Mealy FSM consists of state register and logic More detailed view Next state logic function of present state and FSM inputs Output logic If depends on present state only Moore FSM If depends in present state and FSM inputs Mealy FSM Wintersemester 28/9 34

Mealy FSMs may have fewer states Moore Inputs: enough (it) Outputs: d, clear (it) Mealy Inputs: enough (it) Outputs: d, clear (it) /d=, clear= Init Wait enough Init Wait d= clear= enough Disp enough enough/d= d= Inputs: enough State: I W W D I Inputs: enough State: I W W I Outputs: clear d Outputs: clear d Soda dispenser example: Initialize, wait until enough, dispense Moore: 3 states; Mealy: 2 states Wintersemester 28/9 35

Mealy vs. Moore Q: Which is Moore, and which is Mealy? A: Mealy on left, Moore on right Mealy outputs on arcs, meaning outputs are function of state AND INPUTS Moore outputs in states, meaning outputs are function of state only Inputs: ; Outputs: s, s, p Time /ss=, p= /ss=, p= Alarm /ss=, p= /ss=, p= Date /ss=, p= /ss=, p= Stpwch /ss=, p= /ss=, p= Mealy Inputs: ; Outputs: s, s, p Time ss=, p= S2 ss=, p= Alarm ss=, p= S4 ss=, p= Date ss=, p= S6 ss=, p= Stpwch ss=, p= S8 ss=, p= Moore Wintersemester 28/9 36

Mealy vs. Moore Tradeoff Mealy outputs change mid-cycle if input changes Note earlier soda dispenser example Mealy had fewer states, ut output d not for full cycle Represents a type of tradeoff Moore Inputs: enough (it) Outputs: d, clear (it) Init d= clear= Inputs: enough State: Outputs: clear d I Wait enough W W D enough I Disp d= Wintersemester 28/9 Inputs: enough (it) Outputs: d, clear (it) Init Inputs: enough State: Outputs: clear /d=, clear= d Wait I enough enough/d= W W I Mealy 37

Implementing a Mealy FSM Straightforward Convert to state tale Derive equations for each output Key difference from Moore: External outputs (d, clear) may have different value in same state, depending on input values Inputs: enough (it) Outputs: d, clear (it) / d=, clear= Init Wait enough /d= enough/d= Wintersemester 28/9 38

More on Flip-Flops and Controllers Non-ideal flip-flop ehavior Can t change flip-flop input too close to clock edge Setup time: time D must e stale efore edge Else, stale value not present at internal latch Hold time: time D must e held stale after edge Else, new value doesn t have time to loop around and stailize in internal latch D D setup time Setup time violation D C S D latch Q C D S u 2 hold time u R Q R Q 3 4 7 Leads to oscillation! Grundlagen Q der Technische 5 6 Informatik Wintersemester 28/9 39

Initial State of a Controller All our FSMs had initial state But our sequential circuits did not Can accomplish using flip-flops with reset/set inputs Shown circuit initializes flip-flops to Designer must ensure resetcontroller input is during power up of circuit By electronic circuit design Controller with reset to initial state (assuming state Off was encoded as ). reset controller Inputs: x; Outputs: x= Off x= On State register x= On2 D Q D Q R Cominational logic Q s s S Q n n x= x On3 Wintersemester 28/9 4

Glitching Glitch: Temporary values on outputs that appear soon after input changes, efore stale new output values Designer must determine whether glitching outputs may pose a prolem If so, may consider adding flip-flops to outputs Delays output y one clock cycle, ut may e OK Called registered output Cominational logic s s State register x n n D flip-flop xr Laser timer controller with flip-flop to prevent glitches on x from unintentionally turning on laser Wintersemester 28/9 4

Was haen Sie heute gelernt? Zustandsautomat (FSM) Bildungsvorschrift zur Erstellung eines Models, welches das sequentielle Verhalten des Zustandsautomaten aildet Technik zur Üerführung des Models eines Zustandsautomaten in eine digitale Schaltung Wintersemester 28/9 42