July 2, 2002Latches1 Defining a logic unit A logic unit supports different logical functions on two multi-bit inputs X and Y, producing an output G. This.

Slides:



Advertisements
Similar presentations
Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we’ve already seen. Our schedule will be very.
Advertisements

Lecture 13: Sequential Circuits
Combinational Circuits
Latches/Flip-Flops. Overview We focuses on sequential circuits – We add memory to the hardware that we’ve already seen Our schedule will be very similar.
Give qualifications of instructors: DAP
A. Abhari CPS2131 Sequential Circuits Most digital systems like digital watches, digital phones, digital computers, digital traffic light controllers and.
CS 151 Digital Systems Design Lecture 19 Sequential Circuits: Latches.
Chapter 1 — Computer Abstractions and Technology — 1 Lecture 7 Carry look ahead adders, Latches, Flip-flops, registers, multiplexors, decoders Digital.
Module 12.  In Module 9, 10, 11, you have been introduced to examples of combinational logic circuits whereby the outputs are entirely dependent on the.
1 Lecture 20 Sequential Circuits: Latches. 2 Overview °Circuits require memory to store intermediate data °Sequential circuits use a periodic signal to.
October 16, 2002Flip-flops1 Summary : Latches A sequential circuit has memory. It may respond differently to the same inputs, depending on its current.
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.
IKI a-Latches & Flip-flops
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
LOGIC GATES ADDERS FLIP-FLOPS REGISTERS Digital Electronics Mark Neil - Microprocessor Course 1.
Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Chapter 4 Gates and Circuits.
Chp 6: Synchronous sequential logic 1 Synchronous Sequential Logic Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at.
Chapter 10-Arithmetic-logic units
Arithmetic-Logic Units (ALUs). The four-bit adder The basic four-bit adder always computes S = A + B + CI But by changing what goes into the adder inputs.
Sequential circuit design
Arithmetic-logic units
Some Useful Circuits Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
COE 202: Digital Logic Design Sequential Circuits Part 1
+ CS 325: CS Hardware and Software Organization and Architecture Combinational Circuits 1.
CS1Q Computer Systems Lecture 8
CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay2 The D FlipFlop A 1-bit register is called a D flipflop. When.
1 The Chinese University of Hong Kong Faculty of Education Diploma in Education (Part-Time) Winter 1997 Educational Communications and Technology Assignment.
Chap 4. Sequential Circuits
1 © 2015 B. Wilkinson Modification date: January 1, 2015 Designing combinational circuits Logic circuits whose outputs are dependent upon the values placed.
Digital Logic Computer Organization 1 © McQuain Logic Design Goal:to become literate in most common concepts and terminology of digital.
CS231 Boolean Algebra1 K-map Summary K-maps are an alternative to algebra for simplifying expressions. – The result is a minimal sum of products, which.
IKI b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,
Chapter 3 Digital Logic Structures. 3-2 Combinational vs. Sequential Combinational Circuit always gives the same output for a given set of inputs  ex:
Hamming Code,Decoders and D,T-flip flops Prof. Sin-Min Lee Department of Computer Science.
CS231 Boolean Algebra1 Summary so far So far: – A bunch of Boolean algebra trickery for simplifying expressions and circuits – The algebra guarantees us.
Chapter 3 Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Transistor: Building.
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.
Boolean Functions and Boolean Algebra Laxmikant Kale.
CS1Q Computer Systems Lecture 8
Arithmetic-logic units1 An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the “heart” of a processor—you.
CO5023 Latches, Flip-Flops and Decoders. Sequential Circuit What does this do? The OUTPUT of a sequential circuit is determined by the current output.
Chapter5: Synchronous Sequential Logic – Part 1
Digital Logic Design Basics Combinational Circuits Sequential Circuits Pu-Jen Cheng Adapted from the slides prepared by S. Dandamudi for the book, Fundamentals.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
CS151 Introduction to Digital Design Chapter 5: Sequential Circuits 5-1 : Sequential Circuit Definition 5-2: Latches 1Created by: Ms.Amany AlSaleh.
Sequential circuit analysis1 Sequential Circuit Analysis Last time we started talking about latches and flip-flops, which are basic one-bit memory units.
Sequential Devices Sequential concept: output depends on present as well as past inputs Past inputs influence operations via memory elements.
Sequential Circuit Design 05 Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA.
(Synchronous) Sequential Logic 04 Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA.
Combinational circuits
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Clocks A clock is a free-running signal with a cycle time.
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Circuit analysis summary
Basics Combinational Circuits Sequential Circuits Ahmad Jawdat
CSE 370 – Winter Sequential Logic - 1
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
Unit 10 Arithmetic-logic Units
Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we’ve already seen. Our schedule will be very.
One’s complement addition
From now on: Combinatorial Circuits:
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
ECE 352 Digital System Fundamentals
Sequential circuit analysis
Basic circuit analysis and design
ECE 352 Digital System Fundamentals
Presentation transcript:

July 2, 2002Latches1 Defining a logic unit A logic unit supports different logical functions on two multi-bit inputs X and Y, producing an output G. This abbreviated table shows four possible functions and assigns a selection code S to each. We’ll just use multiplexers and some primitive gates to implement this. Again, we need one multiplexer for each bit of X and Y.

July 2, 2002Latches2 Our simple logic unit Inputs: – X (4 bits) – Y (4 bits) – S (2 bits) Outputs: – G (4 bits)

July 2, 2002Latches3 Combining the arithmetic and logic units Now we have two pieces of the puzzle: – An arithmetic unit that can compute eight functions on 4-bit inputs. – A logic unit that can perform four functions on 4-bit inputs. We can combine these together into a single circuit, an arithmetic-logic unit (ALU).

July 2, 2002Latches4 Our ALU function table This table shows a sample function table for an ALU. All of the arithmetic operations have S 3 =0, and all of the logical operations have S 3 =1. These are the same functions we saw when we built our arithmetic and logic units a few minutes ago. Since our ALU only has 4 logical operations, we don’t need S 2. The operation done by the logic unit depends only on S 1 and S 0.

July 2, 2002Latches A complete ALU circuit G is the final ALU output. When S3 = 0, the final output comes from the arithmetic unit. When S3 = 1, the output comes from the logic unit. C out should be ignored when logic operations are performed (when S3=1). The arithmetic and logic units share the select inputs S1 and S0, but only the arithmetic unit uses S2. The / and 4 on a line indicate that it’s actually four lines.

July 2, 2002Latches6 Comments on the multiplexer Both the arithmetic unit and the logic unit are “active” and produce outputs. – The mux determines whether the final result comes from the arithmetic or logic unit. – The output of the other one is effectively ignored. Our hardware scheme may seem like wasted effort, but it’s not really. – “Deactivating” one or the other wouldn’t save that much time. – We have to build hardware for both units anyway, so we might as well run them together. This is a very common use of multiplexers in logic design.

July 2, 2002Latches7 The completed ALU This ALU is a good example of hierarchical design. – With the 12 inputs, the truth table would have had 2 12 = 4096 lines. That’s an awful lot of paper. – Instead, we were able to use components that we’ve seen before to construct the entire circuit from a couple of easy-to-understand components. As always, we encapsulate the complete circuit in a “black box” so we can reuse it in fancier circuits.

July 2, 2002Latches8 Arithmetic summary In the last few lectures we looked at: – Building adders hierarchically, starting with one-bit full adders. – Representations of negative numbers to simplify subtraction. – Using adders to implement a variety of arithmetic functions. – Logic functions applied to multi-bit quantities. – Combining all of these operations into one unit, the ALU. Where are we now? – We started at the very bottom, with primitive gates, and now we can understand a small but critical part of a CPU. – This all built upon our knowledge of Boolean algebra, Karnaugh maps, multiplexers, circuit analysis and design, and data representations.

July 2, 2002© Howard Huang9 Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we’ve already seen. Our schedule will be very similar to before: – We first show how primitive memory units are built. – Then we talk about analysis and design of sequential circuits. – We also see common sequential devices like registers and counters. In the final third of the semester, we add memory to our ALU to make a complete processor!

July 2, 2002Latches10 Combinational circuits So far we’ve just worked with combinational circuits, where applying the same inputs always produces the same outputs. This corresponds to a mathematical function, where every input has a single, unique output. In programming terminology, combinational circuits are similar to “functional programs” that do not contain variables and assignments. Combinational circuit InputsOutputs

July 2, 2002Latches11 Sequential circuits In contrast, the outputs of a sequential circuit depend on not only the inputs, but also the state, or the current contents of some memory. This makes things more difficult to understand, since the same inputs can yield different outputs, depending on what’s stored in memory. The memory contents can also change as the circuit runs. We’ll some need new techniques for analyzing and designing sequential circuits. Combinational circuit Inputs Memory Outputs

July 2, 2002Latches12 Examples of sequential devices Many real-life devices are sequential in nature: – Combination locks open if you enter numbers in the right order. – Elevators move up or down and open or close depending on the buttons that are pressed on different floors and in the elevator itself. – Traffic lights may switch from red to green depending on whether or not a car is waiting at the intersection. Most importantly for us, computers are sequential! For example, key presses and mouse clicks mean different things depending on which program is running and the state of that program.

July 2, 2002Latches13 What exactly is memory? A memory should have at least three properties. 1.It should be able to hold a value. 2.You should be able to read the value that was saved. 3.You should be able to change the value that’s saved. We’ll start with the simplest case, a one-bit memory. 1.It should be able to hold a single bit, 0 or 1. 2.You should be able to read the bit that was saved. 3.You should be able to change the value. Since there’s only a single bit, there are only two choices: – Set the bit to 1 – Reset, or clear, the bit to 0.

July 2, 2002Latches14 The basic idea of storage How can a circuit “remember” anything, when it’s just a bunch of gates that produce outputs according to the inputs? The basic idea is to make a loop, so the circuit outputs are also inputs. Here is one initial attempt, shown with two equivalent layouts: Does this satisfy the properties of memory? – These circuits “remember” Q, because its value never changes. (Similarly, Q’ never changes either.) – We can also “read” Q, by attaching a probe or another circuit. – But we can’t change Q! There are no external inputs here, so we can’t control whether Q=1 or Q=0.

July 2, 2002Latches15 A really confusing circuit Let’s use NOR gates instead of inverters. The SR latch below has two inputs S and R, which will let us control the outputs Q and Q’. Here Q and Q’ feed back into the circuit. They’re not only outputs, they’re also inputs! To figure out how Q and Q’ change, we have to look at not only the inputs S and R, but also the current values of Q and Q’: Q next = (R + Q’ current )’ Q’ next = (S + Q current )’ Let’s see how different input values for S and R affect this thing.

July 2, 2002Latches16 Storing a value: SR = 00 What if S = 0 and R = 0? The equations on the right reduce to: Q next = (0 + Q’ current )’ = Q current Q’ next = (0 + Q current )’ = Q’ current So when SR = 00, then Q next = Q current. Whatever value Q has, it keeps. This is exactly what we need to store values in the latch. Q next = (R + Q’ current )’ Q’ next = (S + Q current )’

July 2, 2002Latches17 Setting the latch: SR = 10 What if S = 1 and R = 0? Since S = 1, Q’ next is 0, regardless of Q current : Q’ next = (1 + Q current )’ = 0 Then, this new value of Q’ goes into the top NOR gate, along with R = 0. Q next = (0 + 0)’ = 1 So when SR = 10, then Q’ next = 0 and Q next = 1. This is how you set the latch to 1. The S input stands for “set.” Notice that it can take up to two steps (two gate delays) from the time S becomes 1 to the time Q next becomes 1. But once Q next becomes 1, the outputs will stop changing. This is a stable state. Q next = (R + Q’ current )’ Q’ next = (S + Q current )’

July 2, 2002Latches18 Q next = (R + Q’ current )’ Q’ next = (S + Q current )’ Latch delays Timing diagrams are especially useful in understanding how sequential circuits work. Here is a diagram which shows an example of how our latch outputs change with inputs SR=10. 0.Suppose that initially, Q = 0 and Q’ = 1. 1.Since S=1, Q’ will change from 1 to 0 after one NOR-gate delay (marked by vertical lines in the diagram for clarity). 2.This change in Q’, along with R=0, causes Q to become 1 after another gate delay. 3.The latch then stabilizes until S or R change again. S R Q Q’

July 2, 2002Latches19 Resetting the latch: SR = 01 What if S = 0 and R = 1? Since R = 1, Q next is 0, regardless of Q current : Q next = (1 + Q’ current )’ = 0 Then, this new value of Q goes into the bottom NOR gate, where S = 0. Q’ next = (0 + 0)’ = 1 So when SR = 01, then Q next = 0 and Q’ next = 1. This is how you reset, or clear, the latch to 0. The R input stands for “reset.” Again, it can take two gate delays before a change in R propagates to the output Q’ next. Q next = (R + Q’ current )’ Q’ next = (S + Q current )’

July 2, 2002Latches20 SR latches are memories! This little table shows that our latch provides everything we need in a memory: we can set it, reset it, and remember the current value. The output Q represents the data stored in the latch. It is sometimes called the state of the latch. We can expand the table above into a state table, which explicitly shows that the next values of Q and Q’ depend on their current values, as well as on the inputs S and R.

July 2, 2002Latches21 SR latches are sequential! Notice that for inputs SR = 00, the next value of Q could be either 0 or 1, depending on the current value of Q. So the same inputs can yield different outputs, depending on whether the latch was previously set or reset. This is very different from the combinational circuits that we’ve seen so far, where the same inputs always yield the same outputs.

July 2, 2002Latches22 What about SR = 11? Both Q next and Q’ next will become 0. This contradicts the assumption that Q and Q’ are always complements. Another problem is what happens if we then make S = 0 and R = 0 together. Q next = (0 + 0)’ = 1 Q’ next = (0 + 0)’ = 1 But these new values go back into the NOR gates, and in the next step we get: Q next = (0 + 1)’ = 0 Q’ next = (0 + 1)’ = 0 The circuit enters an infinite loop, where Q and Q’ cycle between 0 and 1 forever. This is actually the worst case, but the moral is don’t ever set SR=11! Q next = (R + Q’ current )’ Q’ next = (S + Q current )’

July 2, 2002Latches23 S’R’ latch There are several varieties of latches. You can use NAND instead of NOR gates to get a S’R’ latch. This is just like an SR latch, but with inverted inputs, as you can see from the table. You can derive this table by writing equations for the outputs in terms of the inputs and the current state, just as we did for the SR latch.

July 2, 2002Latches24 An SR latch with a control input Here is an SR latch with a control input C. Notice the hierarchical design! – The dotted blue box is the S’R’ latch from the previous slide. – The additional NAND gates are simply used to generate the correct inputs for the S’R’ latch. The control input acts just like an enable.

July 2, 2002Latches25 D latch Finally, a D latch is based on an S’R’ latch. The additional gates generate the S’ and R’ signals, based on inputs D (“data”) and C (“control”). – When C = 0, S’ and R’ are both 1, so the state Q does not change. – When C = 1, the latch output Q will equal the input D. No more messing with one input for set and another input for reset! Also, this latch has no “bad” input combinations to avoid. Any of the four possible assignments to C and D are valid.

July 2, 2002Latches26 Sequential circuits and state diagrams To describe combinational circuits, we used Boolean expressions and truth tables. With sequential circuits, we can still use expression and tables, but we can also use another form called a state diagram. We draw one node for each state that the circuit can be in. Latches have only two states: Q=0 and Q=1. Arrows between nodes are labeled with “input/output” and indicate how the circuit changes states and what its outputs are. In this case the state and the output are the same. If you’ve taken CS273, this is basically the same as the finite state automata you saw there. Here’s a state diagram for a D latch with inputs D and C. 0x/00x/1 Q=0Q=1 11/1 10/0

July 2, 2002Latches27 Using latches in real life We can connect some latches, acting as memory, to an ALU. Let’s say these latches contain some value that we want to increment. – The ALU should read the current latch value. – It applies the “G = X + 1” operation. – The incremented value is stored back into the latches. At this point, we have to stop the cycle, so the latch value doesn’t get incremented again by accident. One convenient way to break the loop is to disable the latches. +1 ALU S X G Latches D Q C

July 2, 2002Latches28 The problem with latches The problem is exactly when to disable the latches. You have to wait long enough for the ALU to produce its output, but no longer. – But different ALU operations have different delays. For instance, arithmetic operations might go through an adder, whereas logical operations don’t. – Changing the ALU implementation, such as using a carry-lookahead adder instead of a ripple-carry adder, also affects the delay. In general, it’s very difficult to know how long operations take, and how long latches should be enabled for. Tune in tomorrow - same 231 time, same 231 classroom – to find out how to deal with this problem. +1 ALU S X G Latches D Q C

July 2, 2002Latches29 Summary A sequential circuit has memory. It may respond differently to the same inputs, depending on its current state. Memories can be created by making circuits with feedback. – Latches are the simplest memory units, storing individual bits. – It’s difficult to control the timing of latches in a larger circuit. On Wednesday, we’ll improve upon latches with flip-flops, which change state only at well-defined times. We will then use flip-flops to build all of our sequential circuits.