Logic Gates Tutorial

Logic Gates. They’re all around us in many electronic devices. They make up the digital building blocks for circuits used in eg. counters, calculators, computers. In this
Logic Gates Tutorial, I will quickly touch on the basics of logic gates and their theory.

Logic fundamentals

Logic circuits are generally built upon the binary system; Information exists in only two states: on and off. These states can be named in various ways: true/false, 1/0, on/off, high/low, etc. All it comes down to is that information is represented by a bit that has two states.

How do you represent a 1 and a 0 in electronics? Generally, one would use a voltage to represent the digital signal. One could think of a high voltage (at or close to the supply voltage) to be 1, and a voltage at or close to 0V to mean 0. This is a good idea except that circuits might not always reach the exact limits of the power supply due to voltage drops over resistors or diodes and you will end up with a voltage close but too far from the supply voltage. For that reason, ranges of voltages was selected to represent a logic 0 and 1. Two main “standards” exist. The next table should explain clearly:

Type Logic 0 Logic 1
TTL 0 to 0.8V 2 to VCC VCC can be between 4.75V and 5.25V
CMOS 0 to VDD / 2 VDD / 2 to VDD VDD being the supply voltage, limited by the technology the logic circuit uses.

Any voltage level not defined above (that is between the levels for a 1 and a 0) is undefined and generally the logic circuitry will not act upon such voltage levels but keep the input state at the previously certain state.

Schmitt Trigger

Say you have a noisy signal that is supposed to represent a binary value and this signal’s voltage is close to or “riding” around the switching point of your logic circuit. Your logic representation would swap between 1s and 0s continuously while you might only have wanted a clean definitive binary value. In comes the Schmitt trigger. A logic device that allows an analog input to switch the logic value to 1 when it goes above a certain threshold voltage and also back to 0 when it goes below a certain voltage. Everything in between essentially gets ignored. Have a look at this image from Wikipedia for a visual explanation.

Hysteresis applied to a noisy signal
A noisy signal (U) fed into a comparator (A) and a Schmitt trigger (B). The green dotted lines are the circuit’s switching thresholds. The Schmitt trigger tends to remove noise from the signal.

The Truth Table

A way to explain a logics system is needed to easily indicate what outputs to expect from the system for different inputs. The truth table is such a way. It is a table with rows for each possible combination of input values and the equivalent outputs to expect.

Now to look at the basic logic gates. For each one, I’ll include a truth table, textual and graphical representation, and some of the logic ICs that implement that particular gate.

The Inverter (NOT Gate)

This gate flips the input around, inverting it’s value: 1 becomes a 0 and 0 becomes a 1.

Logic expression A
Mathematical expression X = ¬A


The AND and NAND Gates

The AND gate output is true if and only if all inputs are true.

Logic expression AB
Mathematical expression X = A ∧ B

The NAND gate merely invert the result and is represented Y = AB

0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0

AND gate

The OR and NOR Gate

The OR gate output is true if any of the inputs are true.

Logic expression A+B
Mathematical expression X = A ∨ B

The NOR gate (written A + B) is, like the NAND gate, the inversion of the OR gate.

A B OR NOR 0 0 0 1 0 1 1 0 1 0 1 0 1 1 1 0

OR gate

The Exclusive OR (XOR) Gate

The XOR gate output is true only when one of the inputs is true and the other is false.

Expression A ⊕ B
0 0 0
0 1 1
1 0 1
1 1 0



Leave a Comment