Skip to content

Electronics · Ch 10 — Digital Electronics

Logic gates

10.1

Logic gates

A logic gate is an electronic circuit that operates on the rules of Boolean algebra to carry out one particular logic function; gates are the basic elements from which every digital system is assembled. Each gate accepts one or more binary inputs and produces a single binary output that depends only on the present combination of inputs, which is captured in its truth table.

The textbook lists seven types of gate: the three basic gates AND, OR, NOT; the two universal gates NAND and NOR; and the two combinational gates exclusive-OR (XOR) and exclusive-NOR (XNOR). This section studies XOR, XNOR, NAND and NOR in detail — their symbols, Boolean expressions, truth tables, IC pin diagrams, timing diagrams and gate realizations.

Exclusive-OR (XOR) gate

The XOR gate gives a HIGH output only when an odd number of its inputs are HIGH. For two inputs this means the output is 1 whenever the inputs are different, which is why it is also called an inequality detector. Its Boolean expression is Y=A⊕B=A‾B+AB‾Y = A \oplus B = \overline{A}B + A\overline{B}, read as "Y equals A XOR B". XOR gates are available as ICs — IC 7486 contains four independent 2-input XOR gates (figure 10.1.2). XOR gates are widely used in magnitude comparators, gray-code converters, adders and subtractors, odd-parity checkers and modulo-2 adders. The XOR waveform behaviour is shown in the timing diagram (figure 10.1.3), and figure 10.1.4 shows how an XOR is realized from two NOT, two AND and one OR gate.

Exclusive-NOR (XNOR) gate

The XNOR gate is the complement of the XOR gate: its output is HIGH only when both inputs are the same, so it is also called a coincidence gate. It behaves like an XOR gate followed by an inverter. Its expression is Y=A⊕B‾=A‾ B‾+ABY = \overline{A \oplus B} = \overline{A}\,\overline{B} + AB. IC 74266 contains four 2-input XNOR gates (figure 10.1.6). The XNOR gate is used in comparators and even-parity checkers. Its timing diagram is figure 10.1.7, and figure 10.1.8 shows its realization using two NOT, two AND and one OR gate.

NAND gate — a universal gate

The NAND gate (NOT-AND) gives a LOW output only when all inputs are HIGH; equivalently, its output is HIGH when any one input is LOW. Its expression is Y=AB‾Y = \overline{AB}. IC 7400 is a quad 2-input NAND (figure 10.1.9), and figure 10.1.10 shows the symbol (an AND shape with an output bubble, equivalent to an AND gate followed by an inverter).

NAND is called a universal gate because every other gate can be built from NAND gates alone: the NOT function by tying both inputs together (figure 10.1.12, Y=AA‾=A‾Y = \overline{AA} = \overline{A}); the AND function using two NANDs (figure 10.1.13, Y=AB‾‾=ABY = \overline{\overline{AB}} = AB); the OR function using three NANDs (figure 10.1.14); and even the XOR function using four NANDs (figure 10.1.15).

Note

The official KTBS corrigendum corrects the printed label of figure 10.1.14 (OR using NAND) from Y=A‾+B‾Y = \overline{A} + \overline{B} to Y=A‾⋅B‾Y = \overline{A}\cdot\overline{B}. The correct working is that feeding A‾\overline{A} and B‾\overline{B} into a NAND gives Y=A‾⋅B‾‾=A+BY = \overline{\overline{A}\cdot\overline{B}} = A + B by De Morgan's theorem — an OR gate.

NOR gate — a universal gate …

Definition 1Logic gate

An electronic circuit that works on the rules of Boolean algebra to perform one particular logic function. Logic gates are the basic elements of every digital system; each has one or more binary inputs and a single binary output. The seven types are the basic gates (AND, OR, NOT), the universal gate …

Figure 2Logic symbol of a two-input exclusive-OR (XOR) gate with inputs A and B and a single output Y.
Fig. 2 — Logic symbol of a two-input exclusive-OR (XOR) gate with inputs A and B and a single output Y.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

The standard XOR symbol (figure 10.1.1): an OR-gate curved shape with an extra curved line across the two inputs A (top) and B (bottom); the single output Y carries no inversion bubble. Read with its truth table, Y=1Y=1 only when A and B differ, …

Formula 3XOR Boolean expression

Y=A⊕B=A‾B+AB‾Y = A \oplus B = \overline{A}B + A\overline{B} — output HIGH only when the two inputs differ (an odd number of HIGH inputs). Here ⊕\oplus is the XOR operator and the overbar is complement; the term A‾B\overline{A}B covers A=0,B=1 and AB‾A\overline{B} covers A=1,B=0. U …

Table 4Truth table of the XOR gate
ABY = A ⊕ B
000
011
Figure 5Pin diagram of IC 7486, a 14-pin DIP containing four 2-input XOR gates.
Fig. 5 — Pin diagram of IC 7486, a 14-pin DIP containing four 2-input XOR gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.2: 14-pin DIP labelled IC 7486 with a notch on the left. Pin 14 = +5V, pin 7 = GND. The four XOR gates are wired inputs 1,2 → output 3; inputs 4,5 → output 6; inputs 9,10 → ou …

Figure 6Timing diagram of the XOR gate showing inputs A, B and output Y over four input combinations.
Fig. 6 — Timing diagram of the XOR gate showing inputs A, B and output Y over four input combinations.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.3: three stacked waveforms A, B, Y. A = 0,0,1,1; B = 0,1,0,1; Y = 0,1,1,0 — matching the XOR truth table. Reading the pattern: Y follows A XOR B in each column — HIGH only where A and B differ (columns 2 and 3), LOW where they match (columns 1 a …

Figure 7Realization of the XOR gate from two NOT, two AND and one OR gate.
Fig. 7 — Realization of the XOR gate from two NOT, two AND and one OR gate.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.4: A and B each feed an inverter to give A‾\overline{A} and B‾\overline{B}; an upper AND forms A‾B\overline{A}B, a lower AND forms AB‾A\overline{B}; a final OR gives $Y …

Figure 8Logic symbol of a two-input exclusive-NOR (XNOR) gate with inputs A, B and output Y.
Fig. 8 — Logic symbol of a two-input exclusive-NOR (XNOR) gate with inputs A, B and output Y.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.5: the XOR shape with a small inversion bubble on the output; inputs A (top) and B (bottom), output Y. The output bubble marks inversion of the XOR result, so this XNOR gives Y=1Y=1 only when A and B are equal (a coincidence gate) — …

Formula 9XNOR Boolean expression

Y=A⊕B‾=A‾ B‾+ABY = \overline{A \oplus B} = \overline{A}\,\overline{B} + AB — output HIGH only when both inputs are the same (a coincidence gate). The overbar on A⊕BA\oplus B inverts the XOR, so Y=1Y=1 only when the inputs match: A‾ B‾\overline{A}\,\overline{B} covers 0,0 and ABAB covers …

Table 10Truth table of the XNOR gate
ABY = ̅(A ⊕ B)
001
010
Figure 11Pin diagram of IC 74266, a 14-pin DIP containing four 2-input XNOR gates.
Fig. 11 — Pin diagram of IC 74266, a 14-pin DIP containing four 2-input XNOR gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.6: 14-pin DIP labelled 74266 with a left notch. Pin 14 = Vcc, pin 7 = GND; four 2-input XNOR gates drawn inside. What to notice: like every quad DIP it packs four independent 2-input gates powered from the single VccV_{cc}/GND pair, so one IC supplies four X …

Figure 12Timing diagram of the XNOR gate showing inputs A, B and output Y.
Fig. 12 — Timing diagram of the XNOR gate showing inputs A, B and output Y.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.7: waveforms A = 0,0,1,1; B = 0,1,0,1; Y = 1,0,0,1 — matching the XNOR truth table. Reading the pattern: Y is HIGH wherever A and B agree (columns 1 and 4: 0,0 and 1,1) and LOW wherever they differ (columns 2 and 3), the exact complement of the XOR wave …

Figure 13Realization of the XNOR gate from two NOT, two AND and one OR gate.
Fig. 13 — Realization of the XNOR gate from two NOT, two AND and one OR gate.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.8: A and B each feed an inverter; an upper AND forms A‾ B‾\overline{A}\,\overline{B}, a lower AND forms ABAB; a final OR gives Y=A‾ B‾+ABY = \overline{A}\,\overline{B} + AB. Notice this is the XOR realization with the two AND terms swapped: it collects the matching cases A‾ B‾\overline{A}\,\overline{B} and ABAB …

Definition 14NAND gate (universal gate)

A NOT-AND gate whose output is LOW only when all inputs are HIGH, i.e. HIGH when any one input is LOW; Y=AB‾Y = \overline{AB}. It is called a universal gate because NOT, AND, OR and XOR can all be built from NAND gates …

Figure 15Pin diagram of IC 7400, a 14-pin DIP containing four 2-input NAND gates.
Fig. 15 — Pin diagram of IC 7400, a 14-pin DIP containing four 2-input NAND gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.9: 14-pin DIP labelled IC 7400, pin 14 = Vcc, pin 7 = GND; NAND gates wired inputs 1,2 → 3; 4,5 → 6; 9,10 → 8; 12,13 → 11. What to notice: the four NAND gates share one VccV_{cc}/GND pair; because NAND is a universal gate, this single IC can be wired to …

Figure 16Logic symbol of the NAND gate, shown as an AND gate followed by an inverter and as a single NAND symbol.
Fig. 16 — Logic symbol of the NAND gate, shown as an AND gate followed by an inverter and as a single NAND symbol.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.10: (top) an AND gate followed by an inverter; (bottom) a single AND shape with an output bubble. Inputs A, B, output Y=AB‾Y = \overline{AB}. The bubble on the output is the key detail: it inverts the AND result, giving Y=AB‾Y=\overline{AB} — LOW only when both inputs are HIGH, HIGH otherwise.

[!NOTE] The textbook's printed label for this figure (and the matching truth-table header) writes the NAND output with two separate bars, Aˉ Bˉ\bar{A}\,\bar{B}, which reads as Aˉ⋅Bˉ\bar{A}\cdot\bar{B} — that contradicts the book's own NAND truth table (output 1,1,1,0). The correct NAND output, used here and consistent with that truth table, is …

Formula 17NAND Boolean expression

Y=AB‾Y = \overline{AB} — output HIGH when any input is LOW; LOW only when all inputs are HIGH. The overbar covers the whole product ABAB, so the AND is formed first and then inverted. The output is LOW only for A=B=1 and HIGH for every other combination; NAND is a univer …

Table 18Truth table of the NAND gate
ABY = ̅(AB)
001
011
Figure 19Timing diagram of the NAND gate showing inputs A, B and output Y.
Fig. 19 — Timing diagram of the NAND gate showing inputs A, B and output Y.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.11: waveforms A = 0,0,1,1; B = 0,1,0,1; Y = 1,1,1,0 — matching the NAND truth table. Reading the pattern: Y stays HIGH for the first three columns (where at least one input is LOW) and drops LOW only in the last column, where both A and B are H …

Figure 20NOT function realized from a single NAND gate with its inputs tied together.
Fig. 20 — NOT function realized from a single NAND gate with its inputs tied together.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.12: a 2-input NAND with both inputs tied to a common input A gives Y=AA‾=A‾Y = \overline{AA} = \overline{A} — an inverter. What to notice: tying both NAND inputs to A makes the product A⋅A=AA\cdot A=A, and the NAND then inverts it, so a universal NAN …

Figure 21AND function realized using two NAND gates.
Fig. 21 — AND function realized using two NAND gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.13: a NAND of A and B followed by a NAND wired as an inverter gives Y=AB‾‾=ABY = \overline{\overline{AB}} = AB. What to notice: the first NAND gives AB‾\overline{AB} and the second, wired as an inverter, cancels the bar to recover the true AND ABAB — two u …

Figure 22OR function realized using three NAND gates.
Fig. 22 — OR function realized using three NAND gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.14: A and B each pass through a NAND-inverter to give A‾\overline{A} and B‾\overline{B}; these feed a third NAND giving Y=A‾⋅B‾‾=A+BY = \overline{\overline{A}\cdot\overline{B}} = A + B by De Morgan's theorem. (The printed figure label is corrected per the official …

Figure 23XOR function realized using four 2-input NAND gates.
Fig. 23 — XOR function realized using four 2-input NAND gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.15: a central NAND of A and B feeds two intermediate NANDs (with A and with B), whose outputs feed a final NAND giving Y=A⊕BY = A \oplus B. What to notice: four universal NAND gates alone reproduce the XOR function Y=A⊕BY=A\oplus B, HIGH only when A and B differ — proof …

Definition 24NOR gate (universal gate)

A NOT-OR gate whose output is HIGH only when all inputs are LOW; the complement of the OR gate, Y=A+B‾Y = \overline{A + B}. It is a universal gate because NOT, OR, AND and XNOR can all be built from NOR gates …

Figure 25Logic symbol of the two-input NOR gate with inputs A, B and output Y.
Fig. 25 — Logic symbol of the two-input NOR gate with inputs A, B and output Y.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.16: an OR-gate curved shape with a small inversion bubble on the output; inputs A, B, output Y=A+B‾Y = \overline{A + B}. The bubble on the output inverts the OR result, giving Y=A+B‾Y=\overline{A+B} — HIGH only when both A and B are LOW; …

Formula 26NOR Boolean expression

Y=A+B‾Y = \overline{A + B} — output HIGH only when all inputs are LOW. The overbar covers the whole sum A+BA+B, so the OR is taken first and then inverted. The output is HIGH only when every input is LOW and LOW if any input is HIGH; NOR is a universal gate fro …

Table 27Truth table of the NOR gate
ABY = ̅(A+B)
001
010
Figure 28Pin diagram of IC 7402, a 14-pin DIP containing four 2-input NOR gates.
Fig. 28 — Pin diagram of IC 7402, a 14-pin DIP containing four 2-input NOR gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.17: 14-pin DIP labelled 7402, pin 14 = Vcc, pin 7 = GND; four 2-input NOR gates drawn inside. What to notice: the four NOR gates share the single VccV_{cc}/GND pair, and because NOR is a universal gate this one IC can be wired to reali …

Figure 29Timing diagram of the NOR gate showing inputs A, B and output Y.
Fig. 29 — Timing diagram of the NOR gate showing inputs A, B and output Y.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.18: waveforms A = 0,0,1,1; B = 0,1,0,1; Y = 1,0,0,0 — matching the NOR truth table. Reading the pattern: Y is HIGH only in the first column, where both A and B are LOW, and stays LOW for the other three columns where at least one input is H …

Figure 30NOT function realized from a single NOR gate with its inputs tied together.
Fig. 30 — NOT function realized from a single NOR gate with its inputs tied together.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.19: a 2-input NOR with both inputs tied to a common input A gives Y=A+A‾=A‾Y = \overline{A + A} = \overline{A}. What to notice: tying both NOR inputs to A makes the sum A+A=AA+A=A, which the NOR then inverts, so a single uni …

Figure 31OR function realized using two NOR gates.
Fig. 31 — OR function realized using two NOR gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.20: a NOR of A and B followed by a NOR wired as an inverter gives Y=A+B‾‾=A+BY = \overline{\overline{A + B}} = A + B. What to notice: the first NOR gives A+B‾\overline{A+B} and the second, wired as an inverter, removes the bar to recover the true OR A+BA+B — tw …

Figure 32AND function realized using three NOR gates.
Fig. 32 — AND function realized using three NOR gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.21: A and B each pass through a NOR-inverter to give A‾\overline{A} and B‾\overline{B}; these feed a third NOR giving $Y = \overline{\overline{A} + \overline{B} …

Figure 33XNOR function realized using four 2-input NOR gates.
Fig. 33 — XNOR function realized using four 2-input NOR gates.

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.

Figure 10.1.22: a first NOR of A and B feeds two intermediate NORs (with A and with B), whose outputs feed a final NOR giving Y=A‾ B‾+ABY = \overline{A}\,\overline{B} + AB. What to notice: four universal NOR gates alone reproduce the XNOR function, HIGH only when A and B are equal — …