In this explainer, we will learn how to determine the input and output of AND gates in logic circuits and complete truth tables for AND gates.
A logic gate is a device that takes one or more binary inputs and has one binary output. Such binary signals have two possible values: 0 and 1. Each type of logic gate determines one output value, depending on the input.
Besides the numeric assignment 0 or 1, there are other terms we can use to express these binary values, such as “false” or “true” and “off” or “on.” Here, “false,” “off,” and 0 all are equivalent, as are “true,” “on,” and 1. The names used for these binary values carry no extra meaning other than perhaps hinting at the context that the logic gate is working by. One of the most common uses for logic gates is in digital devices, where “on” or “off” can refer to whether a current is present in an electrical element. Logic gates are commonly used in electronics such as smartphones, where they are combined by the millions or billions to perform calculations. We will learn how AND gates can be combined later in this explainer; for now, let us explore how an individual AND gate works.
The diagram above shows the symbol for an AND gate. Here, the input is shown on the left side and the output is on the right side, which is made evident by the direction that the curved shape “points.” The AND gate takes two input values that are represented by the double lines leading into the “D”-shaped symbol. The “D”-shaped symbol shows the direction that information moves through the gate: two inputs (left) become one output (right). It is also useful to remember that the “D”-shaped symbol can represent the last letter in the word “AND,” which sets it apart from other gate symbols.
Because there are two possible input values for two different input channels, there are four possible input combinations for an AND gate. These input combinations and their respective outputs are shown below. We will use color to code the binary values with red representing 0 and blue representing 1. Note that the dotted line extensions are used to show that the lines continue in either direction and that the four gates are separate from one another.
Notice that only one combination of input values gives an output value of 1. This particular case can help explain why this kind of logic gate is called an AND gate—the gate only outputs a 1 when both inputs A and B are set to 1. All other input combinations result in an output value of 0.
We can more formally represent the possible values of an AND gate by using a truth table, which represents each input and output channel as a column. To distinguish between the two input channels, we will call them “A” and “B.” There are four rows in the table corresponding to the four possible combinations of inputs. The truth table for an AND gate is shown below.
Input A | Input B | Output |
---|---|---|
The truth table reiterates the functionality of an AND gate, which is worth stating formally:
Rule: AND Gates
An AND gate is a logic gate with two binary inputs and one binary output. In order for an AND gate to output a value of 1, both input A and input B must be set to 1.
Let us practice using AND gates with some examples.
Example 1: Evaluating the Output of AND Gates
The diagram shows an AND gate. If input A is 1 and input B is 1, what will the output be?
Answer
Recall that an AND gate only outputs a value of 1 if both inputs A and B are set to 1 and that any other combination of input values results in an output of 0.
Here, both inputs are set to 1, so the gate will output a value of 1.
Next, we will examine the output of an AND gate to determine its input.
Example 2: Evaluating the Input of AND Gates
The diagram shows an AND gate. If input A is 1 and the output is 0, what must input B be?
Answer
Recall that an AND gate will only output a value of 1 when both input A and input B are set to 1. All other input combinations result in an output value of 0. The output of this AND gate is 0, so we know that it cannot be the case that both input values are 1. Since input A is 1, we know that input B cannot also be 1.
Therefore, input B must be 0.
We have previously mentioned that AND gates (as well as other types of logic gates) are commonly combined in electronic circuits. Let us now consider the effects of combining AND gates. In this case, each individual gate acts as we have learned, and we must be careful to keep track of the values since the outputs of some gates will be passed along as inputs to subsequent gates.
Example 3: Evaluating the Output of Multiple AND Gates Using Truth Tables
The diagram shows two AND gates connected as part of a logic circuit. The truth table shows the output for the various combinations of the inputs.
Input A | Input B | Input C | Output |
---|---|---|---|
0 | 0 | 0 | 0 |
0 | 0 | 1 | |
0 | 1 | 0 | 0 |
1 | 1 | 0 | |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | |
1 | 1 | 1 |
- What is the value of in the table?
- What is the value of in the table?
- What is the value of in the table?
- What is the value of in the table?
Answer
Part 1
Here, we have two AND gates combined in a circuit. There are three different input channels to consider, so the truth table for this setup is much larger than that for a single AND gate. We will work through a single row in the table at a time so that we can complete the entries , , , and . Let us refer to the AND gate with inputs A and B as the “first” AND gate. The output of this gate, along with input C, lead into what we will call the “second” AND gate, as labeled in the diagram below.
Let us begin with , which appears in the second row of the table.
Input A | Input B | Input C | Output |
---|---|---|---|
0 | 0 | 1 |
In this row of the table, inputs A and B, which belong to the same gate, are both set to 0. We know that an AND gate only returns a 1 when both of its input values are 1, so the first AND gate will output a 0. This 0 is then passed as an input to the second gate, as well as input C. The inputs for the second gate are 0 and 1.
Thus the final output, , is 0.
Part 2
Now let us consider , which appears as input A in another row of the table.
Input A | Input B | Input C | Output |
---|---|---|---|
1 | 1 | 0 |
This time, we already know what the final output of the second gate is, so we will work backward to determine what input A must be. The output of the second gate is 0, so we know that the inputs for the second gate cannot both be 1. The table tells us that input C is 1, so the other input (which is the output of the first gate) must be 0. Because the output of the first gate is 0, we know that inputs A and B must not both be 1. The table tells us that input B is 1.
Therefore, input A, or , must be set to 0.
Part 3
We will now move on to , which appears in the table as the output of the second gate.
Input A | Input B | Input C | Output |
---|---|---|---|
1 | 1 | 0 |
Let us first consider the output of the first gate: inputs A and B are both 1, so the first gate will output a 1. This value is passed as one input to the second gate, along with the value 0 (as told by the table). The inputs of the second gate are 1 and 0.
Therefore, the second gate will output a value so that is 0.
Part 4
Finally, let us consider , which appears as input A in another row of the table.
Input A | Input B | Input C | Output |
---|---|---|---|
1 | 1 | 1 |
We will work our way backward to determine input A, similar to how we found the value of . The output of the second gate is 1 here, so we know that both of its inputs must be 1. Therefore, the first gate must output a value of 1, meaning that both inputs A and B must also be 1.
Thus, we have found that has a value of 1.
We will now look at some more examples of combining AND gates, but instead of using gates with predefined input and output values, these examples are more conceptual.
Example 4: Evaluating the Inputs of Multiple AND Gates
The diagram shows a logic circuit consisting of three AND gates. How many of the inputs must have a value of 1 in order for the output to have a value of 1?
Answer
Recall that an AND gate only outputs a value of 1 if both of its inputs are 1.
We want the final gate to return a 1, so both of its inputs must be 1. Thus, both of the gates on the left must output a 1, so they need to have only inputs of 1.
Therefore, all four of the inputs must be 1 for the system to output a 1.
The example above shows a useful result that is important enough to state formally.
Rule: Circuit of AND Gates to Output 1
For any circuit that is composed exclusively of AND gates, in order for the final output to be 1, all of the inputs must be 1.
Example 5: Evaluating the Inputs of Multiple AND Gates
The diagram shows a logic circuit consisting of three AND gates. How many of the inputs must have a value of 0 in order for the output to have a value of 0?
Answer
We want to find the minimum number of inputs that must have the value 0 in order for the final output of the system to also be 0.
Before we introduce any 0-valued inputs, let us start by considering if all four inputs are 1. In this case, the final output is 1, as shown in the diagram below.
Let us now change only one input from a 1 to a 0 so that we have three 1 inputs and one 0 input.
As shown above, input A is set to 0. The top left gate now returns a 0, since only a gate with both inputs set to 1 will output a 1. Inputs C and D are both 1, so the bottom left gate outputs a 1. The inputs to the final gate on the right-hand side are now 0 and 1, so the output of this gate will be 0, as shown above.
Notice that it does not matter which of the four inputs is set to 0. If any input of this system is 0, the final output of the whole system will be 0.
Therefore, at least one input must be 0 so that the final output is 0.
Example 6: Evaluating the Output of Multiple AND Gates
Each of the diagrams shows a logic circuit consisting only of AND gates. Which of the diagrams shows circuits where the output has a value of 1?
Answer
Recall that an AND gate only outputs a 1 when both of its input values are 1. Thus, for any circuit made exclusively of AND gates, in order for the final output to be 1, all of the inputs must be 1. Therefore, we can look at each of these combinations of gates and know that if there are any 0 inputs, the final output will be 0.
Beginning with option A, we see that the bottom left gate has inputs 0 and 1, as shown below. Therefore, A is not the correct answer.
Moving on to B, we see that both of the gates on the left have an input of 0, as shown below. Therefore, B is incorrect.
In option C the bottom gate on the left has a 0 input, as shown below. Therefore, the final output is 0 and C is not correct.
We are left with option D, which only has inputs of 1, so the final output of the system is 1, as illustrated below.
Therefore, D is the correct choice.
Let us finish by summarizing some important concepts.
Key Points
- An AND gate is a type of logic gate with two binary inputs and one binary output.
- The symbol representation for an AND gate is
- An AND gate only outputs a value of 1 when both input A and input B are set to 1.
- We can draw a truth table for one or more AND gates to formally represent the possible combinations of input and output values.
- For any circuit that is composed exclusively of AND gates, in order for the final output to be 1, all of the inputs must be 1.