A Sample Class Notes of Digital Introduction
A Sample Class Notes of Digital Introduction
When you string a bunch of these transistors together, then you get what’s called
a logic gate, which lets you add, subtract, multiply, and divide binary numbers in any
way imaginable. In a physical circuit, these logic gates have:
Inputs. All logic gates require some kind of input value so that they have
numbers to compare. These figures come in the form of voltages. When your
input voltage is 0V, then it’s considered to be low, or 0. And when you have a
voltage of 5V as an input, then this is deemed to be high, or 1.
Outputs. Once a logic gate has a chance to process your input, it can then
make a decision on whether to open its gate or keep it closed. This output is
entirely determined by the type of logic gate you’re using, and some will only
open if you have two high voltages as an input, whereas others will only open if
you have a low voltage but not a high voltage as an input.
By using a combination of both high and low voltages and sending them through a
logic gate’s input, we can make some amazing things happen. But at the end of the
day, we’re still working with some fundamental questions – do we want to allow a
particular logic gate to allow an electric current to pass through, or not? While this
might seem simplistic at an individual level, chaining all of this logic and decision
making together is how we’ve gone to create some amazing digital electronics in such
a short period of history. But are logic gates really anything new?
Transistors were perfect. They were reliable, didn’t consume nearly as much power as
vacuum tubes and relays, and were incredibly small in size. Despite their difference in
size and shape, the function of relays, vacuum tubes, and transistors were all the same.
They worked as a switch to control the flow of electricity based on some input
voltage.
The first transistor in all its glory made famous by Bell Labs (Image source)
In the 1960s, we started to put together a collection of transistors together that led to
the creation of the first integrated circuit, ushering in our age of modern computers.
These ICs started off simple, cramming in about 20 transistors in a 3 mm square chip
of silicon with other components like resistors and diodes. The earliest ICs were
referred to as small-scale integrated (SSI) ICs.
The production of ICs continued to advance though, soon cramming in 4,800
transistors in the first microprocessor in 1974 made by Intel. Today, we’re in the age
of very large scale integrated (VLSI) ICs, which can pack in millions and even
billions of transistors into one tiny package. All of these integrated circuits are
mathematical powerhouses, stringing together a dizzying amount of logic gates with
the help of transistors to add, subtract, multiply, and divide numbers as we please.
A great visual for how far integrated circuits have come, now packing in millions of
transistors. (Image source)
There are a variety of logic gates, including AND, OR, NOT, XOR, NAND, and
NOR. Each of these logic gates has a very specific way of handling the inputs and the
output that it produces. But regardless of what kind of logic gate we’re talking about,
the inputs and outputs will break everything down to two binary numbers that make
up digital electronics, 1 and 0.
AND Gate
Let’s head back to our farm for a minute. Say we want to let out one of our chickens,
but only if it’s with a rooster so that it can have some protection out on our pasture. In
this case, our chicken and rooster are dependent on each other. If the chicken AND
the rooster are together, then we can let them through our gate and out into the
pasture.
This is how an AND gate works in an electronic circuit. The only way to get a high
output of 1 is to have both of your inputs be 1s as well. Let’s break this down and see
how it works using our chickens in three scenarios:
If we have a chicken AND a rooster at our gate, then we will open the gate.
If we have a chicken AND no rooster at our gate, then we will keep the gate
closed.
And if we have no chicken AND no rooster at our gate, then we will keep the
gate closed.
See the pattern here? Both inputs of an AND gate are entirely dependent on each
other. You can’t have one without the other to produce an output of 1. Here’s how all
of this will break down on what’s called a truth table with A and B being inputs, and
Q being the output:
As you can see, the only way to get a 1 for an output is to have two of the same inputs
flowing in. Otherwise, the gate in a transistor remains closed, and no electricity will
be able to flow through. Here’s how an AND gate will look on a schematic.
An AND logic gate with two inputs and one output.
OR Gate
Back on our farm again, let’s say this time we put up a fence, so we aren’t too worried
about our chickens going out with a rooster for protection. In this example, our
chicken and rooster are not dependent on each other, so if a chicken OR a rooster
approaches our gate, we will open it for them.
With an OR gate, you only need one of your inputs to be a 1 for the output to also be
a 1. Here’s how it would break down in our chicken scenario:
If we have a chicken OR a rooster at our gate, then we will open the gate.
If we have a chicken OR no rooster at our gate, then we will open the gate.
If we have no chicken OR no rooster at our gate, then we will keep the gate
closed.
The pattern here is also pretty clear as well. Both of our inputs are not dependent on
each other, and so long as one of them is present, our gate will open. Here’s how all of
this will look in a truth table with A and B being inputs, and Q being the output:
If you want to quickly identify an OR gate on a schematic, look for this symbol:
NOT Gate
The NOT gate gets a little tricky with our chicken analogy, so let’s try something
else. Say you also have some goats on your farm, but you don’t ever want to let them
outside of your gate. So even if we have a goat at our NOT gate really wanting to go
out, we aren’t going to open the gate. Despite our goat representing a 1 in our logic
gate as an input, a NOT gate always produces an opposite output.
But let’s say the goat walks away from our gate, we now have a 0 as our input, being
the absence of the goat. According to our NOT gate, this will produce an output of a
1, meaning that we can keep our gate open so long as we don’t have any goats nearby.
NOT gates are a bit strange when compared to other gates, as they always do the
complete opposite of whatever input value you provide it. These gates also only
require one input to produce their output, whereas other gates will always need two
inputs. Here’s how the combinations for a NOT gate will look like in a truth table
with A being the sole input and Q being the output:
And it’s pretty easy to spot a NOT gate on a schematic, just look for the logic gate
with only one input and one output.
A NOT logic gate provides the opposite of its input value as its output.
XOR Gate
Back to our farm, we’ve got a XOR gate, which is just like an OR gate, except that if
both of our inputs are present, then the gate will remain closed. You can think of
a XOR gate as being a kind of either/or situation. For example:
If we have EITHER a chicken OR a rooster at our gate, then we will open the
gate.
If we have no chicken or rooster at our gate, then we will keep the gate closed.
If we have both a chicken and a rooster at our gate, then we will keep the gate
closed.
XNOR Gate
If we have a chicken OR a rooster at our gate, then we will open the gate.
If we have a chicken but not a rooster at our gate, then we will keep the gate
closed.
If we have no chicken OR rooster at our gate, then we will open the gate.
And here’s how all of this will break down in a truth table, with A and B being the
inputs, and Q being the output:
The schematic symbol for an XNOR gate looks very similar to a XOR gate with the
addition of a dot at the end of the output:
An XNOR logic gate only returns a 1 output value if the two inputs are the same.
NAND Gate
This gate works similarly to an AND gate, except that when you have two inputs of 1,
you’ll always get an output of 0. So let’s say that we only want to let our chickens out
one at a time, but not with a rooster. A NAND gate is just what we need to make this
happen:
If we have both a chicken AND a rooster at our gate, then we will NOT open
the gate.
If we have a chicken AND no rooster at our gate, then we will open the gate.
If we have no chicken AND no rooster at our gate, then we will open the gate.
If you’re getting stuck on this then, then try thinking of it like this – a NAND gate
works as both an AND gate and a NOT gate. It first compares the two values
using AND logic and then provides an opposite output based on the AND logic.
Here’s how all of this breaks down in a truth table with A and B being inputs, and Q
being the output:
And if you need to work with a NAND gate on a schematic, here’s the symbol to look
for:
A NAND logic gate returns an output of 0 when both inputs are 1.
NOR Gate
Our last and final gate to work with on our farm is a NOR gate, which is just like
a NAND gate in that it has an opposite output than you might expect. A NOR gate
will work just like an OR gate, except that its output is opposite of an OR gate’s
output. For example, back on our farm let’s say we have a mean storm raging outside
and we don’t want to let any of our chickens into our pasture. The NOR gate is just
what we need:
If we have a chicken OR a rooster at our gate, then we will not open the gate.
If we have a chicken OR no rooster at our gate, then we will not open the gate.
If all of our chickens are safe in their coop and not at our gate, then we will
open the gate.
Still with us? A NOR gate works both as an OR gate and a NOT gate. It first
compared the two values using OR logic and then provides an opposite output based
on the OR logic. Here’s how all of this will break down in a truth table with A and B
being inputs, and Q being the output:
And if you’re on the lookout for a NOR gate on a schematic, find this symbol:
A NOR logic gate works just like an OR gate with an opposite output.
While individual logic gates on their surface are all relatively simple and
straightforward, it’s the combination of these gates together that really brings out their
superpowers. By using a combination of logic gates together in an integrated circuit,
you can perform some incredibly complex calculations. And the more logic gates that
you pack into the same physical space, the faster you can calculate! Wherever you
look in the world of digital electronics, you’ve got logic gates at play, doing all of the
heavy mathematical liftings to make some amazing things happen. So the next time
you hear some beautiful music pouring out of your speakers, or you watch a SpaceX
rocket landing in the middle of an ocean without a second thought, remember that
you’ve got logic gates to thank, working tirelessly behind the scenes.