You are on page 1of 8

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 huge
variety 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 current
inputs; 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 the
output.
For example, memory circuits are inherently sequential, and a circuit which takes two
binary 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 a
variety of the most important examples. When we look at SRAM in a later chapter, we
will return to the idea of sequential circuits.

Analyzing Combinational Circuits


A 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 circuit
itself 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 that
computes a useful Boolean function of two inputs:

What function does this implement? To find out, let us analyze this function for all
possible 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

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

The xor function is so


If we do the same for the other three possible input patterns, we arrive common (we shall see
at the following truth table: a very important use of
it below) that it is
considered a “gate”
itself and given its own
symbol:

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 with
C++ 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 familiar
from 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 that
program. A combinational circuit does its work by propagating an electrical
signal along the wires and through its gates, each of which has some delay while
the 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 a
time) 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

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

2
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; hence
the 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 important
roles 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 of
just 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 us
consider 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 the
case 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 previous
one. 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 better
design for this circuit is this one:

2
This 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).

3
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 be
used 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 the
inputs are identical, and 0 if they are not. How could we design such a circuit? One of
the 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 solution
from 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 0
otherwise, that is, it has the following truth table:

Another good thing to do when trying to solve problems is to think about whether you
have 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, you’ll
see that it is the opposite of what we are interested in here; so, let’s just put an inverter on
the output:

Now that we have divided, let’s 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-bit
comparators using a four-input and gate:

4
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 all
the outputs from the 32 one-bit comparators. However, the divide and conquer approach
would work just the same.

Decoder
A 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 possible
patterns 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 we
imagine 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 number
you 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:

5
(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” input
lines, plus n additional “address” inputs, and, depending on the bits present on the
address 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 the
opposite 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 to
your 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

6
number of inputs is being routed to your one output (the speaker on your phone), and this
is 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 circuits
can 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 input
lines to one of eight output lines (you can think of these as phone lines, or data lines in a
computer). 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 rest
of the address lines are 1, then whatever bit is placed on I1 will come out Out5.

7
??
? ? Examples of some important combinational circuits
o Comparator
o Multiplexer
o 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 gets
bigger
? ? 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-path
analysis
? ? 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

You might also like