Você está na página 1de 39

An Introduction to Digital Logic - Signals and Gates

What Are You Going To Learn? Logic Signals And Gates


AND OR NOT (Inverter) NAND

Wiring A Gate

A NAND Simulation

An Example Problem Boolean Algebra Problems


You are at: Elements - Logic Circuits - Gates Return to Table of Contents

Introduction - Why Do You Want to Learn This Material?


In this lesson you're going to be introduced to Digital Logic. There are lots of reasons to learn digital logic. Here are some of those reasons.

Digital logic is the foundation for digital computers. If you want to understand the innards of computers you need to know digital logic. Digital logic has relations to other kinds of logic including: o Formal logic - as taught by many philosophy departments o Fuzzy logic - a tool used to design control systems and many other systems. o So, in learning digital logic you learn something that helps you elsewhere. For many students, learning digital logic is fun.

What Are You Going to Learn?


There are at least two general areas you need to become familiar with.

First, there's background you need to know - the basics of digital logic things like zeros and ones (0s and 1s) and how you can represent signals as sequences of zeroes and ones. Eventually you will want to know how large

arrays of zeroes and ones can be used in computer files to store information in pictures, documents, sounds and even movies and you'll want to learn about how information can be transmitted, between computers and digital signal sources. You will also need to know things about digital circuits - gates, flip-flops and memory elements and others - so that you can eventually design circuits to manipulate digital signals.

Here is a short list of the topics you will learn.


Learn what logic signals look like Model logic signals Learn Boolean algebra for logic analysis Learn about gates that process logic signals Learn how to design some smaller logic circuits Learn about flip-flops and memory elements that store logic signals

Objectives For This Lesson


Here's what we are after in this lesson - what you should be able to do. Given a system that uses logic signals Be able to specify what the output will be when the input is zero (0) and what the output will be when the input is one (1). Given an AND, OR, NAND or NOT gate, Be able to determine the output of the gate given the input logic signals. Given a system that requires gates, Be able to wire a chip correctly, and to check that the chip is functioning properly.

Logic Signals
There are a number of different systems for representing binary information in physical systems. Here are a few.

A voltage signal with zero (0) corresponding to 0 volts and one (1) corresponding to five or three volts.

A sinusoidal signal with zero corresponding to some frequency, and one corresponding to some other frequency. A current signal with zero corresponding to 4 milliamps and one corresponding to 20 milliamps. And one last way is to use switches, OPEN for "0" and CLOSED for "1". (And there are more ways!)

Characteristics of Logic Signals


We should note that all of these signals can and usually will change in time, so that we really are looking at dynamic situations. However, we will start by looking at these signals as though they were not changing in time.

We will pick a voltage signal as a working example. It can take on two values corresponding to 0 and 1. We can associate a variable with that logic signal, and we can assign a symbol to represent that variable - like the symbol A.

Think Binary!
Let's examine a typical situation. You have some sort of device that generates a logic signal.

It could be a telephone that converts your voice signal into a sequence of zeros and ones. It could be the thermostat on the wall that generates a 1 when the temperature is too low, and a 0 when the temperature is above the set point temperature.

The logic signal, A, takes on values of 0 (FALSE, OFF) or 1 (TRUE, ON). That signal might really be a voltage, a switch closure, etc. However, we want to think in terms of zeros and ones, not in terms of the values of the voltage.

Operations on Logic Signals

Once we have the concept of a logic signal we can talk about operations that can be performed on logic signals. Begin by assuming we have two logic signals, A and B. Then assume that those two signals form an input set to some circuit that takes two logic signals as inputs, and has an output that is also a logic signal. That situation is represented below.

The output, C, depends upon the inputs, A and B. There are many different ways that C could depend upon A and B. The output, C, is a function, - a logic function - of the inputs, A and B. IWe will examine a few basic logic functions AND, OR and NOT functions and start learning the circuitry that you use to implement those functions.

Logic Gates
If we think of two signals, A and B, as representing a truth value of two different propositions, then A could be either TRUE (a logical 1) or FALSE (a logical 0). B can take on the same values. Now consider a situation in which the output, C, is TRUE only when both A is TRUE and B is TRUE. We can construct a truth table for this situation. In that truth table, we insert all of the possible combinations of inputs, A and B, and for every combination of A and B we list the output, C.

False False False False True False True False False True True True An AND Example

Let's imagine a physician prescribing two drugs. For some conditions drug A is prescribed, and for other conditions drug B is prescribed. Taken separately each drug is safe. When used together dangerous side effects are produced. Let

A = Truth of the statement "Drug 'A' is prescribed.". B = Truth of the statement "Drug 'B' is prescribed.". C = Truth of the statement "The patient is in danger.".

Then, the truth table below shows when the patient is in danger. A B C

False False False False True False True False False True True True Notice that C is TRUE when both A AND B are true and only then!

AND GATES
An AND function can be implemented electrically using a device known as an AND gate. You might imagine a system in which zero (0) is represented by zero (0) volts, and one (1) is represented by three (3) volts, for example. If we are going to use electrical devices we need some sort of symbolic representation. There is a standard symbol for an AND gate shown below.

Often in lab work it's helpful to use an LED to show when a signal is 0 or 1. Usually a 1 is indicated with an LED that is ON (i.e. glowing). You can use the buttons below to check out this AND gate (Note what an AND gate symbol looks like!) with a simulated LED. Note the following in the simulation (and you can use this in your lab experiments).

To get a logical zero, connect the input of the gate to ground to have zero (0) volts input. To get a logical one, connect the input of the gate to a five (5) volts source to have five volts at the input. Each button controls one switch (two buttons - two switches) so that you can control the individual inputs to the gate. Each time you click a button, you toggle the switch to the opposite position.

Question Q1. You have an AND gate. Both inputs are zero. What is the output?

We now have two ways of representing an AND gate, the truth table and the circuit diagram. However, there is a third way of representing this information a symbolic way - that will take us toward Boolean algebra. Let us consider our variables, A, B and C to be algebraic variables, but algebraic variables that can only take on two values, 0 and 1. Then we represent the AND function symbolically in either of two ways. C = AB or C = AB Some will prefer always to insert the dot between the variables so that the AND operation is clearly indicated. Many times, the context will allow you just to use AB, without a dot between A and B, but if there is a variable named AB, then confusion can arise. Problems

Assume you have an AND gate with two inputs, A and B. Determine the output, C, for the following cases.

P1. A = 1, B = 0 P2. A = 0, B = 1

P3. If either input is zero, what is the output?

P4. A = 1, B = 1

Once we introduce Boolean variables, we can rethink the concept of a truth table. In the truth table below, if A, B and C are truth tables and we have an AND gate with A and B as inputs and C as the output, the truth table would look like this. A 0 0 1 1 B 0 1 0 1 C 0 0 0 1

OR Gates
Consider a case where a pressure can be high and a temperature can be high Let's assume we have two sensors that measure temperature and pressure.. The first sensor has an output, T, that is 1 when a temperature in a boiler is too high,

and 0 otherwise. The second sensor produces an output, P, that is 1 when the pressure is too high, and 0 otherwise. Now, for the boiler, we have a dangerous situation when either the temperature or the pressure is too high. It only takes one. Let's construct a truth table for this situation. The output, D, is 1 when danger exists.

False False False False True True True False True True True True What we have done is defined an OR gate. An OR gate is a gate for which the output is 1 whenever one or more of the inputs is 1. The output of an OR gate is 0 only when all inputs are 0. Shown below is a schematic symbol for an OR gate, together with the simulated LEDs and input buttons so that you can explore OR gate behavior.

In terms of Boolean variables, the truth table for an OR gate looks like this.

A 0 0 1 1

B 0 1 0 1

C 0 1 1 1

Problems Assume you have an OR gate with two inputs, A and B. Determine the output, C, for the following cases. P5. A = 1, B = 0

P6. A = 0, B = 1

P7. If either input is one, what is the output?

NOT Gates (Inverters) A third important logical element is the inverter. An inverter does pretty much what it says. If the input is 0, the output is 1. Conversely, if the input is 1, the output is 0. The symbol for an inverter is shown below. Again, you can putter with this inverter with the simulated LEDs. X is the input to the inverter. The output is NOT-X represented as ~1 or:

The truth table for an inverter is pretty simple since there is only one input. Call the input A, and the output C, and the truth table is:

A 0 1 Example Problem

C 1 0

You need to control two pumps that supply two different concentrations of reactant to a chemical process. The strong reactant is used when pH is very far from the desired value, and the weak reactant when pH is close to desired. You need to ensure that only one of the two pumps runs at any time. Each pump controller responds to standard logic signals, that is when the input to the pump controller is 1, the pump operates, and when that input is 0, the pump does not operate. You have a bunch of two-input AND gates (IC chips), OR gates and Inverters, and you need to design a logic circuit to control the pumps. You can generate a signal that is 1 when Pump S is ON, and 0 when Pump W is ON. Can you design the circuit? In order to solve the problem, consider that the pump controls should receive logical inverse signals. When one pump signal is one, the other is zero. Given that recognition this circuit should work. Here, if X is 1, Pump S pumps.

Notice the simple way we can use a switch and a five volt supply to produce a single logic signal that is ""0"" (ground) or 1 (5 volts). NAND Gates

There is another important kind of gate, the NAND gate. Actually, the way to start thinking about a NAND gate is to think of it as an AND gate with an inverter on the output. That's shown below.

Actually, however, the symbol for a NAND gate compresses the inverter down to a dot at the output of the NAND gate as shown below.

Here is a simulated NAND gate. Check it out.

A 0 0 1 1 Wiring a Quad-NAND Chip

B 0 1 0 1

C 1 1 1 0

If you want to use gates, you will need to learn something about their physical characteristics. In this section we'll walk you through wiring a simple gate circuit using one specific integrated circuit (IC) the 7400 chip. It's a good introduction to some of the more complex logic chips that you'll probably be using later.

Here's a picture of the 7400 chip in a circuit board. This chip is actually an N74LS00P. The LS tells you that it is a low power Schottky chip. Every manufacturer will embed the 7400 or 74LS00 in other part numbers.

Notice that this chip has fourteen pins. If you want to use an IC chip, then you will always need to know the pinout. That's electrical engineering lingo for describing the way the pins are connected to the internal circuitry of the chip. You need to know where the power supply is connected and where the gate inputs and outputs are connected. Here's the pinout for a 7400 chip.

The first step in wiring the 7400 is to connect the positive power supply. Use a five volt (5v) power supply and don't turn it on yet. Connect a lead to pin 14 as shown below, and connect the other end of that lead to a 5v supply. Keep the power supply turned off until you have everything connected. Here's what that looks like when the positive supply voltage to the chip is wired.

The next step in wiring the 7400 is to connect the ground connection. Connect a lead to pin 7 as shown below, and connect the other end of that lead to ground.

Notice the pattern to this connection. The power to this digital logic chip goes to the corners. Remember, power to the corners for logic chips. Now you can connect the two inputs to one of the gates on the chip. You're going to put 5v on either of these inputs for a 1 and ground the input for a 0. There are two wires in the picture below that connect to pins 1 and 2 on the chip. Those pins are the inputs for one of the NAND gates on the chip.

Now you can connect the output of the gate. You will need to connect this output to something like a voltmeter or an oscilloscope so that you can measure and observe the output of the gate. (And the voltmeter or oscilloscope will also have to be connected to the ground. You will measure output voltage with respect to ground.) The output will be near 5v when the output is a 1 and near 0v when the output is a 0.

Actually, you can often connect LEDs to give a visual indication of a 1 (LED lighted) or a 0 (LED dark). Here some LEDs are shown, together with 1kW current limiting resistors. If you connect LED indicators to your circuit remember that an LED is not the same in both directions, and you have to get the correct end connected to the resistor. The other end of each LED is connected to ground (or just "grounded"). Here's the circuit to show the output of a NAND gate:

When the output of the gate is a 1, the output voltage will be five (5) volts. Current will flow through the series combination of the resistor and the LED, so the LED will light. When the output of the gate is a 0, the output voltage will be zero (0) volts and the LED will not be lit. Thus, the LED lights up when the output is a 1, and doesn't light when the output is a 0. You can use this indication scheme to show the status for any signal. (It doesn't have to be the output of a gate.) Click here for an introductory laboratory on the 7400 chip. Question

Q1 In the picture above, (shown again here) is the power turned on for the chip power supply?

A NAND Gate
Here is a photo of a NAND gate wired to display the input signals and output signals. In this simulation you can manipulate the inputs and see the inputs and outputs. Note the following.

The input voltage can be set to either 5v or 0v (ground) for each input to one of the NAND gates on the chip. Five volts is a logical 1, and zero volts is a logical zero. o Note how the push buttons move a connection from 5v to ground when the button is pushed. When an signal is a 1, there is an LED that lights to show that the input is 1. When the LED is not lit, the signal is 0. o Note that there is a current limiting resistor in series with each LED. If the voltage at the output becomes 5v and the LED "saturates" around 1.8v, you need a current limiting resistor. These resistors look to be 1k. The power supply connection and the ground connection to the chip are both shown. The vertical line of connection points on the circuit board is ground.

Check out how the circuit works and note all of the connections that you need to make to ensure that the chip works as it is supposed to work. Example Problem Let's reconsider the pump problem. What happens if there are times when you don't want either pump to pump? Assume you have a digital signal that is 1 when one of the two pumps is to pump, and 0 when neither pump is to pump. For example, if the pH was very close to desired you wouldn't want to do anything at all so you wouldn't want either pump to turn on.. You still have the other signal that determines which pump is to pump whenever one of the pumps should pump. Devise a circuit that will ensure that both pumps are OFF when the Pumpsignal is 0 and that the correct pump pumps when the Pump signal is 1. The circuit you devise in this section will be simple enough that you can probably implement it with a few chips although you will need to look for chips with AND gates and inverters. You should be able to handle that now. Work through the solution in this lesson and try it out in lab if you can.

Example Solution Let's look at this problem with a truth table. Here's the truth table.

Pumps Pump On Choice Pump Pump 1= 0=S S W ON 1=W 00 1 0 21 31 0 1 0 1 0 0 0 1 0 0 1 0

In English, we say to turn Pump S (Strong reactant) ON when the pumps are ON, and the strong reactant is chosen (Choice 3) and to turn Pump W (Weak reactant) ON when the pumps are ON and the weak reactant is chosen (Choice 2). Otherwise, do nothing. If we examine it closely we see that there is exactly one term in each function. S is 1 only for choice 3, that is when you want PUMPS ON and you want the strong reactant. Similarly, W is 1 only for choice 2. Here's the truth table again. Note the following:

We have defined Boolean variables here for the various signals, P, C, S, and W. We have indicated the inputs by shading them green, and the outputs by shading them orange. P 0 1 2 3 0 0 1 1 C 0 1 0 1 S 0 0 0 1 W 0 0 1 0

Looking at the statement "S is 1 . . . when you want Pumps ON AND you want the strong reactant" then you can generate a logic expression directly from the statement.

and also:

Finally, realize that it doesn't take much to implement these functions. Note you only need one inverter and two AND gates. Here's the circuit that turns the pumps on at the proper time. This is an interactive simulation of the circuit, so you can toggle the switches with the push buttons. Check it out. Question Q2 To check out the circuit you should what?

A QUICK QUESTION Within the simulated circuit, determine the part of the circuit that genrates a 1 when the pumps are ON, and a 0 when they both are OFF.

What If The Problem Isn't So Simple?


Not all functions are as simple as this one, and certainly not all can be implemented with just a few gates. However, implementing this simple function gives us a clue how to implement more complex functions. In the next lesson we'll look at a more general method for implementing functions - a method that uses only AND and OR gates and inverters - but a method which can also be implemented with only NAND gates. We hope that sounds intriguiging to you and that you are looking forward to the next lesson. Click here to go to the lesson on logic functions.

Boolean Algebra
Clearly at this point we are entering a realm of a different kind of algebra. We have encountered some example terms in this algebra.

and:

The algebra is unusual because the variables in the algebra (S, P, C and W in the example) can take only two values, 0 and 1. In this section we will examine some of the properties of this algebra, and the implications of what we have already learned. There are some simple things we need to establish before we can proceed.

An AND gate has this truth table when the inputs are A and B, and the output is C:

A 0 0 1

B 0 1 0

C 0 0 0

So, clearly we have: o 00 = 0, and o 11 = 1, and o 01 = 0 Which may be exactly what you expected. We also need to consider an OR gate.

An OR gate has this truth table when the inputs are A and B, and the output is C:

A 0 0 1 1

B 0 1 0 1

C 0 1 1 1

So, clearly we have: o 0 + 0 = 0, and o 1 + 1 = 1, and o 0+1=1

Now, if you are taking a college course, and you write home that 1 + 1 = 1 is what you just learned, your parents may want your tuition refunded. Now, if you accepted what was claimed above, then you also have to accept the following: AA = A Just let A be either zero or one and remember the truth table for an AND. We also have:

A+A=A Again, just let A be either zero or one and remember the truth table for an OR. And - - - believe it or not, this result for A + A is very useful because it is a fundamental result that will let us build circuits with fewer gates. We'll come back to that later. There are some interesting theorems that can be proved. Note the following:

These two little theorems will prove to be useful. To prove these theorems you only need to know about the properties of AND, OR and NOT gates. That is left as an exercise for you.

When we want to prove a theorem we will take the approach that we can prove the theorem by examining all possible combinations of the appropriate variables. We can do that because the possible combinations are finite.

Here is a truth table. It lists all possible combinations for two variables.

AB 0 01 01 1 1 00 1 1 0 1 0 1 0 1 0 0 0 1 0 0 0

This truth table proves the following theorem. Theorem (de Morgan)

Proof The proof of this theorem is contained in the truth table above which lists every possible combination of A and B, and shows that this result is true. One final note. There are some further simple facts that come in useful. Note the following:

and:

Boolean Algebra can be a confusing and misleading business. De Morgan's theorem above seems almost trivial. However, there is a very interesting consequence of this theorem. Here it is:

If you have a Boolean function that is a sum-of-products form it can be implemented using a two layer circuit with the first layer composed of AND gates, and the second layer composed of OR gates. Applying deMorgan's theorem to the function the circuit can be built using the same structure, but replacing every AND and OR gate with a NAND gate.

First, you need to understand how to expand a function in terms of minterms. Click here to go to that lesson. Problems

Problem Logic1P01 - Building a Three-Input AND.

Links to Other Lessons on Digital Logic


o o

Gates Minterms

o o o o o

Karnaugh Maps Flip-Flops Counters Memory Elements Digital Logic Laboratories

Send your comments on these lessons.

A logic gate is an elementary building block of a digital circuit. Most logic gates have two inputs and one output. At any given moment, every terminal is in one of the two binary conditions low (0) or high (1), represented by different voltage levels. The logic state of a terminal can, and generally does, change often, as the circuit processes data. In most logic gates, the low state is approximately zero volts (0 V), while the high state is approximately five volts positive (+5 V). There are seven basic logic gates: AND, OR, XOR, NOT, NAND, NOR, and XNOR.

The AND gate is so named because, if 0 is called "false" and 1 is called "true," the gate acts in the same way as the logical "and" operator. The following illustration and table show the circuit symbol and logic combinations for an AND gate. (In the symbol, the input terminals are at left and the output terminal is at right.) The output is "true" when both inputs are "true." Otherwise, the output is "false."

AND gate

Input 1 Input 2 Output 1 1 1 1 1

The OR gate gets its name from the fact that it behaves after the fashion of the logical inclusive "or." The output is "true" if either or both of the inputs are "true." If both inputs are "false," then the output is "false."

OR gate

Input 1 Input 2 Output 1 1 1 1 1 1 1

The XOR ( exclusive-OR ) gate acts in the same way as the logical "either/or." The output is "true" if either, but not both, of the inputs are "true." The output is "false" if both inputs are "false" or if both inputs are "true." Another way of looking at this circuit is to observe that the output is 1 if the inputs are different, but 0 if the inputs are the same.

XOR gate Input 1 Input 2 Output 1 1 1 1 1 1

A logical inverter , sometimes called a NOT gate to differentiate it from other types of electronic inverter devices, has only one input. It reverses the logic state.

Inverter or NOT gate Input Output

1 1

The NAND gate operates as an AND gate followed by a NOT gate. It acts in the manner of the logical operation "and" followed by negation. The output is "false" if both inputs are "true." Otherwise, the output is "true."

NAND gate Input 1 Input 2 Output 1 1 1 1 1 1 1

The NOR gate is a combination OR gate followed by an inverter. Its output is "true" if both inputs are "false." Otherwise, the output is "false."

NOR gate Input 1 Input 2 Output 1 1 1 1 1

The XNOR (exclusive-NOR) gate is a combination XOR gate followed by an inverter. Its output is "true" if the inputs are the same, and"false" if the inputs are different.

XNOR gate Input 1 Input 2 Output 1 1 1 1 1 1

Using combinations of logic gates, complex operations can be performed. In theory, there is no limit to the number of gates that can be arrayed together in a single device. But in practice, there is a limit to the number of gates that can be packed into a given physical space. Arrays of logic gates are found in digital integrated circuits (ICs). As IC technology advances, the required physical volume for each individual logic gate decreases and digital devices of the same or smaller size become capable of performing ever-more-complicated operations at ever-increasing speeds.

Logic Gate

Logic gates perform basic logical functions and are the fundamental building blocks of digital integrated circuits. Most logic gates take an input of two binary values, and output a single value of a 1 or 0. Some circuits may have only a few logic gates, while others, such as microprocessors, may have millions of them. There are seven different types of logic gates, which are outlined below. In the following examples, each logic gate except the NOT gate has two inputs, A and B, which can either be 1 (True) or 0 (False). The resulting output is a single value of 1 if the result is true, or 0 if the result is false. 1. 2. 3. 4. 5. 6. 7. AND - True if A and B are both True OR - True if either A or B are True NOT - Inverts value: True if input is False; False if input is True XOR - True if either A or B are True, but False if both are True NAND - AND followed by NOT: False only if A and B are both True NOR - OR followed by NOT: True only if A and B are both False XNOR - XOR followed by NOT: True if A and B are both True or both False

By combining thousands or millions of logic gates, it is possible to perform highly complex operations. The maximum number of logic gates on an integrated circuit is determined by the size of the chip divided by the size of the logic gates. Since transistors make up most of the logic gates in computer processors, smaller transistors mean more complex and faster processors.

Logic Gates
Introduction Logic gates serve as the building blocks to digital logic circuits using combinational logic. We're going to consider the following gates: NOT gates (also called inverters), AND gates, OR gates, NAND gates, NOR gates, XOR gates, and XNOR gates.

We'll also discuss the concept of gate deltay.


NOT gates NOT gates or inverters have a single bit input and a single bit of output.

This is a diagram of a NOT gate. It is a triangle with a circle on the right. The circle indicates "negation".

The truth table defines the behavior of this gate.


x 0 1 z 1 0

where x is the input and z is the output.


AND2 gates AND2 gates have two bits of input and a single bit of output. The subscript, 2, indicates how many inputs this AND gate has. For example, AND3 gates have 3 inputs.

The output of AND2 gate is 1 only if both inputs are 1. Otherwise, the output is 0.

The truth table defines the behavior of this gate.

x1 0 0 1 1

x0 0 1 0 1

z 0 0 0 1

The function implmented by AND2 gates has interesting properties:


The function is symmetric. Thus, x * y == y * x. This can be verified by using truth tables. We use * to represent AND2. The function is associative. Thus, (x * y) * z == x * (y * z). This can be verified by using truth tables.

Because of these properties, it's easy to define ANDn, which is an n-input AND gate.

ANDn(x1, x2,...,xn) = x1 * x2 * ... * xn


That is, an AND gate with n-inputs is the AND of all the bits. This is not ambiguous because the AND function is associative (all parenthesization of this expression are equivalent).
OR2 gates OR2 gates have two bits of input and a single bit of output. The subscript, 2, indicates how many inputs this OR gate has. For example, OR3 gates have 3 inputs.

The output of OR2 gate is 0 only if both inputs are 0. Otherwise, the output is 1.

The truth table defines the behavior of this gate.


x1 0 0 x0 0 1 z 0 1

1 1

0 1

1 1

The function implemented by OR2 gates has interesting properties:


The function is symmetric. Thus, x + y == y + x. This can be verified by using truth tables. We use "+" to represent OR2 The function is associative. Thus, (x + y) + z == x + (y + z). This can be verified by using truth tables.

Because of these properties, it's easy to define ORn, which is an n-input OR gate.

ORn(x1, x2,...,xn) = x1 + x2 + ... + xn


That is, an AND gate with n-inputs is the AND of all the bits. This is not ambiguous because the AND function is associative (all parenthesization of this expression are equivalent).
NAND2 gates NAND2 gates have two bits of input and a single bit of output. The subscript, 2, indicates how many inputs this NAND gate has. For example, NAND3 gates have 3 inputs.

NANDk gates is define unusually. Since NAND2 is not associative, the definition is based on AND2. In particular

NANDk(x1, x2,...,xn) = NOT( ANDk(x1, x2,...,xn) )

Thus, NANDk is the negation of ANDk. The truth table defines the behavior of this gate. It's the negation of AND2.
x1 0 0 x0 0 1 z 1 1

1 1

0 1

1 0

The function implemented by NAND2 gates has interesting properties:


The function is symmetric. Thus, x NAND y == y NAND x. This can be verified by using truth tables. The function is not associative. This can be verified by using truth tables.

Because of these properties, NANDk is defined from ANDk, and not built from NAND2 gates. NOR2 gates OR2 gates have two bits of input and a single bit of output. The subscript, 2, indicates how many inputs this OR gate has. For example, NOR3 gates have 3 inputs.

The output of NOR2 gate is the negation of OR2.

The truth table defines the behavior of this gate.


x1 0 0 1 1 x0 0 1 0 1 z 1 0 0 0

The function implmented by NOR2 gates has interesting properties:


The function is symmetric. Thus, x NOR y == y NOR x. This can be verified by using truth tables. The function is not associative. This can be verified by using truth tables.

Because of these properties, NORk is defined from ORk, and not built from NOR2 gates.

XOR2 gates XOR2 gates have two bits of input and a single bit of output.

The output of XOR2 gate is 1 only if the inputs have opposite values. That is, when one input has value 0, and the other has value 1.. Otherwise, the output is 0. This is called exclusive-or. The definition of OR2 is inclusive-or, where the output is 1 if either input is 1, or if both inputs are 1. XOR2 can be defined using AND2, OR2, and NOT.

x XOR y == ( x AND (NOT y) ) OR ( (NOT x) AND y ) == x\y + y\x


Here's a diagram of the XOR2 gate.

If you look carefully at the drawing of the gate, there is a second arc behind the first one near the inputs. Since this second arc is hard to see, it's usually a good idea to write the word "XOR" inside the gate. The truth table defines the behavior of this gate.
x1 0 0 1 1 x0 0 1 0 1 z 0 1 1 0

The function implmented by XOR2 gates has interesting properties:

The function is symmetric. Thus, x (+) y == y (+) x. This can be verified by using truth tables. (We use (+) to denote logical XOR--ideally, we'd draw it with a + sign inside a circle, but HTML doesn't seem to have a symbol for this).

The function is associative. Thus, [ x (+) y ] (+) z == x (+) [ y (+) z ]. This can be verified by using truth tables.

Because of these properties, it's easy to define XORn, which is an n-input XOR gate.

XORn(x1, x2,...,xn) = x1 (+) x2 (+) ... (+) xn


That is, an XOR gate with n-inputs is the XOR of all the bits. This is not ambiguous because the XOR function is associative (all parenthesization of this expression are equivalent).
XNOR2 gates XNOR2 gates have two bits of input and a single bit of output.

The output of XNOR2 gate is the negation of XOR2 and has 1 when both inputs are the same.

If you look carefully at the drawing of the gate, there is a second arc behind the first one near the inputs. Since this second arc is hard to see, it's usually a good idea to write the word "XNOR" inside the gate. The truth table defines the behavior of this gate.
x1 0 0 1 1 x0 0 1 0 1 z 0 1 1 0

The function implmented by XNOR2 gates has interesting properties:


The function is symmetric. Thus, x XNOR y == y XNOR x. This can be verified by using truth tables. The function is associative. Thus, (x XNOR y) XNOR z == x XNOR (y XNOR z). This can be verified by using truth tables.

Because of these properties, it's easy to define XNORn, which is an n-input XNOR gate.

XNORn(x1, x2,...,xn) = x1 XNOR x2 XNOR ... XNOR xn


That is, an XNOR gate with n-inputs is the XNOR of all the bits. This is not ambiguous because the XNOR function is associative (all parenthesization of this expression are equivalent). (Error-checkers! You may wish to verify this, and email me if this is incorrect!).
Building Blocks We can use logic gates to build circuits. While we've described 6 gates, you can do with only three gates to build all possible circuits: AND2, OR2, and NOT. In fact, you don't even need all three gates. It can be done in two kinds of gates of less. We'll explain in a future section.

These circuits can implement any truth table.


Valid Combinational Circuits The inverse is not true. Not every circuit that is built from gates corresponds to a truth table. In particular, you must observe the following rules if it's to correspond to a truth table.

The output of a gate may only be attached to the input of another gate. (Think of this as a directed edge from output to input). There must be no cycles in the circuit. Treat the circuit like a directed graph with directed edges defined in the previous item. Although the output of a gate may be attached to more than one input, an input may not have two different outputs attached to it (this would create conflicting input signals). Each input of a gate must come from either the output of another gate or a source. A source is a source that generates either a 0 or 1.

Gate Delay Real gates have delay. In other words, if you change the value of the inputs, say from 0 and 0 to 0 and 1, then the output takes some small amount of time before it changes. This delay is called gate delay.

This delay is due to the fact that information can travel at most, the speed of light, and in reality, the time it takes to do the computation is not infinitely quick. This delay limits how fast the inputs can change and yet the output have meaningful values. It also allows certain kinds of circuits to be created that don't follow the rules from the previous section. In particular, flip flops (to be discussed later) can be generated from gates that use cycles.
Why Subscripts? Most books don't distinguish between an AND2 gate and a AND3 gate. They claim an AND gate is an AND gate, regardless of the number of inputs.

While this is true, I subscript it because an AND2 and an AND3 do not have the same truth table. In particular, an AND2 truth table has 4 rows while an AND3 has 8. While the two truth tables are related, they still define different functions. Thus, I make the distinction by subscripting the number of inputs.
Summary Logic gates are the building blocks of combinational logic circuits. You can buy logic gates from electronic hobby places. These gates are primarily for hobbyists. Each chip usually has about 4 logic gates.

Real computers don't use these kinds of gates, because they take far too much space. With VLSI technology, you can cram millions of gates onto a wafer no bigger that your thumbnail. The behavior of logic gates can be described by truth tables. However, because these gates are "physical", they have some properties not expressed in truth tables. In particular, gate delay describes the amount of time it takes for the output to change when the input changes. This time is not zero, thus, one must wait a short amount of time for the output to take effect. We'll discuss how to build circuits from these gates in a later set of notes.

Você também pode gostar