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

Similar documents
Asynchronous (Ripple) Counters

Digital Fundamentals: A Systems Approach

Experiment 8 Introduction to Latches and Flip-Flops and registers

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

CHAPTER 4: Logic Circuits

CHAPTER 4: Logic Circuits

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

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

Chapter 5 Synchronous Sequential Logic

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

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

EET2411 DIGITAL ELECTRONICS

CHAPTER1: Digital Logic Circuits

Chapter 4. Logic Design

Lecture 11: Synchronous Sequential Logic

Flip-Flops and Sequential Circuit Design

CPS311 Lecture: Sequential Circuits

Counter dan Register

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

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

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

CHAPTER 6 COUNTERS & REGISTERS

ELCT201: DIGITAL LOGIC DESIGN

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

LATCHES & FLIP-FLOP. Chapter 7

COMP2611: Computer Organization. Introduction to Digital Logic

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

Combinational vs Sequential

Digital Systems Laboratory 3 Counters & Registers Time 4 hours

Contents Circuits... 1

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

EE292: Fundamentals of ECE

Universidad Carlos III de Madrid Digital Electronics Exercises

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

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

1. a) For the circuit shown in figure 1.1, draw a truth table showing the output Q for all combinations of inputs A, B and C. [4] Figure 1.

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Registers and Counters

Digital Circuits 4: Sequential Circuits

Lecture 8: Sequential Logic

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

Administrative issues. Sequential logic

MC9211 Computer Organization

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

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

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

Sequential Logic Circuits

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

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

UNIT IV. Sequential circuit

Counters

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

Introduction. Serial In - Serial Out Shift Registers (SISO)

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

Digital Logic Design I

Laboratory Exercise 7

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

Computer Systems Architecture

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

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

Chapter 5: Synchronous Sequential Logic

Chapter. Synchronous Sequential Circuits

Logic Design. Flip Flops, Registers and Counters

CS8803: Advanced Digital Design for Embedded Hardware

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

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

CSC258: Computer Organization. Combinational Logic

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

Introduction to Microprocessor & Digital Logic

Computer Organization & Architecture Lecture #5

Experiment # 12. Traffic Light Controller

Sri Vidya College of Engineering And Technology. Virudhunagar Department of Electrical and Electronics Engineering

2 Sequential Circuits

Chapter 5 Sequential Circuits

Unit 11. Latches and Flip-Flops

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Chapter 11 State Machine Design

Sequential Digital Design. Laboratory Manual. Experiment #7. Counters

TMEL53, DIGITALTEKNIK. INTRODUCTION TO SYNCHRONOUS CIRCUITS, FLIP-FLOPS and COUNTERS

Chapter 3. Boolean Algebra and Digital Logic

ELCT201: DIGITAL LOGIC DESIGN

Chapter Contents. Appendix A: Digital Logic. Some Definitions

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

Introduction to Sequential Circuits

Microprocessor Design

ASYNCHRONOUS COUNTER CIRCUITS

2. Counter Stages or Bits output bits least significant bit (LSB) most significant bit (MSB) 3. Frequency Division 4. Asynchronous Counters

Principles of Computer Architecture. Appendix A: Digital Logic

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

Lecture 12. Amirali Baniasadi

Rangkaian Sekuensial. Flip-flop

Week 4: Sequential Circuits

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

Logic Design II (17.342) Spring Lecture Outline

Slide Set 7. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

ESE 570 STATIC SEQUENTIAL CMOS LOGIC CELLS. Kenneth R. Laker, University of Pennsylvania, updated 25Mar15

Registers and Counters

# "$ $ # %!"$!# &!'$("!)!"! $ # *!"! $ '!!$ #!!)! $ "# ' "

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS 150 Spring 2000

Transcription:

CSC258 Week 5 1

We are here Assembly Language Processors Arithmetic Logic Units Devices Finite State Machines Flip-flops Circuits Gates Transistors 2

Circuits using flip-flops Now that we know about flip-flops and what they do, how do we use them in circuit design? Inputs Combinational Circuit Storage Units Outputs What s the benefit in using flip-flops in a circuit at all? We can design much cooler circuits using flip-flops. 3

Example #1: Registers For storing values 4

Shift registers A series of D flip-flops can store a multi-bit value (such as a 16- bit integer, for example). SI D D 1 D 2 D 15 Clk Data can be shifted into this register one bit at a time, over 16 clock cycles. ú Known as a shift register. 5

Load registers One can also load a register s values all at once, by feeding signals into each flip-flop: ú In this example: a 4-bit load register. D D 1 D 2 D 3 D D D D Clk One clock pulse, 4 bits stored. 6

Load registers To control when this register is allowed to load its values, we introduce the D flip-flop with enable: EN D2 D D Clk EN When EN = 1, D2 is whatever D is, load D When EN =, D2 is whatever is, maintain 7

Load registers D D 1 D 2 D 3 Write Clk D D D D EN EN EN EN Implementing the register with these special D flip-flops will now maintain values in the register until overwritten by setting EN high. 8

In computer architecture, registers are the CPU s most local storages (3+ of them on-chip), i.e., they are the lowest level of the memory hierarchy. They are the memory units that the CPU directly interact with. Higher level of memory include cache, RAM, hard disc, etc. 9

Example #2: Counters 1

Counters Consider the T flip-flop: ú Output is inverted when input T is high. What happens when a series of T flip-flips are connected together in sequence? More interesting: ú Connect the output of one flip-flop to the clock input of the next! T Clk T D 11

Counters Asynchronous means the four outputs do not change upon the same clock signal. 1 1 2 3 T T T T This is a 4-bit ripple counter, which is an example of an asynchronous circuit. ú Timing isn t quite synchronized with the rising clock pulse. ú Cheap to implement, but unreliable for timing. 12

Demo: asynchronous human counter 1 1 2 3 T T T T 1. Need 4 volunteers,, 1, 2, 3 2. toggles when receives clock signal (tap on shoulder) 3. 1 toggles when goes from 1 to 4.2 toggles when 1 goes from 1 to o 5.3 toggles when 2 goes from 1 to 6. Audience read the number 321 13

Counters Timing diagram C 1 2 T T T T 1 2 3 1 C 3 1 1 1 1 1 1 1 1 1 1 1 1 1 14

Synchronous Counter Toggle only when the lower bit is 1 and is toggling to (carry bit generated) Write T T 1 T 2 T 3 Clk This is a synchronous counter, because all output s change upon the same clock edge. 15

Counter with parallel load When load is high, set states to R and R1 Write Load R R 1 1 D 1 D Clk Clear Counters are often implemented with a parallel load and clear inputs. ú Can set the counter to whatever value needed. 16

State Machines 17

Designing with flip-flops Counters and registers are examples of how flip-flops can implement useful circuits that store values. ú How do you design these circuits? ú What would you design with these circuits? 18

Designing with flip-flops Sequential circuits are the basis for memory, instruction processing, and any other operation that requires the circuit to remember past data values. These past data values are also called the states of the circuit. Need to describe the relation between the current state and the next state: use combinational circuits 19

State example: Counters With counters, each state is the current number that is stored in the counter. 1 zero 1 1 1 1 one 1 two three 11 seven 111 11 six five 11 1 1 four 1 On each clock tick, the circuit transitions from one state to the next, based on the inputs. 1 1 Each state does not need to correspond to a binary number, they are just different states 2

State Tables State tables help to illustrate how the states of the circuit change with various input values. ú Transitions are understood to take place on the clock ticks. State Write State zero zero zero 1 one one one one 1 two two two two 1 three three three three 1 four four four four 1 five five five five 1 six six six six 1 seven seven seven seven 1 zero 21

State Tables Same table as on the previous slide, but with the actual flip-flop values instead of state labels. Note: Flip-flop values are both inputs and outputs of the circuit here. F 1 F 2 F 3 Write F 1 F 2 F 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 22

and this brings us to Finite State Machines 23

Finite State Machines (FSMs) From theory courses ú A Finite State Machine is an abstract model that captures the operation of a sequential circuit. A FSM is defined (in general) by: ú A finite set of states, ú A finite set of transitions between states, triggered by inputs to the state machine, ú Output values that are associated with each state or each transition (depending on the machine), ú Start and end states for the state machine. 24

Design procedures comparison (roughly) Combinational circuits 1. Desired behaviour 2. Truth table 3. Logic expression 4. Circuit Sequential circuits 1. Desired behaviour (cooler behaviour) 2. Finite state machine 3. Circuit with flip-flops 25

Example #1: Tickle Me Elmo Remember how the Tickle Me Elmo works! 26

Example #1: Tickle Me Elmo Toy reacts differently each time it is squeezed: ú First squeeze à Ha ha ha that tickles. ú Second squeeze à Ha ha ha oh boy. ú Third squeeze à HA HA HA HA, go crazy uestions to ask: ú What are the inputs? ú What are the states of this machine? ú How do you change from one state to the next? 27

Example #1: Tickle Me Elmo Squeeze Initial Squeeze Tickles OhBoy Squeeze Squeeze GoCrazy 28

Example #2: Traffic Light Change= Change=1 Red Change=1 Yellow Change= Change=1 Green Change= 29

FSM design Design steps for FSM: 1. Draw state diagram 2. Derive state table from state diagram 3. Assign flip-flop configuration to each state 4. Redraw state table with flip-flop values 5. Derive combinational circuit for output and for each flip-flop input. 3

Example: Sequence Recognizer Recognize a sequence of input values, and raise a signal if that input has been seen. Example: Three high values in a row ú Detect that the input has been high for three rising clock edges. ú Assumes a single input X and a single output Z. What are the states? 31

Step 1: State diagram In this case, the states are labeled with the most recent three input values. Transitions between states are indicated by the values on the transition arrows. 32

Step 2: State table Make sure that the state table lists all the states in the state diagram, and all the possible inputs that can occur at that state. Previous State EN Next State 1 1 1 1 1 1 11 1 1 1 1 11 11 11 11 1 111 1 1 1 1 11 1 11 1 11 11 1 11 1 11 111 11 111 1 111 33

Step 3: Assign flip-flops Assign flip-flops for storing states. A single flip-flop can store two values ( and 1), and thus two states. How many states can be stored with each additional flip-flop? ú One flip-flop à 2 states ú Two flip-flops à 4 states ú Three flip-flops à 8 states ú ú Eight flip-flops? à 2 8 = 256 states n states need: ceiling(log 2 n) flip-flops 34

How many flip-flops for this one? 3 35

Step 3: Assign flip-flops In this case, we need to store 8 states. ú 8 states = 3 flip-flops (3 = log 2 8) For now, assign a flip-flop to each digit of the state names in the FSM & state table. EN Combinational Circuit D D D Clk 36

Step 4: State table Mapping states to flip-flop values This is NOT the only way of mapping from state to flip flop values, in fact it is not even a good way, as we will see later. FPrev. 2 FState 1 F EN F 2 Next F 1 State F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 11 1 1 1 1 1 11 1 1 1 11 1 1 1 1 1 111 1 1 1 1 1 111 1 1 1 1 11 11 1 1 11 11 11 11 111 111 1 1 1 1 1 1 1 37

Step 4: State table Mapping states to flip-flop values This is NOT the only way of mapping from state to flip flop values, in fact it is not even a good way, as we will see later. F 2 F 1 F EN F 2 F 1 F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 38

Step 5: Circuit design Karnaugh map for F 2 : F EN F EN F EN F EN F 2 F 1 F 2 F 1 1 1 1 1 F 2 F 1 1 1 1 1 F 2 F 1 Next state F 2 = F 1 Current state 39

Step 5: Circuit design Karnaugh map for F 1 : F EN F EN F EN F EN F 2 F 1 1 1 F 2 F 1 1 1 F 2 F 1 1 1 F 2 F 1 1 1 Next state F 1 = F Current state 4

Step 5: Circuit design Karnaugh map for F : F EN F EN F EN F EN F 2 F 1 1 1 F 2 F 1 1 1 F 2 F 1 1 1 F 2 F 1 1 1 Next state F = EN Current state 41

F 2 = F 1 F 1 = F F = EN Step 5: Circuit design Resulting circuit looks like the diagram on the right. This will record the states and make the state transitions happen based on the input, What about the output value Z which should go high when we have three highs in a row. EN Clk D D D F F 1 F 2 42

Step 5: Circuit design Boolean equation for Z: EN D Z = F F 1 F 2 Clk F Z D F 1 D F 2 43

Moore machine vs Mealy machine Two ways to derive the circuitry needed for the output values of the state machine: ú Moore machine: The output for the FSM depends solely on the current state (based on entry actions). ú Mealy machine: The output for the FSM depends on the state and the input (based on input actions). Being in state X can result in different output, depending on the input that caused that state. 44

An issue: timing and state assignments 1 Example: if recognizer circuit is in state 11 and gets a as an input, it moves to state 11. ú The first and last digits should change at the same time, but they can t. ú If the first flip-flop changes first, the state will change to 111, and the output Z would go high for an instant, which is unexpected behaviour. ú If the second flip-flop changes first, it s fine since the intermediate state 1 does NOT cause unexpected behaviour. 45

An issue: timing and state assignments So how do you solve this? Two possible solutions: 1. Whenever possible, make flip-flop assignments such that neighbouring states differ by at most one flip-flop value. Intermediate states can be allowed if the output generated by those states is consistent with the output of the starting or destination states. 2. If the intermediate states are unused in the state diagram, you can set the output for these states to provide the output that you need. Might need to add more flip-flops to create these states. 46

State does not have to have flip-flop values, it can be anything you want to assign. Previous State EN Next State 1 1 1 1 1 1 11 1 1 1 1 11 11 11 11 1 111 1 1 1 1 11 1 11 1 11 11 1 11 1 11 111 11 111 1 111 Home exercise: re-assign the states so the time issue doesn t exist 47

After-class example: Mouse clicks Design a circuit that takes in two signals: ú A signal P, which is high if the user is pressing the mouse button, ú A signal M, which is high if the mouse is being moved. Based on the inputs, indicate whether the user is clicking, double-clicking, or dragging the mouse on the screen. 48

1 1,11 Dragging Clicked 11 1,1 1 Neutral 1 11 1 Released 11 Double Clicked 1 1 Transitions indicate the values of P&M. Outputs depend on the state (Moore machine) Home exercise: build the circuit for the mouse based on this FSM. 49

Next week processor architecture 5