COMP sequential logic 1 Jan. 25, 2016

Similar documents
Lecture 8: Sequential Logic

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

D Latch (Transparent Latch)

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

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

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

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

Synchronous Sequential Logic

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

MODULE 3. Combinational & Sequential logic

Asynchronous (Ripple) Counters

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

ELCT201: DIGITAL LOGIC DESIGN

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

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

Chapter 8 Sequential Circuits

RS flip-flop using NOR gate

CHAPTER 4: Logic Circuits

211: Computer Architecture Summer 2016

Sequential Logic and Clocked Circuits

UNIT IV. Sequential circuit

Sequential Circuits: Latches & Flip-Flops

CS 261 Fall Mike Lam, Professor. Sequential Circuits

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

Previous Lecture Sequential Circuits. Slide Summary of contents covered in this lecture. (Refer Slide Time: 01:55)

DIGITAL CIRCUIT LOGIC UNIT 11: SEQUENTIAL CIRCUITS (LATCHES AND FLIP-FLOPS)

CPS311 Lecture: Sequential Circuits

Logic Design. Flip Flops, Registers and Counters

CHAPTER 4: Logic Circuits

More Digital Circuits

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

Rangkaian Sekuensial. Flip-flop

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

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

RS flip-flop using NOR gate

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

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

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED 220. Experiment 4 - Latches and Flip-Flops

Introduction to Sequential Circuits

The outputs are formed by a combinational logic function of the inputs to the circuit or the values stored in the flip-flops (or both).

Logic Design II (17.342) Spring Lecture Outline

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

Unit 11. Latches and Flip-Flops

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

MC9211 Computer Organization

Chapter. Synchronous Sequential Circuits

ELCT201: DIGITAL LOGIC DESIGN

Logic Design II (17.342) Spring Lecture Outline

LATCHES & FLIP-FLOP. Chapter 7

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

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

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

Introduction to Microprocessor & Digital Logic

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

Counters

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

Chapter 5 Sequential Circuits

`COEN 312 DIGITAL SYSTEMS DESIGN - LECTURE NOTES Concordia University

Chapter 4: One-Shots, Counters, and Clocks

Contents Circuits... 1

A clock is a free-running signal with a cycle time. A clock may be either high or low, and alternates between the two states.

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design ALU and Storage Elements

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

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

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

Computer Organization & Architecture Lecture #5

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

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

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

ECE 341. Lecture # 2

Counter dan Register

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

Other Flip-Flops. Lecture 27 1

Combinational vs Sequential

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

Vignana Bharathi Institute of Technology UNIT 4 DLD

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

ECE 172 Digital Systems. Chapter 2.2 Review: Ring Counter, Johnson Counter. Herbert G. Mayer, PSU Status 7/14/2018

FLIP-FLOPS AND RELATED DEVICES

Clocks. Sequential Logic. A clock is a free-running signal with a cycle time.

Week 4: Sequential Circuits

Digital Circuits ECS 371

(Refer Slide Time: 2:05)

Chapter 3 Unit Combinational

EECS 270 Group Homework 4 Due Friday. June half credit if turned in by June

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

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

Sequential Logic Circuits

Chapter 5 Sequential Circuits

Unit 9 Latches and Flip-Flops. Dept. of Electrical and Computer Eng., NCTU 1

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

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

CS61C : Machine Structures

Chapter 5 Sequential Circuits

Registers and Counters

COMP2611: Computer Organization. Introduction to Digital Logic

IT T35 Digital system desigm y - ii /s - iii

Software Engineering 2DA4. Slides 3: Optimized Implementation of Logic Functions

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

Transcription:

OMP 273 5 - sequential logic 1 Jan. 25, 2016 Sequential ircuits All of the circuits that I have discussed up to now are combinational digital circuits. For these circuits, each output is a logical combination of the inputs. We have seen that these circuits can do arithmetic and other operations. But these circuits are not powerful enough to build a general purpose computer. A key element that is missing is memory. onsider two different ways of remembering something. Suppose I tell you a telephone number. One way for you to remember it would be to write it down, say on paper. Then later you could just look at the paper. Another way to remember the number which is good for short term, is just to repeat the number over and over to yourself. You probably have some intuition about how a computer could write down a number. It could alter the state of some magnetic material, for example. What is less clear to you is how a computer could remember a number by repeating it to itself. Indeed this is the mechanism that is often used. We will now turn to this technique. RS latch (reset, set) The basic way to design a circuit that tells itself a value over and over is as follows. onsider a feedback circuit which is constructed from two NOR gates. Such a circuit is called an RS latch. R S On the left below is a truth table for a NOR gate, as a reminder. On the right are the values of and for various input combinations. It may seem strange that we label the two outputs as such, since if R = S = 1, then = 0 and = 0 which is impossible, and indeed in the slides I used the symbol instead of when introducing the RS latch. The reason it is ok to give the output labels and is that eventually we will not allow R = S = 1. The way RS latches are used is that at most one of R and S have value 1. When exactly one of them has value 1, it determines and. When both have value 0, then and keep the values that they had when one of R and S last had the value 1. See slides for illustration. A B A + B R S 0 0 1 0 0 hold remember 0 1 0 0 1 1 0 set 1 0 0 1 0 0 1 reset 1 1 0 1 1 0 0 not allowed last updated: 26 th Jan, 2016 1

OMP 273 5 - sequential logic 1 Jan. 25, 2016 It is standard to use letters R and S and to call them reset and set, respectively. The input R = 1 and S = 0 resets the output which traditionally means gives it value 0. The input R = 0 and S = 1 sets the output which means gives it the value 1. If you then put R = 0 and S = 0, you hold the value of i.e. you remember the value. Thus, an RS latch acts as a one-bit memory, holding (locking, latching shut) the value as long as R = 0, S = 0. The feedbacks in the circuit are what I said before about repeating a number back to yourself to remember it. The clock All the circuits we ve seen up to now can change their output values at any time their inputs change. You can imagine this has undesirable properties. If the outputs of one circuit are fed into other circuits, the exact timing and ordering of operations will be important. For example, consider the adder/subtractor we saw earlier. The sequence of carries takes some time, and we don t want the inputs to the adder to change (say, to add two new numbers) before all the carries have propagated and the result from the first sum is finished, and the result stored somewhere. To prevent this problem, we need a mechanism of synchronizing the inputs and outputs of the circuits. Synchronization is achieved by a clock. A clock in a computer is a signal (a value on a wire) that alternates between O and 1 at regular rate. When you say that a processor has a clock speed of 3 GHz, you mean that the clock cycles between 0 and 1 at a rate of 3 billion times per second (GHz means gigaherz where giga means billion.) To understand how a clock signal is generated, you would need to take a course in electronics and learn about crystal oscillators. For OMP 273, we will simply assume such a clock signal is available and that it regularly oscillates between 0 and 1 as shown below. The ON interval has the same duration as the OFF interval. 1 0 time clocked RS latch We can combine the clock and the RS latch to give us more control over when we write into the RS latch, namely we only write when the clock is 1. The circuit below is called a clocked RS latch. R S last updated: 26 th Jan, 2016 2

OMP 273 5 - sequential logic 1 Jan. 25, 2016 When = 0, the circuit holds its value regardless of any changes in the R or S inputs. When = 1, the circuit behaves as the RS latch shown above. Note that this does not yet avoid the R = S = 1 situation which I mentioned above. Here is an example of how the output can vary as the R and S inputs vary. Note that transitions in can occur at the transition of from 0 to 1 (in the case that S or R already has the value 1 at that time), or during the time that =1, in the case that S or R becomes 1 while = 1. One tricky case occurs during the second to last clock pulse. uring that pulse, there are two brief events to note: first S goes to 1 temporarily, and then R goes to 1 temporarily. Note what happens to. When S goes to 1, goes to 1, and when S drops back to 0, stays on (memory). falls to 0 a short time later namely when R goes to 1 since then is reset. latch ( for data ) The RS latch allows us to write either a 1 or 0 value by inputing a 1 to S or R, respectively. The latch allows us to write the value of a binary variable. The detailed circuit is shown below on the left. The symbolic representation commonly used is shown on the right. If = 1, then we want to write 1 and so we make the S input be 1 (recall the clocked RS latch). If = 0, then we want to write 0 and so we should make the R input be 1. This is done by feeding into the S input and feeding the complement of into the R input. When = 0, the outputs of the two AN gates is 0 and so holds (latches) its value, regardless of what is. When = 1, the latch is open and the value of is written into. R S last updated: 26 th Jan, 2016 3

OMP 273 5 - sequential logic 1 Jan. 25, 2016 This latch circuit is extremely important, so lets repeat the idea. When = 0, the data input does not get written to and the previous value of is held. A write only occurs when = 1, and in that case the current value of is written and can be read. Also notice that, by design, it is impossible for the R and S inputs to both be 1 here, so our earlier concern about these values being simultaneously 1 now goes away. The latch provides some control on when we can write, but it still not good enough. When the computer s clock signal is 1, data passes freely through the circuits. Let s consider an example of why this is problematic. Suppose we wish to implement an instruction such as x := x + y; We could implement it by putting the values of x and y into circuits made out of an array of sequential circuits. We will discuss the correct way of doing this over the next few lectures. For now, let s look at an incorrect way of doing it, namely by representing x and y as binary numbers and storing the bits of each number in an array of latches. Say we have somehow managed to store y in the A array and x in the B array. (Each of the little boxes in the figure below is supposed to be a latch. We when say store a value we mean that the outputs have that value.) We feed these two arrays into our ALU (arithmetic logic unit) and feed the answer back into the B array, in order to execute the above instruction. What happens? When = 1, the sum bits S i computed by the adder will write their values back into the B i units. But as long as = 1, these newly written values will go right through into the adder again. They will be summed once more with y, and will loop back and be written into the B array again, etc. Moreover, the carry bits will take time to propagate the result and so we cannot even think of succession of additions. What a mess! When becomes 0 again, and writes are no longer allowed, the values that are in the B units are not what we want. last updated: 26 th Jan, 2016 4

OMP 273 5 - sequential logic 1 Jan. 25, 2016 flip-flop We need a mechanism that prevents data from being read from a latch at the same time as it is being written to a latch. The mechanism that achieves this is called a flip-flop. The two basic types of flip-flop are shown below. In each case, we have a pair of latches with the output value of the first being the input of the second, and with the clock being inverted for one latch but not the other. rising edge triggered falling edge triggered Here I discuss just the falling edge one. (The argument of what happens for the rising edge one is very similar.) When goes from 0 to 1, the first latch is written to, but the second latch holds its previous value because the inverted clock input to the second latch goes from 1 to 0. When drops from 1 to 0, the value that had just been written to the first latch now is written to the second latch whose clock input rises from 0 to 1 and this data value appears in the output. Note that when drops from 1 to 0, the value that had just been written into the first latch is held even though the input to the first latch might have changed. The reason the previous value is held is that is 0. We say this flipflop is falling edge triggered because the value changes when the clock falls from 1 to 0. For this mechanism to guarantee the synchronization we desire, the interval of a clock pulse has to be long enough that the combinational circuits (such as adders, multiplexors, etc) between flip-flops have finished computing their output values. onsider again the example above for x := x + y. Each of the bit memory units in fact would be a flip flop rather than a latch. We would now have synchronization. uring a clock pulse (=1), the adder circuit would compute x + y and at the end of the clock pulse when falls from 1 to 0, then result would be written into x. Below is an example of timing diagram for and the value stored in a flip flop. I have included both the rising edge case and falling edge case. last updated: 26 th Jan, 2016 5

OMP 273 5 - sequential logic 1 Jan. 25, 2016 rising edge triggered falling edge triggered Registers To perform an addition, you can imagine that the numbers/bits are read from a set of flip-flops (sequential circuit), go through an adder circuit (combinational circuit) and are written into another set of flip-flops, or even possibly the same flip flops. I gave a sketch of this above, and we ll see how this works in MIPS computer in coming lectures. A set of flip-flops that holds the values of some variable is called a register. The key property of a register is that its flip-flops are written to as a unit. There is no way to selectively write to the individual flip-flops in a register. On any clock cycle, you either write to every flip-flop in the register, or you write to none of the flip-flops in the register. The sketch below shows a four bit register. Each of the square boxes represents one flip-flop. Here I have written FF in each box to emphasize its a flip-flop, not a latch. (In the slides, I didn t write FF, and in future I won t write FF.) Each flip flop has a clock input and data input and a output. FF FF FF FF 3 3 2 2 1 1 0 0 Shift registers A shift register is a special register that can shift bits either to the left or right. We have seen that shifting bits of an unsigned number to the left multiplies that number by 2, and shifting bits to the right divides the number by 2. You can imagine it might be useful to have specialized circuits for computing such shifts. The figure below shows a four bit shift right register. When we shift right, we need to specify the input for the leftmost flip-flop. In the figure below, the leftmost bits is filled with the value of variable 4. You can design the circuit to fill it with whatever you want (0, 1, or even wraparound from 0, etc) and select one of these with a multiplexor. last updated: 26 th Jan, 2016 6

OMP 273 5 - sequential logic 1 Jan. 25, 2016 4 3 2 1 0 Note that for right and left to be meaningful, we need to use the common convention that the least significant bit (that is, 0 ) is on the right. Examples Show a timing diagram of the contents of the above register. Assume the initial values in the register are ( 3, 2, 1, 0 ) = (1, 0, 0, 1) and assume the flip-flops in the register are falling-edge triggered. Also assume that, over the close pulses shown, the value of 4 is 0. (In general, 4 is not always 0, but it makes the timing diagram easier to understand if we think of it as 0. Essentially we are just following the initial 3 value of 1 as this 1 value moves through 2 to 1 to 0. 0 1 2 3 Let s look at a more general shift register that can either shift left or right, and that can also be cleared (all bits set to zero) and that can also be written to as a unit (write to all bits in one clock cycle). Notice that we have tilted each flip-flop on its side in order to simplify the figure. Also notice that we need a 2 bit selector to specify which of the four operations you want to perform. The same selector is applied to each multiplexor. I have only shown bits 7, 8, 9 but you can imagine extending the figure to other bits. last updated: 26 th Jan, 2016 7

OMP 273 5 - sequential logic 1 Jan. 25, 2016 0 9 8 7 S 2 MUX MUX MUX 9 8 7 last updated: 26 th Jan, 2016 8