Download The completeness of NAND and NOR gates

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Flexible electronics wikipedia , lookup

Transistor wikipedia , lookup

Opto-isolator wikipedia , lookup

Flip-flop (electronics) wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Rectiverter wikipedia , lookup

Two-port network wikipedia , lookup

Integrated circuit wikipedia , lookup

CMOS wikipedia , lookup

Transcript
CHAPTER 3-1
GATES AND BOOLEAN ALGEBRA
Gates



A digital circuit is one in which only 2 logical values are present.
o Typically, a signal between 0 and 0.5 volt represents one value (e.g. binary 0) and a signal
between 1 and 1.5 volts represents the other value (e.g. binary 1). Voltages outside these 2 ranges
are not permitted.
Tiny electronic devices built from transistors called gates can compute various functions of these 2valued signals. These gates form the hardware basis on which all digital computers are built.
In Figure 3-1(a) we have shown a bipolar transistor (the circle) embedded in a simple circuit.
o The transistor has 3 connections to the outside world: the collector, the base, and the emitter.
o When the input voltage Vin is below a certain critical value, the transistor turns off and acts like an
infinite resistance. This causes the output of the circuit V out to take on a value close to Vcc, an
externally regulated voltage, typically +1.5 volts.
o When Vin exceeds the critical value, the transistor switches on and acts like a wire, causing Vout to
be pulled down to ground (by convention, 0 volts).
o The important thing to notice is that when Vin is low, Vout is high, and vice versa.
 This circuit is thus an inverter, converting a logical 0 to a logical 1, and a logical 1 to a logical
0.
o The resistor (the jagged line) is needed to limit the amount of current drawn by the transistor so it
does not burn out.
o The time required to switch from one state to the other is typically a nanosec or less.
----------------------------------------------------------------------------------------------------------------------------- ---
------------------------------------------------------------------------------------------------------------------- ------------Figure 3-1. (a) A transistor inverter. (b) A NAND gate. (c) A NOR gate.



In Figure 3-1(b) 2 transistors are cascaded in series.
o If both V1 and V2 are high, both transistors will conduct and Vout will be pulled low.
o If either input is low, the corresponding transistor will turn off, and the output will be high.
o In other words, Vout will be low iff both V1 and V2 are high.
In Figure 3-1(c) the two transistors are wired in parallel instead of in series.
o If either input is high, the corresponding transistor will turn on and pull the output down to
ground.
o If both inputs are low, the output will remain high.
These 3 circuits, or their equivalents, form the 3 simplest gates, and they are called NOT, NAND, and
NOR gates respectively.
o NOT gates are often called inverters.
o If we now adopt the convention that high (Vcc volts) is a logical 1, and that low (ground) is a
logical 0, we can express the output value of any of these circuits as a function of the input values.
--------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------- --Figure 3-2. The symbols and functional behavior for the 5 basic gates.





If the output signal of Figure 3-1(b) is fed into an inverter circuit, we get another circuit with precisely
the inverse of the NAND gate, namely, a circuit whose output is 1 iff both inputs are 1.
o Such a circuit is called an AND gate.
Similarly, the NOR gate can be connected to an inverter to yield a circuit whose output is 1 if either or
both inputs is a 1 but 0 if both inputs are 0.
o Such a circuit is called an OR gate.
The small circles used as part of the symbols for the inverter, NAND gate, and NOR gate are called
inversion bubbles. They are often used in other contexts as well to indicate an inverted signal.
The 5 gates of Figure 3-2 are the principal building blocks of the digital logic level.
o The NAND and NOR gates require 2 transistors each, whereas the AND and OR gates require 3
each. For this reason, many computers are based on the NAND and NOR gates rather than the
more familiar AND and OR gates.
o Note that gates may have more than 2 inputs. In principle, a NAND gate, for example, may have
arbitrarily many inputs, but in practice more than 8 inputs is unusual.
The 2 major technologies for constructing gates are bipolar and MOS (metal oxide semiconductor).
o The major bipolar types are TTL (transistor-transistor logic) and ECL (emitter-coupled logic).
o MOS gates are slower than TTL and ECL but require much less power and take up much less
space, so large number of them can be packed together tightly.
o MOS comes in many varieties, including PMOS, NMOS, and CMOS.
o Most modern CPUs and memories use CMOS technology, which runs on a voltage in the
neighborhood of +1.5 volts.
Boolean algebra




To describe the circuits that can be built by combining gates, a new type of algebra is needed, one in
which variables and functions can take on only the values 0 and 1.
o Such an algebra is called a Boolean algebra, after its discoverer, the English mathematician
George Boole.
A Boolean function has 1 or more input variables and yields a result that depends only on the values of
these variables.
Because a Boolean function of n variables has only ____ possible combinations of input values, the
function can be completely described by giving a truth table with ____ rows, each row telling the value
of the function for a different combination of input values.
o Such a table is called a truth table.
o If we agree to always list the rows of a truth table in numerical order (base 2), i.e., for 2 variables
in the order 00, 01, 10, and 11, the function can be completely described by the 2n -bit binary
number obtained by reading the result column of the truth table vertically.
 Thus NAND is ______, NOR is ______, AND is ______, and OR is ______.
 Obviously, only ____ Boolean functions of 2 variables exist.
Figure 3-3(a) shows the truth table for a Boolean function of 3 variables: M=f(A,B,C).
o This function is the majority logic function, i.e., it is 0 if a majority of its inputs are 0 and 1 if a
majority of its inputs are 1.
--------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------- --Figure 3-3. (a) The truth table for the majority function of 3 variables. (b) A circuit for (a).




Although any Boolean function can be fully specified by giving its truth table, as the number of
variable increases, this notation becomes increasingly cumbersome. Instead, another notation is
frequently used.
To see how this other notation comes about, note that any Boolean function can be specified by telling
which combinations of input variables give an output value of 1.
o By convention, we will place a bar over an input variable to indicate that its value is inverted. The
absence of a bar means that it is not inverted.
o Furthermore, we will use implied multiplication to mean the Boolean AND function and + to
mean OR.
o Thus e.g., A B C takes the value 1 only when A=___ and B=___ and C=___. Also, A B +B C is 1
only when (A=___ and B=___) or (B=___ and C=___).
The 4 rows of Figure 3-3(a) producing 1 bits in the output are: _______________________________.
The function, M, is true (i.e., 1) if any one of these 4 conditions is true.
o We can write M=______________________________ as a compact way of giving the truth table.
A function of n variables can thus be described by giving a "sum" of at most ____ n-variable "product"
terms.
Implementation of Boolean functions


The formulation of a Boolean function as a sum of up to 2 n product terms leads directly to a possible
implementation of the function.
o Using Figure 3-3 as an example, we can see how this implementation is accomplished.
o The circuit contains 4 AND gates, one for each term in the equation for M (i.e., one for each row
in the truth table having a 1 bit in the result column).
o Finally, all the product terms are ORed together to get the final result.
o This circuit of Figure 3-3(b) uses a convention that we will need repeatedly: when 2 lines cross, no
connection is implied unless a heavy dot is present at the intersection.
From the example of Figure 3-3 it should be clear how to implement a circuit for any Boolean
function:
1. Write down the truth table for the function.
2. Provide inverters to generate the complement of each input.
3. Draw an AND gate for each item with a 1 in the result column.
4. Wire the AND gates to the appropriate inputs.
5. Feed the output of all the AND gates into an OR gate.
The completeness of NAND and NOR gates

Although we have shown how any Boolean function can be implemented using NOT, AND, and OR
gates, it is often convenient to implement circuits using only a single type of gate.
----------------------------------------------------------------------------------------------------------------------------- ---
----------------------------------------------------------------------------------------------------------------------------- --Figure 3-4. Construction of (a) NOT, (b) AND, and (c) OR gates using only NAND gates or only NOR
gates.


One way to implement a Boolean function using only NAND or only NOR gates is:
o First follow the procedure given above for constructing it with NOT, AND, and OR.
o Then replace the multi-input gates (more than 2 inputs) with equivalent circuits using 2-input
gates. For example, A+B+C+D can be computed as (A+B)+(C+D), using 3 2-input OR gates.
o Finally, the NOT, AND, and OR gates are replaced by the circuits of Figure 3-4.
Both NAND and NOR gates are said to be complete, because any Boolean function can be computed
using either of them.
o No other gate has this property, which is another reason they are often preferred for the building
blocks of circuits.
Circuit equivalence



Circuit designers naturally try to reduce the number of gates in their products to reduce chip area
needed to implement them, minimize power consumption, and increase speed.
o To reduce the complexity of a circuit, the designer must find another circuit that computes the
same function as the original but does so with fewer gates.
o In the search for equivalent circuits, Boolean algebra can be a valuable tool.
As an example of how Boolean algebra can be used, consider the circuit and truth table for AB+AC
shown in Figure 3-5(a).
o Figure 3-5(b) shows the circuit and truth table for A(B+C).
o Because 2 functions are equivalent iff they have the same output for all possible inputs, it is easy
to see from the truth tables of Figure 3-5 that A(B+C) is equivalent to AB+AC.
o Despite this equivalence, the circuit of Figure 3-5(b) is clearly better than that of Figure 3-5(a)
because it contains fewer gates.
Note that NOT has higher precedence than AND which has higher precedence than OR.
----------------------------------------------------------------------------------------------------------------------------- ---
-------------------------------------------------------------------------------------------------------------------------- Figure 3-5. 2 equivalent functions. (a) AB+AC. (b) A(B+C).

In general, a circuit designer starts with a Boolean function and then applies the laws of Boolean
algebra to it in an attempt to find a simpler but equivalent one. From the final function, a circuit can be
constructed.
o To use this approach, we need some identities from Boolean algebra.
o It is interesting to note that each law has 2 forms that are duals of each other. By interchanging
AND and OR and also 0 and 1, either form can be produced from the other one.
o All the laws can be easily proven by constructing their truth tables.
o DeMorgan's law can be extended to more than 2 variables, e.g., ABC = A + B + C .
---------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------Figure 3-6. Some identities of Boolean algebra.

DeMorgan's law suggests an alternative notation.
---------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------Figure 3-7. Alternative symbols for some gates: (a) NAND. (b) NOR. (c) AND. (d) OR.

Using the identities of Figure 3-7 and the analogous ones for multi-input gates, it is easy to convert the
sum-of-products representation of a truth table to pure NAND or pure NOR form.
---------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------Figure 3-8. (a) The truth table for the XOR function. (b)-(d) three circuits for computing it.
Problems
1.
Use a truth table to show that X=(X AND Y) OR (X AND NOT Y).
2.
There exist 4 Boolean functions of a single variable and 16 functions of 2 variables. How many
functions of 3 variables are there? Of n variables?
3.
Show how the AND function can be constructed from 2 NAND gates.
4.
Consider the following truth table which defines the Boolean function f:
A B C X
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0
a. Define the function f using the "sum" of "product" notation.
b. From the answer you gave in a) above, show a digital circuit which implements f using the NOT,
AND, OR gates. To make the diagram simpler, you do not have to draw the NOT gate to invert an
input signal, and you do not need to draw the specific shapes of the gates. For example, the
following is an acceptable drawing:
A
AND
OR
B
A
C
AND