From Binary to Logic Part II: Logic Gates

Lucas PenzeyMoog
4 min readApr 23, 2019

--

Photo by Mika Baumeister on Unsplash

This is a continuation of Part I of this series which covers an introduction to binary and transistors, so start there if you want the full story, or continue straight into logic gates.

Logic Gates

A logic gate is a fancy term that simply means a device that can take one or more binary inputs and produce a single binary output. Logic gates can be implemented in a few different ways, but we’re going to focus on ones implemented with transistors.

One of the simplest logic gates is called the AND gate, and it’s built using two standard (non-complementary) transistors chained together. In the diagram below the V stands for volts, which is our source. A and B represent the values (0 or 1) being fed to the gate of each transistor. The inverted pyramid of three lines at the bottom of the diagram represents our sink.

Remember that logic gates take one or more binary inputs and produce a single binary output. The relationship between these inputs and outputs is summarized in what’s called a truth table. The truth table for an AND gate is as follows:

This is called an AND gate because the output will only equal 1 if both A and B have a value of 1. When A and B have a value of 1, the gates of both transistors are in their “on” state and electricity can flow from the source all the way through both transistors and into the sink. When we want to represent different gates it’s helpful to have a simplified version, especially when we start chaining logic gates together. The below is the standard symbol used to represent an AND gate:

AND gate symbol

Along with a few others gates, most logical processes can be accomplished by combining the six gates pictured below. For example, a full-adder circuit, which can perform addition with binary numbers, can be created by combining one OR gate, two XOR gates, and two AND gates:

full-adder circuit

Truth tables are great and all, but as you can tell from my last few posts I’m a big fan of visuals. Understanding truth tables can easily be done with a tool called logic.ly, which is very helpful for exploring how logic gates function in general. Here are the six major gates and their truth tables in graphical form:

AND gate — Output is on if A and B are on
OR gate — Output is on if one or both of A and B are on
NAND (not and) gate — Output is on only if both A and B are not on
NOR (not or) gate — Output is on only if A and B are both on or both off
XOR (exclusively or) gate —Output is on if either A or B are on, but not both
XNOR (exclusively not or) gate — Output is on only if A and B are both on, or both off

We now have a basic understanding of how logic gates take binary as input and produce an expected output. With this knowledge, take a moment to appreciate the fact that the device you’re reading this on is making use of billions of transistors and gates to bring you this very basic introduction to a very complex topic.

--

--