## From Transistors to FunctionsFor the purpose of this class, we will consider transistors to be the basic building blocks of computer hardware. A
More conveniently, transistors are depicted using the picture below.
## Transistors as Faucets!The operation of a transistor could be explained by making an analogy to faucets.
Just like a transistor, a faucet is connected to a
If we represent the fact that water flows from the source to the sink
with a -
When the gate of a transistor is **ON**(or has a value**1**) then electricity flows from the source to the sink and the transistor is said to be**ON** -
Otherwise when the gate of a transistor is **OFF**(or has a value**0**) then electricity does not flow from the source to the sink and the transistor is said to be**OFF**.
The current technology used to build computer hardware (chips) is called CMOS, which stands for Complementary Metal–Oxide–Semiconductor.
In CMOS, in addition to using the transistor described
above, we use another kind of transistors, which is turned
To carry the analogy with faucets, one can think of a faucet that lets water flow from the source to the sink when its knob is tightened but not when the knob is loosened.
## Using Transistors to Build Bigger CircuitsUsing transistors as building blocks, we can build larger circuits that perform interesting (logical) operations.
Our first example is the
Now, let's find out what the inverter circuit above will do when presented with
an input (i.e. -
If **X=0**then by definition of the bottom transistor, it will be**OFF**, which means that electricity will not be able to flow from its source to its sink. Also, by definition, the top transistor will be**ON**, which means that electricity will be able to flow from its source to its sink. The question is, will there be any electricity coming out from**Z**(where**Z**is the output of that circuit). The answer is YES. Since the top transistor is ON and the bottom transistor is OFF, electricity flowing out of the battery will go through the top transistor but will not be able to make it through the bottom one. In other words, it will flow out through**Z**. To visualize the operation of the inverter, it may be helpful to think about this example using the water analogy discussed before. -
If **X=1**then by definition of the bottom transistor, it will be**ON**, which means that any electricity already available at its source will drain in the sink. Also, by definition, the top transistor will be**OFF**, which means that no electricity will be able to flow from its source to its sink. The question is, will there be any electricity coming out from**Z**(where**Z**is the output of that circuit). The answer is NO. Since the top transistor is OFF and the bottom transistor is ON, electricity flowing out of the battery will be blocked by the top transistor and any electricity that may exist in**Z**, will drain. In other words, there will be no electricity flowing out through**Z**. Again, it may be helpful to think about this example using the water analogy discussed before.
The table below sums up the operation of the NOT gate by providing an output (Z) for every possible input (X) of the circuit. Tables like this one (providing us with the value of a function for all possible combination of inputs of that function) are called truth tables.
Figure 6: Truth table summarizing operation of the inverter
circuit (the NOT function).The figure below shows how one could build another circuit using
transistors. This circuit has two inputs Figure 7: The "not both X and Y" circuit (the NAND function).There are 4 possibilities for the inputs, namely **X=0, Y=0****X=0, Y=1****X=1, Y=0****X=1, Y=1**
Let's try to do
an analysis similar to what we did for the Thus we get the truth table below for the circuit shown above.
Figure 8: Truth table summarizing operation of the NAND gate.The above truth table says that the output of the circuit is In order to build an
Similar to the
We leave it as an exercise to check that the truth table for the above circuit is as shown below.
Figure 11: Truth table summarizing operation of the NOR gate.
And, just as we were able to obtain the AND function by
connecting the output of the NAND function to the input of the
NOT function (see figure 9), we can obtain the OR function
(which outputs 1 whenever at least one of its inputs is 1) by
connecting the output of the NOR function to the input of the
NOT function.
## Basic Logic FunctionsFrom the above examples and discussion, we conclude that we
can construct the main logic functions
Since we will be using these functions (or gates) in future designs, we will give
them symbols so that we don't have to draw all the transistors and all
the connections each time we want to use (say) an
For an
For an
Finally, for the
## Other Logic FunctionsBy putting AND, OR, and NOT gates together, we can construct more complex (logic) functions. Let's start with the simple example shown in the figure below-- namely,
constructing a
three-input
This process could be generalized thus allowing us to build
four-input, five-input, etc..
Similarly, we can also construct
The above two examples are simple, since one can predict the behavior
of many
First, we notice that it has two inputs,
For example, if
Similarly, we can do it for
If we do this for all 4 input combinations, we get the truth table below.
Notice that the above procedure could be used to find out the truth table for any logical circuit. From the truth table in Figure 20, we notice that the
behavior of the circuit is such that it produces an output of
Can you guess how many transistors it would take to build the above XOR gate? To summarize, if we take transistors as a building block, one can see how to combine a handful of transistors to build logical functions such as AND, OR, NOT, XOR, etc. By putting a few of these together we get even more complex (interesting) functions, and the process goes on, allowing us to build functionalities as complex as those supported by (say) the processor in your PC. |

**Materials adapted from lecture notes by
Azer Bestavros -- first developed for
CS-101 in 1995.
**