Professional Documents
Culture Documents
Circuits
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:
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
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:
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