Logic Gates

Where this sits in GATE

Logic gates are the building blocks of Digital Logic, Section 2 of the GATE 2027 CS syllabus, and of Digital Circuits in the GATE 2027 EC syllabus. In the Studyloaf tracker's GATE CS pack, tick them off under Digital Logic.

The seven gates

Truth tables for two inputs A and B (NOT takes A only)
ABAND ABABOR A+BA+BNAND AB‾\overline{AB}NOR A+B‾\overline{A+B}XOR A⊕BA\oplus BXNOR A⊕B‾\overline{A\oplus B}
00001101
01011010
10011010
11110001

NOT simply flips its input: 0‾=1\overline{0} = 1 and 1‾=0\overline{1} = 0. XOR outputs 1 when the inputs differ; XNOR outputs 1 when they match.

NAND and NOR are universal

Every Boolean function can be built from NAND gates alone (and, separately, from NOR gates alone). With NAND:

  • NOT: tie both inputs together, A⋅A‾=A‾\overline{A \cdot A} = \overline{A}.
  • AND: a NAND followed by a NAND used as NOT, AB‾‾=AB\overline{\overline{AB}} = AB.
  • OR: invert each input first, then NAND: A‾⋅B‾‾=A+B\overline{\overline{A}\cdot\overline{B}} = A + B by De Morgan's theorem.
  • XOR: four NAND gates. With N=AB‾N = \overline{AB}, the output is AN‾⋅BN‾‾=A⊕B\overline{\overline{A N}\cdot\overline{B N}} = A \oplus B, which checks out on all four input rows.

Worked example: a half adder

A half adder adds two bits AA and BB, giving a sum bit SS and a carry bit CC. From the table of binary sums (0 + 0 = 00, 0 + 1 = 01, 1 + 0 = 01, 1 + 1 = 10):

S=A⊕B,C=ABS = A \oplus B, \qquad C = AB

So one XOR gate and one AND gate are enough. Check the last row: 1⊕1=01 \oplus 1 = 0 and 1⋅1=11 \cdot 1 = 1, giving binary 10, which is 2.

Worked example: tracing a circuit

Inputs AA and BB feed a NAND gate, and its output and a third input CC feed a NOR gate. When is the final output YY equal to 1?

Solution: Y=AB‾+C‾Y = \overline{\overline{AB} + C}. A NOR outputs 1 only when both its inputs are 0, so we need AB‾=0\overline{AB} = 0 (that is, A=B=1A = B = 1) and C=0C = 0. Of the 8 input combinations, only A=1,B=1,C=0A = 1, B = 1, C = 0 gives Y=1Y = 1, so Y=ABC‾Y = AB\overline{C}.

Worked example: how many functions?

How many different Boolean functions of 2 inputs are there? A 2-input truth table has 22=42^2 = 4 rows, and each row's output can be 0 or 1 independently, so there are 24=162^4 = 16 functions. With nn inputs there are 22n2^{2^n}: 4 for one input, 16 for two, 256 for three. The seven named gates are just seven of those 16.

Common mistakes

  • Mixing up OR and XOR. For inputs 1 and 1, OR gives 1 but XOR gives 0.
  • Reading NAND as 'NOT A AND B'. It's NOT applied to the whole AND: AB‾\overline{AB}, not A‾B\overline{A}B.
  • Inverting only one side when converting with De Morgan. A+B‾=A‾⋅B‾\overline{A + B} = \overline{A}\cdot\overline{B}: complement each term and swap the operator.
  • Assuming XOR of three inputs is 1 only when exactly one input is 1. It's 1 when an odd number of inputs are 1, so 1⊕1⊕1=11 \oplus 1 \oplus 1 = 1.

Where this comes up in exams

The GATE 2027 CS syllabus lists, under Section 2, Digital Logic, Boolean algebra and minimization and the design of combinational and sequential circuits, which are built from these gates. The GATE 2027 EC syllabus lists logic gates and their static CMOS implementations under Digital Circuits.

Checked against GATE 2027 CS syllabus and GATE 2027 EC syllabus. Syllabi can change from year to year, so confirm with the latest official notification for your exam.

Continue learning

Gate expressions are simplified with Boolean algebra.