|
|
How do computers really work? We’re going answer this question by demonstrating how complex systems can be constructed from simple elements called gates—in very much the same way that sophisticated programs can be constructed from relatively primitive computer instructions. Unfortunately, we can’t go into the electronic details of circuits (i.e., how they operate at electronic level).
We begin by introducing the three gates from which all other logic elements can be constructed. Practical digital computers cannot be constructed from gates alone; they require memory elements that store information. Without memory you couldn’t even count—you can’t calculate the next number unless you can remember the current one. After we’ve looked at the gate, we introduce the devices that store data and implement counters.
Having introduced the two fundamental elements of a computer we describe the bus or electronic highway along which information flows. Finally, we put all these three elements together and demonstrate how a computer works.
![]() |
The logic element This shows a black box with two input terminals, A and B, and a single output terminal C. This device reads the two logic values at its input terminals and produces an output that depends only on the states of the inputs and the nature of the logic element. Such a logic element is very simple because its inputs and outputs can be in only one of two states; 0 or 1. We call these primitive elements gates, because they are analogous to gates in the real world—they either permit a signal to pass through the gate, or they block it. |
The behavior of a gate is described by its truth table which defines its output for each of the possible inputs.
| The symbol for an AND gate
Truth table for the AND gate a. Two-input AND gate b. Three-input AND gate
|
Table (a) provides the truth table for the two-input AND gate. If the inputs are A and B, the output C is true (i.e., 1) if and only if both inputs A and B are 1. The AND function is represented by the dot, so that the operation A AND B is written A.B. Some math texts employ the symbol “Ç“ to indicate the AND function (i.e., A AND B is written AÇB). The Ç symbol avoids confusion between the dot as the AND operator in Boolean algebra and the dot as the multiply symbol in conventional algebra. AND gates can have any number of inputs—table (b) gives the truth table for an AND gate with inputs three A, B, and C and an output D = A.B.C. In this case the output, D, is 1 only when A AND B AND C are all 1. |
Another fundamental gate is the OR.
| The symbol for an OR gate
Truth table for the OR gate a. Two-input OR gate b. Three-input OR gate
|
The table gives the truth tables for a 2-input OR gate and
a 3-input OR gate. The output of an OR gate is 1 if either one or more of
its inputs are 1. In fact, the only way to make the output of an OR gate go
to a logical 0 is to set all its inputs to 0.
The OR function is represented by the symbol “+”, so that the operation A OR B is written A+B. Some math texts employ the symbol “È“ (e.g., A.B = AÈB) to avoid confusion between “+” as the logical OR operator and the conventional addition operator.
|
The “.” operator is used for the AND function and the “+” operator is used for the OR function because the AND and OR functions behave rather like multiplication and addition, respectively, in conventional algebra. The equation P = A.B + C.D states that P is true if either A and B are true or C and D are true.
The final basic gate is the simplest of all gates, the inverter or complementer. The inverter has a single input and its output is the logical complement of its input. If the input is A, the output is written NOT A, or A, or A*, or A’, or /A. The reason for so many representations of NOT A, is that most word processors can’t create an overbar, and writers have employed various prefixes and suffixes to denote logical negation. If the input is 1, the output is 0 and vice versa. Note that the small circle in figure 4.4 indicates inversion—whenever you see such a circle in a logic diagram, the signal passing through it is inverted.
![]() |
The symbol and truth table for an inverter |
Although we don’t intend to cover Boolean algebra, it is worthwhile looking at how AND and OR gates behave when the inputs are two literals (i.e., the constant value 0 or 1), or a literal and a variable.
|
|||||||||||||||||||||
Several gates can be interconnected to create a circuit. All you have to remember is that the output of a gate can be connected to the input of another gate. An output can be connected to several inputs, but two outputs cannot be connected together. Suppose the outputs of two inverters were connected together and the input to one inverter was 0 and the input to the other inverter was 1. The output of one inverter would be 1 and the output of the other would be 0. If both outputs were connected together, they would have to be the same value (because the voltage at a point can have only one value at any instant).
![]() |
A circuit with four gates This circuit has four gates, labeled G1, G2, G3 and G4. Lines that cross each other in a diagram without a dot at their intersection are not connected together—lines that meet at a dot are connected. This circuit has three inputs A, B, and X, and an output C. It also has three intermediate logical values; the outputs of gates G1, G2, and G3 are labeled P, Q, and R, respectively. When dealing with a circuit like this, you can treat a gate as a processor that operates on its inputs according to its logical function; for example, the inputs to AND gate G3 are P and X, and its output is P.X. Because P = A+B, the output of G3 is (A+B).X. Similarly the output of gate G4 is R+Q, which is (A+B).X + AB. |
Boolean (i.e., logical) expressions involving AND and OR operators follow the rules of conventional algebra—brackets are evaluated first, and the AND operator takes precedence over the OR operator. Consider the expression A.C + B(C + D). The evaluation of the bracketed expression C + D takes place first, and the result is ANDed with B. Input A is ANDed with C, and the result ORed with the previous result B(C + D).
One way of analyzing the above circuit of figure is to employ a truth table to tabulate all the inputs, intermediate values, and outputs. Intermediate values P and Q are the AND and OR functions of A and B, respectively. Note how the patterns for P and Q in the truth table are each repeated, once with input X = 0, and once with input X = 1. You should expect this result, because the value of X doesn’t affect the equations for P and Q. The intermediate value R is given by P.X (i.e., (A+B).X).
![]() |
Truth table The output of the circuit is C = (A+B).X + A.B. But what does it actually mean? If you look at the table, you can find a pattern. When input X = 0, the output C is identical to A.B (i.e., A AND B). When input X = 1, the output is identical to A+B (i.e., A OR B). We have just constructed a programmable logic element that performs an AND operation or an OR operation depending on the state of one of its inputs, X. Suppose X is connected to a signal that comes from an instruction in a computer, the operation carried out would be a logical AND or an OR depending on the nature of the instruction. In a real computer, the circuit would be replicated for each bit of a word and all control inputs would be connected together. Let’s introduce some new gates. |
The next three gates can all be derived from a combination of AND, OR, and NOT gates. The figure below provides the circuit symbols for the NOR gate, the NAND gate, and the Exclusive OR gate, respectively. The term NOR gate is a contraction of the words Not and OR, because a NOR gate is equivalent to an OR gate followed by an inverter. The symbol for the NOR gate is the same as the OR gate, except that the NOR gate has a bubble at its output to show that the output is inverted. If you look at the truth table for the NOR gate , you will see that its output is true if and only if both inputs are false.
![]() |
Three new gates
|
The NAND gate is equivalent to an AND gate followed by an inverter (i.e., Not AND). The output of a NAND gate is false if both inputs are true, and false otherwise. There are two interesting aspects of NOR and NAND gates. The first is that they are actually easier to fabricate in silicon than their OR and AND counterparts. The second is that any digital circuit can be constructed from NOR gates only (or NAND gates only). Because gates are used to make digital circuits, and digital circuits are used to make computers, any general-purpose digital computer—no matter how sophisticated—can be constructed from NOR gates only.
The Exclusive OR function often written EOR or XOR, and uses the special mathematical symbol Å (e.g., C = A Å B). The EOR gate behaves, in some ways, rather like an OR gate. The difference between an exclusive OR and a conventional or inclusive OR gate arises when both inputs are true; that is, 1 + 1 = 1 whereas 1 Å 1 = 0. An EOR gate can be constructed from two inverters, two AND gates and an OR gate, because A Å B = A*.B + A.B*.
The EOR is a difference detector—the output is true if the inputs are different (i.e., 0 and 1, or 1 and 0).