this video is sponsored by onedreams
stay tuned to the end to find out more
think of any computing device or
computer activity you take for granted
shopping on your smartphone playing
games on your computer
watching this video on a notebook
all these devices and activities are
made possible by something that is not
that dissimilar from this light switch
a standard light switch simply turns a
light either on or off
yes or no true or false
that's it
remarkably the brain of your computer
called the cpu or central processing
unit is made up of essentially billions
of light switch-like components called
transistors a transistor is simply a
device that either has a current flow
through it or not when a current is
flowing it is odd or true or equivalent
to a one when no current is flowing it
is off or false or equivalent to a zero
this is what binary means a one or zero
a standard computer at its essence only
understands this binary language what is
a 1 and what is a 0 that's all
so the question is how does a simple
device like a transistor result in the
myriad of complexity and sophisticated
devices capable of enabling so much of
our modern lifestyle and essential
activities to answer this question i
want to take you on a journey inside the
cpu of a computer and show you how it
actually works in addition i'll point
out the essential differences in how a
cpu of a quantum computer would work
versus a classical computer cpu you
don't want to miss what's coming up
right now
let's do a quick review of the main
components of a computer for any
computer to work it needs a power supply
because energy is needed to run the
system
a computer works with a lot of data so
it needs a place to store the data
for storage of bulk data hard drives and
solid state drives are used
but bulk storage devices are simply too
slow for the speeds needed to transfer
data with the processor to help this
issue most computers have something
called ram or random access memory which
is much faster than any hard disk or ssd
and it's also physically closer to the
processor allowing higher bandwidth and
faster flow of data
all these devices are really ancillary
to the main component of the computer
which is the central processing unit or
cpu
this is the brain of the computer that
does the actual computation the device
that you're likely watching this video
on like a laptop notepad phone etc
contains such a processing unit a
classical cpu is made from transistors
a transistor is basically like an on off
switch if it is on then it's like the
number one and if it's off it's like the
number zero groups of transistors
connected in the appropriate way form
what's called logic gates these logic
gates do the actual computation in cpus
to understand how logic gates work let's
look more closely inside a cpu we'll do
this by looking at the very first
commercially available general purpose
processor which was introduced by intel
corporation in 1971 called the intel
4004
by looking at this relatively simple
processor we will get an idea of the
architecture of the cpu the 4004 was a
four bit processor this means it can
work with inputs formed by four bits and
again one bit is nothing but either one
or zero thus the processor could accept
an input like
one zero one one this is also called a
word a word is an object made from ones
and zeros with which the cpu works
and in the case of the intel 4004 it was
four 4-bit words it consists of 2 250
transistors to give you an idea of how
much we have progressed in 50 years
modern processors are 64-bit processors
and consists of billions of transistors
now let's look closer at how a computer
actually works by processing just ones
and zeros
the internal diagram of the intel 4004
chip looks like this there are some
timing controls at the bottom
responsible for keeping the operation
synchronized because if not synchronized
the computer will get lost with what
it's trying to do and crash
we have some registers and an address
stack for storing values to keep track
of the data we're working with there's
also an instruction decoder that helps
decipher the code and figure out what
the cpu should be processing and we have
some io or input output to communicate
with other components of the computer
the magic all happens at this red thing
called the alu or arithmetic logic unit
this is where everything is calculated
in process
the rest is mostly just data management
and data storage so it's really not that
complicated basically you take some
input perform a set of operations on it
and then you get an output the end
result is a set of output data now there
are many more components needed to make
all this synchronized and smooth but
essentially that's it
how it's processed at the alu is
determined by the instructions that it
is given in modern cpus there can be
many such alus as part of so-called
executive units and then each of these
units can specialize in different tasks
like addition or multiplication
let's do a quick example to see how an
alu works
let's say we want to add two numbers two
and three
these two numbers will be represented by
four binary bits
in binary code two is represented as 0 0
1 0 and 3 is represented as 0 0 1 1.
these are the input bits also called
operands
to add them together the instruction
code must tell the alu to add them this
will be specified by some flag that
tells it what to do with the operands it
receives these are sent to the alu in
the form of a set of binary bits so for
example
the flag could be 0 0 and this could
mean add and 0 1 could mean multiply and
1 0 could be subtract and 1 1 would mean
division some of the bits of the
original instruction code will be flags
and some will be the inputs we need to
add multiply subtract or do some other
operation how exactly all this works is
different for different types of cpus
then the alu processes these inputs and
outputs a result
now in order to compute the results a
lot of complex logic is needed the logic
is built into the processor using
something called logic gate
now what is a logic
it's actually rather simple there are
different variants but essentially a
logic gate takes in two bits thus two
binary numbers of a single digit then
depending on the type of logic gate it
is and depending on what value the bits
have the gate will output a result bit
physically these gates are made from a
bunch of transistors connected in the
appropriate way for whatever gate you
want to make a simple example would be
the and gate
in the and gate if the two incoming bits
are one thus true then the output is one
otherwise the output is false or zero
this is easier to understand in terms of
truth tables where 1 is true and 0 is
false
another gate is the or gate here if
either or both of the incoming two bits
are one then the output is one otherwise
the output is zero now what if we only
want the case where the gate is true if
and only if
one input is one and the other is zero
otherwise it is false this is called an
xor or xor gate there are several more
gates but you get the idea with the and
or or xor gate we can construct a
circuit which can add numbers but before
we get to that let's look at how a logic
gate is built using transistors after
all the transistor is the core building
block of a cpu the add gate is rather
simple to build you just need two
transistors and some appropriate
resistors there are different ways to
physically construct a logic gate so
this is just one example the and gate
takes in two inputs and if those two
inputs are true or one then the output
is on or one or true so let us take
one transistor and attach some power
source to it thus the source input is a
then we connect the first input a
as the gate input to the transistor thus
if the input a is on or connected then
the gate will have electricity flowing
through
now the second transistor has to also be
on for the output to be one if either a
or b are not connected in other words if
either is zero then the output will be
zero they both have to be one for the
output to be one this is exactly how an
and gate should work we can also make an
or gate with two transistors if we just
change the wiring a bit in this case if
either a or b transistors are on the
output will be one it will be zero only
if both transistors are off the xor gate
is a little bit more complicated but the
idea is the same it's just a couple of
transistors and resistors to regulate
the signal and then everything must be
wired in the correct way
how can we then use these logic gates to
add numbers for this we need two xor
gates two and gates and one or gate this
is called a full adder circuit here a
and b is the input to add and c n is the
carry bit from the c out output this is
needed to carry over bits for example in
elementary school when you learned to
add five plus five then you had to carry
the one for the tens unit and put a zero
in the one spot it works the same way in
binary language the carry out bit is the
same concept
this might seem trivial but a computer
is fundamentally just doing first grade
math really fast of course computers
work with binary numbers so in the cpu
we would get a carry if we add one and
one since anything larger than a one
would require a carry in binary let's
now add two numbers two and three first
we must convert them into binary using
four bit numbers we can write 2 in
binary as 0 0 1 0 and 3 as 0 0 1 1.
from right to left we have 0 and 1
through the xor gate the result is 1 or
true in the beginning of the calculation
the c n starts with a zero since there's
no carry from the c out when the zero
from the c in is combined with the one
from the first xor gate
into the second xor gate we get a one
for the output
now if we continue with the first and
gate the inputs will be 0 and 1. the
result will be 0.
the input for the second and gate will
be 0 and 1 from a and b
the result will be 0.
0 and 0 through the or gate will also
result in a zero next we again have one
and one for the input and the result is
zero
because the previous c out was zero then
c n will be zero again if we continue we
will see that we have a zero at the
second xor gate and the first and gate
but this time since both a and b are one
then the second and gate will return a
one now since we have zero and one as
the input for the or gate
the result will be a one we get that the
c out is one we thus have a carry to
consider in the next step
for a and b this time we have zero and
zero which is zero from the first xor
connected to a and b but now we have a
carry so cn is now 1.
this means that in the second xor gate
we now have 0 and 1 as the input so we
get a 1 as the result
now as a and b is 0 there is no carry
out so c out is now 0. in the last step
we have zero and zero as the input and
since the c in is also zero then
everything is zero and the result of
this round is zero all around if we
collect all the results from our four
rounds of computation then we get that
zero zero one zero plus zero zero one
one
equals
zero one zero one and if we convert this
into standard integer numbers we get
five
so voila two plus three is equal to five
and this is exactly what we would expect
from this adder logic circuit
similarly logic gates can be constructed
to do other things so in this way a
computer can do all kinds of cool things
but it's easy to forget that these logic
circuits are just doing first grade math
the circuitry and architecture of the
computer as a whole is complex but it is
built around an elementary concept this
is roughly how a classical processor
works you have some timing management
components and a lot of storage for
instructions and the data which the
processor needs to work the alu then
executes and performs the actual
calculation to give you some result
that's it now how do quantum computers
differ quantum computers in principle do
the same computations as a classical
computer but there are a couple of
differences
instead of bits the quantum processor
uses qubits to do the computations
qubits are bits that are in a
superposition of both zero and one but
they can potentially take on an infinite
number of values between zero and one
they could be made with one of many
quantum objects like electrons or
photons that have some binary property
like spent stupids being in
superposition have some significant
advantages if you want to learn more
about why this is so powerful check out
my prior video about quantum computers
because qubits can be in a state of both
0 and 1 at the same time qubits can
store 2 to the power of the equivalent
number of bits so three qubits can hold
the same amount of data as two to the
third or eight classical bits and just
10 qubits would be able to store the
same data as 2 to the 10 or
1024 classical bits
now qubits are quite different
physically compared to the bits of a
classical computer in the classical
computer we use electrical signals that
flow through a circuit if there's a
signal you have a one state if there's
no signal you have a zero state the
qubit on the other hand is usually
stationary it's located in a physical
place on the quantum chip so they do not
flow like classical bits through a gate
the gate has to be applied onto the
stationary qubits this can be done using
photons in particular using microwave
pulses
but the exact detail depends on the
design of a specific chip we're still in
the early days of quantum computing so
many different approaches are being
tested
instead of classical logic gates quantum
computers use quantum logic gates in the
quantum case we can also make a full
adder to add two numbers but instead of
and gates we use what's called to foley
gates and instead of or or xor gates we
use c not gates at face value the
quantum full adder isn't really anything
special the gates are slightly different
but we're still just doing simple
operations the magic of the quantum
computer comes from the fact that the
quantum logic gates can work with cubits
we have two qubits in this circuit so
instead of adding just two numbers
together we could potentially do four
additions at the same time if we had
three qubits we could do eight additions
at once and so on
adding two numbers on a quantum computer
isn't any better than on a classical
computer but something like finding a
specific number among billions of
numbers like a reverse phone number
search is relatively easy
for example let's consider that we want
to find a phone number where for
simplicity the number is between zero
and eight this is the biggest number
that we can write with three classical
bits the classical computer
would then just start from one end and
ask is this the right number so first it
would try 0 0 0 then 0 0 1 then 0 1 0
then 0 1 1 and so on on a quantum
computer we can take 3 qubits and make a
superposition of all eight possible
numbers and thus search the entire space
of possibilities in just one search
instead of up to eight
one thing that quantum computer
scientists agree on is that it won't
solve every type of problem it's well
suited only for certain kinds of
challenges like probability problems
optimization like finding the best
possible travel route or a needle in a
haystack type of problems the challenges
that quantum computing faces isn't in
the hardware but the real magic of the
quantum computer comes from the
algorithms used to solve these problems
using qubits not better machinery or
speed as new algorithms are developed
we'll find more ways to use quantum
computers in more applications the past
might be classical but the future is
almost certainly going to be quantum
if you want to learn more about
computers and quantum mechanics then
consider subscribing to wondering
today's sponsor one of the courses that
helped inform me during the research for
this video is called the science of
information from language to black holes
it's taught by one of my favorite
educators benjamin schumacher of kenyan
college this is a 24 lecture series
which teaches you everything from logic
gates to cryptography to cubits to the
connection between reality and
information you can not only enjoy these
great lectures by professor schumacher
but also some of the best educators in
the world you'll be hard-pressed to find
a better online learning service than
one dream i myself have been a member
for a very long time i can't recommend
them enough you'll even see my
testimonial at the bottom of one dream's
homepage it's really easy to sign up
right now because they are offering a
free trial and you can cancel at any
time but there's really nothing to lose
if you want to support this channel and
greatly increase the depth of your
knowledge be sure to click the special
link
in the description and if you have a
question or comments from me
please leave them in the comment section
because i try to respond to all of them
i'll see you
in the next
video my friend
[Music]
you