What actually happens inside a computer?
by MARS MORALES
You may already know computers use binary (zeros and ones), but what is physically going on? This drove me nuts for the longest time. After relentlessly bugging the heck out of electrical engineering graduate students, I finally understood! Soon, you will, too (or at least understand one mech engineer’s interpretation).
Circuit boards, like the one pictured above, are like highways of wires where electrons flow like cars. Logic is the rules of the road, telling them when they’re allowed to start and stop. These kinds of rules are called digital or Boolean logic (created by a guy named George Boole).
What is Boolean logic?
Boolean logic is based on the idea that electricity flowing in a wire can either be on or off. These two choices are also called true or false and 1 or 0, respectively, but whatever you call them it’s always a binary system (bini = two things).
But a computer is more than a light switch that’s only on or off, it has LOTS of inputs (states of being on or off) that need to be compared. These comparison statements are how it makes complicated “decisions” (in quotes because the computer doesn’t make choices like a living thing).
There are three basic operators: AND, OR, and NOT. There are some advanced ones but I won’t cover them here. Operators are always capitalized and always have only one output (result). They can be represented by mathematical operations like multiplication (×) and addition (+).
Below are two sections explaining how the operators work, the first in words and the second using math. If you don’t understand one, the other might make more sense.
Also, input 1 and input 2 can be shortened to A and B.
Explained with Words
- AND compares two inputs. The first and second inputs must both be true for the output to be true.
- corresponds to multiplication.
- OR compared two inputs. At least one of the first or second inputs must be true for the output to be true.
- corresponds to addition.
- NOT has one input. Also called an inverter, it just turns true into false and vice versa.
Explained with Math
AND example (formula is A × B):
- Inputs: 1 AND 0
- Math: 1 × 0 = 0
- Output: 0 (false)
Another AND example:
- Inputs: 1 AND 1
- Math: 1 × 1 = 1
- Output: 1 (true)
OR example (formula is A + B):
- Inputs: 1 OR 0
- Math: 1 + 0 = 1
- Output: 1 (true)
- NOTE: In cases like 1 OR 1 where the answer is 2, you just say the answer is 1. Because it’s already non-zero making it true, it can’t be truer.
NOT example (formula is 1 – A):
- Input: 1
- Math: 1 – 1 = 0
- Output: 0 (false)
Back to real life (computers)
Inputs are one or two wires leading into the logic gate, and output is one wire that leaves it. But what is going on inside the logic gate, where the “math” happens?
What is a logic gate?
Logic gates are symbols representing electronic setups. Here are examples of AND, OR, and NOT drawings from Hyperphysics:
Each symbol has at least one input and one output.
The symbol shapes are pretty much universal, so AND is always shaped like a half-oval, OR is always a pointy version, and inverters always have a circle at the output end.
In “real life” logic gates live within integrated circuits. ICs usually look like this:
Wow, what a cute little bug! How does it work?
The metal “legs” (called pins) sticking out of the integrated circuit are paths for electricity. Once inside, the electricity will encounter a logic gate and may or may not be allowed through an exit pin.
This diagram is an example of an integrated circuit with AND gates inside. Recognize the symbols?
The squares labeled 1 through 14 are pins. Each of the four AND gates has two input pins and one output pin. The two pins that aren’t connected to any gates are for supplying power (this will be explored in a future article on electronics).
How do the gates work?
Basically, inside the gates are switches which only let electricity flow if a certain voltage threshold is met (but it depends on what kind of logic gate it is). The switches control the flow by taking advantage of electricity’s properties.
This video excellently explains transistor switches WAY better than I ever could. It also brings up voltage, which will be the topic of a future article. You can read a Mothfuzz article about the history of the transistor here.
Digital integrated circuits have logic gates inside. Each logic gate has one or more inputs and one output. What’s inside the gate depends on what logical operation it does, but it’s generally some transistors that control electricity going through.
There are so, so many different kinds of integrated circuits, but this is fundamentally how they all work.
If you understand digital logic, you understand the foundation of computers.
If you liked this article, please whitelist Mothfuzz.com with your ad-blocker! The ads keep this site free.
Disclaimer: I am a mechanical engineer, not an electrical or computer engineer. If I made a glaring mistake, please let me know!