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

Similar documents
Logic Design ( Part 3) Sequential Logic (Chapter 3)

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

CHAPTER 4: Logic Circuits

CHAPTER 4: Logic Circuits

Chapter 3. Boolean Algebra and Digital Logic

Chapter 5 Synchronous Sequential Logic

Logic Design II (17.342) Spring Lecture Outline

Sequential Digital Design. Laboratory Manual. Experiment #3. Flip Flop Storage Elements

Spring 2017 EE 3613: Computer Organization Chapter 5: The Processor: Datapath & Control - 1

COMP2611: Computer Organization. Introduction to Digital Logic

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

Introduction to Sequential Circuits

CPS311 Lecture: Sequential Circuits

Problems with D-Latch

COMP sequential logic 1 Jan. 25, 2016

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

ELCT201: DIGITAL LOGIC DESIGN

Combinational vs Sequential

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

1.b. Realize a 5-input NOR function using 2-input NOR gates only.

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

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

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

CS 110 Computer Architecture. Finite State Machines, Functional Units. Instructor: Sören Schwertfeger.

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

Sequential Logic Circuits

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

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

Experiment 8 Introduction to Latches and Flip-Flops and registers

Chapter 4. Logic Design

MC9211 Computer Organization

CprE 281: Digital Logic

CS8803: Advanced Digital Design for Embedded Hardware

Engr354: Digital Logic Circuits

ELCT201: DIGITAL LOGIC DESIGN

RS flip-flop using NOR gate

First Name Last Name November 10, 2009 CS-343 Exam 2

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

Computer Architecture and Organization

Chapter 3 Unit Combinational

Principles of Computer Architecture. Appendix A: Digital Logic

RS flip-flop using NOR gate

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

Chapter 5: Synchronous Sequential Logic

CS 261 Fall Mike Lam, Professor. Sequential Circuits

Unit 11. Latches and Flip-Flops

Multiplexor (aka MUX) An example, yet VERY useful circuit!

2 Sequential Circuits

Learning Outcomes. Unit 13. Sequential Logic BISTABLES, LATCHES, AND FLIP- FLOPS. I understand the difference between levelsensitive

Chapter Contents. Appendix A: Digital Logic. Some Definitions

Where Are We Now? e.g., ADD $S0 $S1 $S2?? Computed by digital circuit. CSCI 402: Computer Architectures. Some basics of Logic Design (Appendix B)

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

Synchronous Sequential Logic. Chapter 5

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

CS8803: Advanced Digital Design for Embedded Hardware

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

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

Chapter 5 Sequential Circuits

Part 4: Introduction to Sequential Logic. Basic Sequential structure. Positive-edge-triggered D flip-flop. Flip-flops classified by inputs

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

D Latch (Transparent Latch)

Last time, we saw how latches can be used as memory in a circuit

CS/ECE 250: Computer Architecture. Basics of Logic Design: ALU, Storage, Tristate. Benjamin Lee

Analysis of Clocked Sequential Circuits

ECE 301 Digital Electronics

Chapter 5 Sequential Circuits

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

EET2411 DIGITAL ELECTRONICS

CS 61C: Great Ideas in Computer Architecture

Section 6.8 Synthesis of Sequential Logic Page 1 of 8

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

BCN1043. By Dr. Mritha Ramalingam. Faculty of Computer Systems & Software Engineering

CprE 281: Digital Logic

Department of CSIT. Class: B.SC Semester: II Year: 2013 Paper Title: Introduction to logics of Computer Max Marks: 30

Lecture 11: Synchronous Sequential Logic

Synchronous Sequential Logic

Combinational / Sequential Logic

CprE 281: Digital Logic

Digital Logic Design I

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

WEEK 10. Sequential Circuits: Analysis and Design. Page 1

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

Other Flip-Flops. Lecture 27 1

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

More Digital Circuits

Chapter 8 Sequential Circuits

Digital Circuits ECS 371

Synchronous Sequential Logic

SEQUENTIAL LOGIC. Satish Chandra Assistant Professor Department of Physics P P N College, Kanpur

Figure 30.1a Timing diagram of the divide by 60 minutes/seconds counter

CHAPTER1: Digital Logic Circuits

Universidad Carlos III de Madrid Digital Electronics Exercises

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) LATCHES and FLIP-FLOPS


Chapter 1: Switching Algebra Chapter 2: Logical Levels, Timing & Delays. Introduction to latches Chapter 9: Binary Arithmetic

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

Synchronous Sequential Logic

Transcription:

Logic esign ( Part ) Sequential Logic- Finite State Machines (Chapter ) Based on slides McGraw-Hill Additional material 00/00/006 Lewis/Martin Additional material 008 Roth Additional material 00 Taylor Additional material 0 Farmer Additional material 0 Narahari uick summary Combinational logic circuits Basic gates (OR, AN,.) Combinational devices (Multiplexers, ecoders, Adders, ) We now have a storage device -Latch Implementation of registers and memory Using -latches ok now back to sequential circuits and state machines Recall examples of Vending Machine and Counter Finite State Machines The behavior of sequential circuits can be expressed using characteristic tables or finite state machines (FSMs). FSMs consist of a set of nodes that hold the states of the machine and a set of arcs that connect the states. irected graph to represent a FSM State Machine type of sequential circuit Combines combinational logic with storage Remembers state, and changes output and state at each clock cycle based on inputs and current state State Machine Moore and Mealy machines are two types of FSMs that are equivalent. They differ only in how they express the outputs of the machine. Moore machines place outputs on each node/state Associate an output with each state Mealy machines present their outputs on the transitions. Inputs Combinational Logic Circuit Storage Elements Outputs

States in a FSM The concept of state the state of a system is a snapshot of all relevant elements at a moment in time. a given system will often have only a finite number of possible states. For many systems, we can define the rule which determines under what conditions a system can move from one state to another. So when do they change states? Random times? Only at specific times? Are we ready to design sequential circuits and finite state machines? Is something missing? When do states change in a machine? o we let states change at arbitrary times? What do you think happens in a computer? ed Flip-Flops/Circuits Subsystem in a computer consists of a large number of combinational and sequential devices Each sequential device is like latch which is in one of two states As machine executes its cycle, the states of all sequential devices change with time To control large collection of devices in an orderly (synchronized) fashion, machine maintains a clock Requires all devices to change their states at the same time generates sequence of pulses Much easier to design, debug, implement, and test How do we change latches so that they allow change in state synchronized with the clock? Sequential logic circuits require a means by which events can be sequenced..clock! Introducing - The! A clock controls when stored values are updated Electrical waveform sends pulses through a circuit Oscillating global signal with fixed period 0 One Cycle The clock will act as the heartbeat of our system The number of cycles per second is the clock frequency measured in cycles per second or Hertz (Hz) The clock period refers to the duration of one clock cycle. The period and frequency are inversely related. Typical clock frequency:.ghz =. x0 9 Hz So corresponding clock period = /(. x 0 9 ) =.x0-8 -9 sec That would be: 0. nanoseconds time

Attaching to -Latch Let s attach CLOCK to the WE on -Latch clock WE We create windows of time that we can store data into latch When the CLOCK is HIGH -latch is open When the CLOCK is LOW -latch is closed We have to prepare what we wish to store, right before latch closes open closed open CLOCK time -9 Finite State Machine In general a Finite State Machine consists of An n-bit storage (register?) which stores the state of the machine A block of logic that computes the next state as a function of the current state and the inputs, if any A block of logic which computes the output based on the Inputs current state. Next State Function State Register (storage) Combinational Logic Blocks Output Function Outputs esigning and implementing a FSM. First draw the state diagram Encode each state in binary using N bits These N bits correspond to N state variables that need to be stored. Call them S N- S N- S S 0 State diagram will show transitions from state to state based on value of inputs. Next, derive the truth table (from state diagram) inputs in truth table are N current state variables and the inputs outputs are the values of the state variables in the next state and the output at each state -- common notation is S but confusion with complement operator, so let s use S*. From truth table, derive combinational circuit (boolean function) for each of the next state values State variables are stored in your N storage elements Simple -bit Counter count from 0 to bit encoding A,B of states: 00, 0,0, Counts 00 0 0 boolean functions: A,B current state A*, B* next state A* = (A B) + (A B ) = A XOR B B* = (A B ) + (AB ) = B Two storage elements to store bits A,B Use -latches? State can change at each clock cycle Implement circuit A B A* B* 0 0 0 0 0 0 0 0

-Latch Timing iagram The diagram below is called a Timing iagram Our -Latch is previous-state dependent We can think of this as a time dependency Moving to the right on diagram, represents forward moving time The inputs & outputs to our -Latch are on left Inputs/Outputs can be either HIGH (logic ) or LOW (logic ) Think of this as a time-dependent truth table Logic level = Logic level =0 time Let s Try to Build a Counter using the -Latch We can t use a -latch to build a counter Why not? Let s say at time=0, -latch has: 00 >This is the input to incrementer, so output = 0 >Now 0 is input to the -latch Problem: >We can t guarantee the clock will be low in time to store this new value into the -latch Logic level = Logic level =0 Solving the ed -Latch problem.. we need to decouple circuit that reads current state from circuit that writes in the new/next state In one clock cycle, we can only do one read of a state and one write into the latch build a latch consisting of TWO latches One enabled during clock high to read current state One enabled during clock low to write new state Connect the two Flip-Flop (or master-slave flip-flop) Flip-Flop is a pair of latches Stupid name, but it stuck Isolates next state from current state Latch # inter WE WE Latch # Two phases: = : WE =0: Latch # closed, WE =: Latch # open = 0: WE =: Latch # open, WE =0: Latch # closed -6

Flip-Flop timing iagram Latch # inter Latch # Flip-Flop vs. -Latch We refer to the flip flop as an edge-triggered device. = ONLY when WE changes from 0 to inter WE WE L -closed L -open L -open L -closed L -closed L -open L -open L -closed This differs from latch, which is: level-triggered = anytime WE equals Timing iagram for FF: WE -7-8 -8 Flip-Flop vs. -Latch We refer to the flip flop as an edge-triggered device. = ONLY when WE changes from 0 to This differs from latch, which is: level-triggered = anytime WE equals Timing iagram for -Latch: WE Flip-Flop We can think of the Flip-Flop as a bit storage container with an input,, and an output,. The flip-flop takes a clock input (often denoted with a triangle) A set of flip-flops can be grouped together with common and WE inputs to form a register. A key component in our processor Flip-Flop -9-9 -0

Storage evices R S RS RS Latch Stores Bit, Level-Triggered - forbidden input: S=0, R=0 -Holds ata when RS= Working Counter Use a clocked register (made of flip-flops) -ff + WE -Latch Stores Bit, Level-Triggered -No forbidden inputs (fixes RS Latch) -= when WE= -Holds ata when WE=0 FF CLK -Flip-Flop Stores Bit, Edge-Triggered -No forbidden inputs -= when WE (CLK) transitions from 0 to -Holds ata for WE= or WE=0 -Except when WE transitions from -0 to - Counter Timing iagram Incrementer (+) computes the next value of the state register -ff + Finite State Machine Representation of Counter Reset 000 00 Bubbles represent all possible states for the machine (aka your flip-flop based circuit) 0 00 Arrows show movement from one state to the next 0 6-0 00 0 Transitions occur at pulse of the clock - 6

Truth Table Representation of Counter Present State Next State (t) (t) 0 (t) (t+) (t+) 0 (t+) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Finite State Machine The counter we designed is an example of a finite state machine. In general a Finite State Machine consists of An n-bit register which stores the state of the machine A block of logic that computes the next state as a function of the current state and the inputs, if any A block of logic which computes the output based on the current state. Combinational Logic Blocks Inputs Next State Function State Register Output Function Outputs - -6 One Last Thing Flip-Flop with Additional Write Enable From previous slides, we attached clock to WE of the -flip-flop Now, we add another WE line to the flip flop Just holds onto data already stored in FF Give it the ability to ignore the clock! WE 0 FF Flip-Flop w/we WE -7 Review: esigning and implementing a FSM. First draw the state diagram Encode each state in binary using N bits These N bits correspond to N state variables that need to be stored. Call them S N- S N- S S 0 State diagram will show transitions from state to state based on value of inputs. Next, derive the truth table (from state diagram) inputs in truth table are N current state variables and the inputs outputs are the values of the state variables in the next state and the output at each state -- common notation is S but confusion with complement operator, so let s use S*. From truth table, derive combinational circuit (boolean function) for each of the next state values State variables are stored in your N storage elements 7

Storage Each master-slave flip-flop stores one state bit. Example: Blinking Traffic Sign (from textbook) The number of storage elements (flip-flops) needed is determined by the number of states (and the representation of each state). Each bit can be 0 or = states N bits can represent N states Example: If a FSM has states, then the circuit needs log = storage elements. Fewer the states, less hardware needed Concept of Minimization of States for a given FSM ANGER ANGER ANGER 8

ANGER ANGER ANGER ANGER 9

ANGER ANGER Example: Traffic Sign A blinking traffic sign: How many states states No lights on & on,,, & on,,,, & on (repeat as long as switch is turned on) How many bits to represent the states S S 0 With S S 0 values: 00, 0, 0, Traffic Sign State iagram Switch off State bit S State bit S0 Switch on Outputs Transition on each clock cycle. 0

Note we really have groups of lights to be controlled = control lines X,Y,Z Group : Lights and ; controlled by Z If Z= then Group lights ( and ) are switched on Group : lights & ; controlled by Y Group : Light ; controlled by X 0 all off 0 grp on 00 0 0, all on 0 grp, on 0 When is group on? in states 0, 0 and - but only when the switch IN is on! Logic expressions for X,Y,Z epends on S 0 and S and Input is on If Input is off then X,Y,Z are al 0 can you come up with a logic expression for next state values of S 0 and S? epends on current values of S 0 and S and Input is on Input off then both bits are set to 0 since next state is 00 Next state value of S0 denoted S 0 = if current state is 00 or current state 0 and In= When do we switch to the next state? the two bits of S[:0] are updated at every clock cycle we have to make sure that the new state does not propagate to the combinational circuit input until the next clock cycle. Traffic Sign Truth Tables Outputs (depend only on state: S S 0 ) S S 0 Z Y X 0 0 0 0 0 0 0 0 0 0 Lights and Lights and Light Next State: S S 0 (depend on state and input) Switch Whenever In=0, next state is 00. In S S 0 S S 0 0 X X 0 0 0 0 0 0 0 0 0 0

Boolean functions for light control bits from truth table, consider all rows where outputs = Traffic Sign Logic Z = ((NOT S )S 0 + S (NOT S 0 ) + S S 0 ).In Y = (S S 0 + S (NOT S 0 ) ).In X = (S S 0 ).In flipflop From Logic to Processor esign Combinational Logic ecoders -- convert instructions into control signals Multiplexers -- select inputs and outputs ALU (Arithmetic and Logic Unit) -- operations on data Sequential Logic State machine -- coordinate control signals and data movement Registers and latches -- storage elements Putting it all together The goal: Turn a theoretical device - Turing s Universal Computational Machine - into an actual computer... interacting with data and instructions from the outside world, and producing output data. Smart building blocks: We have at our disposal a powerful collection of combinational and sequential logic devices. Now we need a master plan...

Recall: what are Computers meant to do? We will be solving problems that are describable in English (or Greek or French or Hindi or Chinese or...) and using a box filled with electrons and magnetism to accomplish the task. This is accomplished using a system of well defined (sometimes) transformations that have been developed over the last 0+ years. Problem Transformation - levels of abstraction The desired behavior: the application The building blocks: electronic devices Natural Language Algorithm Program Machine Architecture Micro-architecture Logic Circuits evices What Next? Next topic: The von Neumann model of computer architecture Basic components How instructions are processed The LC computer and instruction set The ISA of LC Programming the LC Assembly Language programming Chapters,,6,7