From Binary to Logic Part I: Binary Counting and Transistors

Lucas PenzeyMoog
5 min readApr 19, 2019

--

Photo by Azlan Baharudin on Unsplash

Most people have heard the phrase that computers “are all ones and zeroes at the end of the day”, but what does that actually mean? How do we get from two simple values to the technology that we all take for granted these days? This post does not aim to answer that question fully, since the complete answer would require one or two masters degrees and years of study. Rather this two part series aims to introduce the concept of binary, transistors, and finally logic gates to serve as an introduction to the world of computer engineering.

The 1s and the 0s

Let’s start at the beginning of all things regarding digital computers: binary (and yes digital is an important distinction, have fun with the entirely different rabbit hole that is analog computers).

Counting in binary is difficult at first because it uses an unfamiliar base: 2. Chances are you’re familiar with decimal counting, which has a base of 10. Decimal uses combinations of the 10 ubiquitous numbers, 0–9, to represent every possible value. Binary, on the other hand, only has two elements, 1 and 0, that can be combined to represent any given value.

Representing zero and one is straightforward, but how do we get to two in binary? We do the same thing we do when we want to go from 9 to 10 in decimal (also known as denary), where the units place resets to zero, and a one is added to the tens place.

But in binary we can’t really have a tens place since that’s a base 10 convention. Going forward it’ll be useful to have a shared language for the different spaces in binary, which follow the same pattern as denary:

So to represent the value of 2 in binary it’s as simple as resetting the ones place to zero and introducing a 1 to the twos place. For 3 we can add a 1 to the ones place, but then for 4 we’re back to resetting the ones and the twos place to zero and adding a one to the next largest place (fours).

Now I said we’d be getting from binary to transistors to logic gates which is a lot to cover so I won’t spell out how to count to ten, but see if you can work it out on your own given the above information and check your work against the table below.

Now that we have the basics of number representations in binary, we’ll explore how those values are represented in electronics with the transistor.

Transistors

A transistor is a device that can switch electronic signals and electrical power and contains at least three terminals: a source, a gate, and a sink. Microprocessors in modern computers have billions of these individual transistors packed into a chip the size of a stamp. The one pictured below is much larger than the ones powering todays computers but it’s useful for illustrating the basic concept. The three metal pins are the source, gate, and sink, and it’s the gate that determines whether electricity is allowed to flow from the source to the sink.

A common analogy for describing this flow of electricity is that of a water faucet. In a faucet, water flows from the water company (the source), and passage of water from the water company to your kitchen sink (the sink, easily enough) is controlled by the knob (the gate). When the knob is closed water isn’t allowed to flow into the sink, and when the knob is opened water is allowed to flow.

Now replace water with electricity and the knob with a gate and we have the transistor. When the gate is “on”, meaning it has a value of 1, the transistor is “on” and electricity can pass from the source to the sink. When the gate is “off”, meaning it has a value of 0, the transistor is “off” and electricity does not flow from the source to the sink.

To build computer chips, the above type of transistor is combined with what’s called a complementary transistor, where the values of the gate are inverted. So when the gate is “off” (which again means it has a value of 0) a complementary transistor is on, so electricity can flow from the source to the sink. When the gate is on, with a value of 1, a complementary transistor is off, so electricity cannot flow from the source to the sink. This type of transistor is represented by adding a dot to the transistor’s gate:

Based on the type of transistor and state of its gate it’s possible to control the output of the transistor. This output will either be a 1 or a 0: a 0 will be the output when there is no electricity flowing through the gate, and a 1 will be the output when electricity is allowed to flow.

Now we have a basic conceptual understanding of how the absence or presence of electricity at a transistor’s gate results in the flow or restriction of electricity through the transistor. With just these simple building blocks we can construct what’s called a logic gate, which takes one or more binary inputs and produces a single binary output. Logic gates are what make computational logic possible, and will be the subject of Part II of this series.

--

--