Resources | Subject Notes | Computer Science
Logic gates are fundamental building blocks of digital circuits. They perform basic logical operations on one or more binary inputs (0 or 1) to produce a single binary output (0 or 1). These gates are essential for creating more complex digital systems, such as adders, decoders, and microprocessors.
Here's a detailed explanation of the common logic gates:
The NOT gate, also known as the inverter, performs the logical inverse of its input. If the input is 0, the output is 1, and vice versa.
Input (A) | Output (Q) |
---|---|
0 | 1 |
1 | 0 |
The AND gate produces a 1 output only if both of its inputs are 1. If either or both inputs are 0, the output is 0.
Input A | Input B | Output (Q) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
The OR gate produces a 1 output if at least one of its inputs is 1. The output is 0 only if both inputs are 0.
Input A | Input B | Output (Q) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
The NAND gate is the inverse of the AND gate. It produces a 0 output only if both of its inputs are 1. Otherwise, the output is 1.
Input A | Input B | Output (Q) |
---|---|---|
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
The NOR gate is the inverse of the OR gate. It produces a 1 output only if both of its inputs are 0. Otherwise, the output is 0.
Input A | Input B | Output (Q) |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
The XOR (exclusive OR) gate produces a 1 output if its inputs are different (one is 0 and the other is 1). It produces a 0 output if its inputs are the same (both 0 or both 1).
Input A | Input B | Output (Q) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Logic gates are combined to create more complex logic circuits. Here are some examples:
A half adder is a combinational circuit that adds two single-bit binary numbers. It has two inputs (A and B) and two outputs (Sum and Carry).
The Boolean equations for a half adder are:
$$ \begin{aligned} \text{Sum} &= A \oplus B \\ \text{Carry} &= A \land B \end{aligned} $$A full adder is a combinational circuit that adds three single-bit binary numbers: two inputs (A and B) and a carry-in (Cin). It has two outputs: a sum (Sum) and a carry-out (Cout).
The Boolean equations for a full adder are:
$$ \begin{aligned} \text{Sum} &= A \oplus B \oplus Cin \\ \text{Carry} &= (A \land B) \lor (A \land Cin) \lor (B \land Cin) \end{aligned} $$Truth tables are used to define the behavior of logic gates and circuits. They list all possible combinations of input values and the corresponding output values.
Logic gates and circuits are used in a wide variety of applications, including: