conmbinational circuit

Upload: ulsece

Post on 29-May-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Conmbinational Circuit

    1/8

    1

    Chapter Two: Basic Combinational

    Circuits

    Basic Types of Digital Circuits

    The basic and, or, and not gates presented in the last chapter can be combined in a hugevariety of ways to build the digital circuitry that drives modern computers. Two basic

    categories of circuits are

    ?? Combinational Circuits: Circuits whose outputs depend only on the currentinputs; hence they appear to combine the inputs in some way to produce the

    outputs; and

    ?? Sequential Circuits: Circuits whose outputs depend on the both the current and

    past inputs; hence they use the sequence of inputs over time to determine theoutput.

    For example, memory circuits are inherently sequential, and a circuit which takes twobinary numbers, adds them, and outputs the sum, would be combinational. In this chapter

    we will consider how to analyze and to design combinational circuits, as well as look at avariety of the most important examples. When we look at SRAM in a later chapter, wewill return to the idea of sequential circuits.

    Analyzing Combinational CircuitsA combinational circuit can be thought of as an implementation of a Boolean function: it

    takes some inputs A, B, C, etc., and produces a unique output f(A,B,C, ). The circuititself is just a network of the basic gates, where the information flows in one direction

    only (in this book, generally from left to right). For example, here is a simple circuit thatcomputes a useful Boolean function of two inputs:

    What function does this implement? To find out, let us analyze this function for allpossible inputs, that is, let us create a truth table with rows for each possible combination

    of input bits. To do the analysis for each case, we simply write the bits on the input

  • 8/9/2019 Conmbinational Circuit

    2/8

    2

    wires, and then propagate them to the right by using the truth tables for each of the basicgates, eventually arriving at the output; here is the circuit with A=B=0:

    If we do the same for the other three possible input patterns, we arrive

    at the following truth table:

    This is the Exclusive-OR function: it differs from the normal, or

    inclusive-OR in that it excludes the case A=B=1.1

    Evaluating the Design of a Combination Circuit

    Whenever a circuit is designed, it is analyzed carefully (just like C++ programs) to

    answer these two questions:

    ?? How much space does it take up? This generally means simply how many gates(or how many transistors) it contains. Larger circuits are more expensive,

    consume more power, and take up more room on a crowded chip. Just as withC++ programming, it is always worth finding a smaller, more elegant design that

    does the same thing.

    ?? How much time does it take to do the computation? You are probably familiarfrom CS 112 with analyzing the efficiency of your C++ program in terms of its

    worst-case performance. This gives us a guarantee about the running time of thatprogram. A combinational circuit does its work by propagating an electrical

    signal along the wires and through its gates, each of which has some delay whilethe transistors change state (see the box at right). The most important difference

    between a circuit and a C++ program is that a program is sequential (one step at atime) whereas a circuit is parallel (many parts of the computation occur at once).

    If we discount the time it takes for electricity to flow through the wire, then what

    1The normal OR is normal only in Computer Science---in English it is the exclusive-OR that is more

    normal.

    The xor function is so

    common (we shall seea very important use of

    it below) that it isconsidered a gate

    itself and given its ownsymbol:

  • 8/9/2019 Conmbinational Circuit

    3/8

    3

    we need to know is: what is the longest path from some input to some output(length = number of gates along the path). For example, there are four paths

    through the xor circuit above, two with two gates, and two with three gates; hencethe time between the inputs getting their values, and the output producing a

    correct value is 3 times the gate delay.2

    Some Important Combination Circuits

    We now present a number of combinational circuits that will appear later in importantroles in the construction of the processor and memory units. Their size and worst-case

    performance will be briefly considered as well.

    Multiple-Input AND

    The and gate is extremely useful, and is often generalized to more than two input wires;for example, we can have a 6-input and gate that returns a 1 only if all its inputs are 1:

    You can imagine how this might be constructed using six transistors in series, instead ofjust two; unfortunately, due to the electrical properties of transistors, it is not possible to

    create and gates with an arbitrarily large number of inputs (say, a million). Thus, let usconsider how to construct a combinational circuit out of two-input and gates that behaves

    like a huge and gate with M inputs, for some large M. For now, let us just consider thecase M=8; here is one way to create an and circuit with 8 inputs:

    Unfortunately, this is not a very good design. The signal has to propagate through each

    of the gates in sequence, since each gate depends on the value output by the previousone. Thus, it takes M-1 gate delays. One very basic design principle we will see over

    and over is to try to introduce as much parallelism as possible. For example, a betterdesign for this circuit is this one:

    2This assumes that each gate has the same delay, which does not look very reasonable in the simple gate

    designs we have seen in chapter one; however, in the actual circuits used in real computers, there is more

    regularity in the design of the gates, and this assumption is a good approximation. One gate delay is about

    2-3 ns (nanoseconds = billionths of a second).

  • 8/9/2019 Conmbinational Circuit

    4/8

    4

    This design takes the same number of gates, but the signal (flowing in parallel in different

    branches of the sideways tree) has to pass through only 3 gates! The same design can beused to create and- and or-circuits with any number of inputs.

    Comparator

    One of the most common things to do in C++ programming is to test two variables (or a

    variable and a constant) to see if their values are the same. A circuit that tests two binary

    bit patterns to see if they are identical or not is called a comparator: it outputs a 1 if theinputs are identical, and 0 if they are not. How could we design such a circuit? One ofthe best things to do when faced with a complex problem is to consider the simplest

    example of such a problem and solve that first; then try to construct a general solutionfrom your small solution (this is called divide and conquer). The simplest example of a

    comparator is one that takes two bits as input and returns a 1 if they are the same, and 0otherwise, that is, it has the following truth table:

    Another good thing to do when trying to solve problems is to think about whether youhave seen something similar before, that is, can you reuse or adapt a previous solution

    (meaning, a circuit you have already seen)? If you examine the xor circuit above, youllsee that it is the opposite of what we are interested in here; so, lets just put an inverter on

    the output:

    Now that we have divided, lets conquer: if we want to construct a four-bit (half byte)comparator, we need to check if the first bits are the same, and the second are the same,

    and the third, and the forth. This means combining the outputs of four one-bitcomparators using a four-input and gate:

  • 8/9/2019 Conmbinational Circuit

    5/8

    5

    Modern computers store variables in 32 bit (or even 64 bit) words---if we needed a 32-bit

    comparator, we would probably need to use an and-circuit with 32 inputs to collect allthe outputs from the 32 one-bit comparators. However, the divide and conquer approach

    would work just the same.

    DecoderA decoder is a very important combinational circuit that is used in accessing memory,

    among other uses. A decoder has N inputs and 2N

    output lines; each of the 2N

    possiblepatterns of bits on the inputs corresponds to one of the output lines, and when that input

    pattern appears, the corresponding output line is set high (given the value 1). If weimagine a simple phone system as consisting of separate wires traveling to each phone

    from your own, a decoder could be used, for example, to read the (binary) phone numberyou are dialing, and to send a signal to the ringer on the remote phone. Here is a circuit

    diagram of a 3 to 8 decoder:

  • 8/9/2019 Conmbinational Circuit

    6/8

    6

    (This diagram was taken from Tanenbaum, Structured Computer Organization, p.133).

    The reader should trace through this circuit, and verify that it behaves as follows:

    Multiplexers and Demultiplexers

    Another important combinational circuit is a multiplexer, which takes 2n data inputlines, plus n additional address inputs, and, depending on the bits present on theaddress inputs, sends one of the 2n input values to the output. In other words, the address

    lines select the data input that is to be routed to the output. If the information goes in theopposite direction, you have a demultiplexer. You might think of this as a primitive kind

    of phone switchboard, where there are multiple phone lines (the data lines) coming toyour phone (the output), and the phone number (the address lines) you dial determines to

    which phone you are connected. If you are listening to the remote caller, then one of a

  • 8/9/2019 Conmbinational Circuit

    7/8

    7

    number of inputs is being routed to your one output (the speaker on your phone), and thisis like a multiplexer; if you are talking, then your microphone is the input to a

    demultiplexer, which routes your voice to one of a number of output lines. These circuitscan be constructed easily from a basic decoder, and will form a question on your first

    homework.

    Here is a simple use of a multiplexer and demultiplexer to route one of four inputlines to one of eight output lines (you can think of these as phone lines, or data lines in acomputer). The address lines specify which of the appropriate data lines is active.

    Essentially, the address lines specify the number of the data line in the binary number

    system, which we will cover in the next chapter. For example, if A0=B1=0 and the restof the address lines are 1, then whatever bit is placed on I1 will come out Out5.

  • 8/9/2019 Conmbinational Circuit

    8/8

    8

    ??

    ?? Examples of some important combinational circuits

    o Comparator

    o Multiplexero Decoder/Demultiplexer

    o Shifter, Full-adder (to be covered in later section)

    ?? Designing combinational circuits (This will be covered in lab)

    ?? Construct BE

    ?? Construct Truth table from BE

    ?? Construct circuit from TT

    ?? Minimizing Circuits (This also will be covered in lab, or in exercise)

    HW1:

    ?? Create Demultiplexer from decoder circuit; analyze depth and size as getsbigger

    ?? Create high fan in AND from two input, analyze depth

    ?? Design circuit X using method, minimize

    ?? Analyze time delay of circuits, perhaps 32-bit wide ALU, using longest-pathanalysis

    ?? Design XOR using transistors, or 6 input OR

    ?? Look on web for some info about something, report on it?

    ?? Something on binary numbers

    ?? Gate delay and the speed of light