1

**Articles / How CPUs Work**

« **on:**June 27, 2018, 07:21:29 PM »

Get on my bus(!), I’m going to a magical place. I’m going to have to strap you all in before

we begin, as this is an experimental journey; one that travels through uncharted and scary

territory. It’s a journey from uninterested layperson, to enlightened computer LOVER. You’ll

wonder how you never felt about the machine you call a ‘box’.

Like magicians protecting the tricks of the trade, the uber nerds don’t want you to know

about this place! Well, maybe they don’t care, but it sounds dramatic, right? And it’s

damned dramatic. You’ll touch on parts of your mind that’ll have you linking the Universe

to bunnies and hair ties. You’ll scratch your left butt cheek as your knowing grin spreads

with the realisation that you know more about computers than 99% of Earths population.

Yes. I’m selling tickets for a bus ride. A bus ride through the very heart of a computer

brain. I mean, the brain of a computer, stopping off at the heart on the way. Or, was that

bypass the heart, then blow by the lungs as we circumnavigate the brain? It’s not important.

What you should know before we leave the depot is this: What you are about to learn will

make you an uber nerd. You will, from now and ever after be hated by everyone you meet.

Not through jealousy at your broad knowledge, not through disdain at not being able to keep

up with your dinner table banter… Oh no. It’s just that you’ll bore the crap out of everyone

you meet! Once you know the secret of the computer, you’ll be consumed. You’ll want to build

your own CPU, just like I have. And that’s a good thing.

Oh yeah… Uber nerds stay out! You already know all this stuff, so I ask that you give up

your seat for a lesser, pimplier nerd. Thank you. Are we ready, set, primed? Good, let’s

begin.

You are standing in a dusty room. It’s in an arid outback location. Two people are talking

to the desk clerk about a journey to the summit of the nearby mountain. It’s named, Mt Uberknowledge.

It’s a pretty big mountain, lucky we’re taking my bus to the top!

Our aim, by the end of this article, is to get intimate with the workings of an electronic

computer. Our aim, by the end of this article, is to know what it is to compute. The computers

we’ll be studying are built and designed by me. They are not real! They are software simulations

of my designs. The first computer is primitive and simplistic, but it works. We will begin

our journey with a look at some of the items required in order to begin computing.

First off, what is a goal of designing a computer? It needs to process data. Apart from how

we interpret that data, everything a computer does is just processing data. You put something

in, and expect the right output. OK, that’s pretty bog standard knowledge. We all know

that. What we don’t all know is, how simple it really is inside the computer.

It’s simple, but there’s a lot of simple, which ultimately makes it complex… Please don’t

get the wrong idea about my computer designs that we’ll be using for this article. They

are not up to scratch by any modern or 1950s standard. What they are though, is a perfect

example of what a computer does. They can play games, process words and balance your budget

(we’ll get to those things). Clever folk come along and make the basic design quicker and

cheaper to build, but the concept remains the same. So onwards we go!

We process data, but what is data? To a computer, data is an electronic signal. Well that’s

what you’ll hear all the time. We call it a signal, but it’s nothing more than a voltage,

or not a voltage at some point in a circuit. We place our own meanings on what the value

of those ‘signals’ might be. How can this allow a machine to process human information?

This is the question that has driven my simple brain to learn what I now know. This is

the magic part of computers, and more importantly, the magic part of humans. Computers are

human things, they came from human minds. They are tools that work with our minds, like

a PCI card for our minds.

Have you ever stood at the end of a passage way that has a light switch at both ends, for

the same light? It’s so you can turn it on, walk to the other end, then switch it off;

all without being attacked by a monster. The passage light is something I find very useful

as your first example of digital electronics. The light is wired to the two switches in

such a way that they have a relation ship to it. The light can be turned on by different

combinations of the switch. Let’s see. If one switch is turned on, the light will be lit.

If both are on, the light will be lit. But you need at least one switch to be on before

you’ll light the light. This is a logical arrangement. And it has a special name within

the world of digital electronics, it’s called an ‘OR’ gate. Digital what the??? Digital

electronics is just a fancy name for circuits that work based on levels being above or below

a certain threshold. For instance, anything above 5volts DC will be considered an ‘on’ signal.

Anything below, will be considered an ‘off’ signal. But we’ll see more of this as we progress.

Back to the ‘OR’ gate. These ‘gates’ (no relation to Bill) are just switches. If you placed

five volts at one end of a wire, you’d get five volts at the other end. Unless you broke

the wire, then you’d have two pieces of wire. Not a bad deal really, except that the two

new pieces are not as long as the original. But let’s see a video!

http://youtube.com/watch?v=L2fKHesYYNY

In a computer, there are a lot of these things, although they don’t look like that! The switches

are made using ‘semi-conductors’ and they are microscopic switches that rely on electricity

to switch them on or off. But the idea is simple. The ‘OR’ gate/switch has two input signals

and one output signal. It needs at least one input signal in order to output a signal. Two

input signals is fine and will yield the same output as one input signal. It should be noted

that the ‘OR’ gate may have many inputs, but it only ever has one output.

What you have seen is simply amazing. That simple switch arrangement is a major piece of

the computer puzzle. There are only two other pieces. Close you mouth…! I didn’t mention

that the computer puzzle uses the same three pieces over and over and over and over… Did

I?

Here is the second piece, it’s called the ‘AND’ gate. I’ll show you the video first, then

an explanation. Those at the front of the bus should already be onto this!

http://youtube.com/watch?v=gBQ23T4Ss6Y

The inputs aren’t so clear for this gate, but once again, they are the switches. See how

the light only comes one if switch one AND switch two are closed? As with the ‘OR’ gate,

the ‘AND’ gate can have multiple inputs. It can have one million inputs if you want, but

only one output. And for there to be an output, every input must bear a signal.

Step back! Signals, volts, gates? Yeah, I’m talking pretty generally, as it serves no purpose

to get down as far as the electronics behind these things. We can assume that five volts

means ‘a’ signal and anything less means no signal. This ‘signal’ is not really travelling

along. It’s more like either present on a wire or not. But we’ll see this in more detail

when I show you the design of my first computer. Hehehe..

There is one final gate that I can show you. It’s the only other gate used in computer circuits.

It’s the ‘NOT’ gate. Not that it’s not a gate, it’s name is the ‘NOT’ gate. It is a gate.

Not, not a gate.

http://youtube.com/watch?v=Eq8xAYmOy08

Simplicity itself. Any input is reversed. A signal going in results in nothing coming out

and verse vice. There is no end to how useful this gate is when applied to digital circuits.

And you’ll certainly see this when we look at the microcode for my computer designs.

These pretty animations are pretty, right? We all agree on that. What you may be wondering

though, is how do electronic ‘gates’ form a machine that can process data? A machine that

can beat you at chess? A machine that can connect to another machine, via the utilisation

of yet more machines, to a machine across the globe? This is why you’re strapped to your

seat. You will certainly try to leave the bus during this next section. Whatever magic was

there, will be stifled and possibly murdered by the boredom that is about to follow. Your

eyes will glaze over. Your brain will ask you “what have I ever done to you???”. You’ll

want to scream, just to liven things up a little. But relax. I strapped you down for a reason.

For it’s the simple things in life that are often the best. And when it comes to binary

logic, there is nothing more beautiful and succinct. Argue with me now, and later, you’ll

agree. Certainly, later, you’ll agree.

Binary logic is the paper work that makes electronic computers possible. Their operations

are designed using this form of mathematics, largely credited to George Boole who lived

in the mid part of the 19th century.

Binary logic is the description of what results from the application of operations on logic

states. Or, what happens when you try to find the truth of adding two false things together.

You’ll see this terminology crop up often. True, false, on, off, one and zero. They all

mean the same thing though. The same thing in the circuit of a computer. Either there is

a voltage, or there is not. Generally, a voltage is mapped to true, on, 1. A lack of voltage

is mapped to false, off or zero.

We combine gates in order to perform operations on data. That’s it. You can go home now!

Oh, you want to know ‘how’ we combine those gates? Well read on. The number system we use

has ten symbols, ranging from the symbol ‘zero’ to the symbol ‘9’., right? There’s nothing

special about it. It’s boring and silly and I want a new one. But that’s not important right

now. Back to the decimal number system…

The decimal number system has like some kind of ‘add in’ functionality that may be applied

to any number system with any amount of symbols. This functionality is the how the columnar

positions of a numeral lend weight to that numeral. The rightmost numeral has a value of

the numeral, multiplied by (10 to the power of 0). Anything to the power of zero is always

one. So this first column is just one, multiplied by whatever numeral is there. If it’s

a three, the value of the rightmost column is three.

Moving to the column left of the rightmost column, we have a different imposed ‘weight’ over

whatever numeral resides there. This time, the column multiples it’s numeral by 10 to the

power of 1. In effect, we just multiply everything in the second from the right column by

ten. Pretty straight forward. There is a generalisation for how this weighted column system

applies to the decimal system:

numbered zero) to left for ‘n’ number of columns. And forgetting all that garbage, we can

see that columns moving to the left apply powers of ten increasing by a factor of ten per

left column move. When you see a number written, like say 666, you are really seeing this

system in play. Let’s go thr…

…ough this number. The leftmost three is in column number ‘2’, if we count from the right

and start our count with zero. That means, that we multiply the numeral in this column by

10^2, or 100. Giving us, 600. The column to the right of the leftmost column contains the

numeral ‘6’. This column is number one, so it’s power will be 10^1. We need to multiply

the numeral in this column by ten. OK, we have a total of 660 so far. I’ll let you guess

what happens for the rightmost column. It has something to do with multiplying the numeral

there by 10^0, which is ‘1’.

The magic of numbers and computers and toast starts to come into play, RIGHT NOW. We have

just generalised all of number symbols. You’ve just seen how flimsy our decimal system is,

and how we can generalise how we show amounts, any way we like. The fact that we grew up

with decimal means we ‘think’ it’s a great way to work with numbers. And I can’t see any

problem with it, but computer manufacturers could. As you may recall from earlier on in

this essay, I mentioned that logic gates are electronic circuits, on a microscopic sc…

…ale. They aren’t microscopic for the fun of it. It has to do with productivity and competition.

Computer manufacturers need to work to a supply and demand basis like all companies. This

means efficiency, and simplicity in a mind numbingly complex field. When you hear someone

mention that computers can only work with binary numbers, tell them they are wrong. Explain

to them that any number base is possible, binary just happens to translate to cheaper circuits!

Cheaper, for many reasons, as we’ll see.

Binary? That is the focus of the last part of this first essay(there‘ll be more!). Try to

forget for a moment, decimal. Try to think of it as an arbitrary system for arranging symbols

to represent an amount of something. We use ten unique symbols in the decimal system. Binary

uses but two. The numeral one and the numeral zero. How do you show the number zero in the

binary number system? I think you all know the answer to this. How about this then… How

would represent one of something, using the binary number system? Yes, the numeral one!

Easy as wetting yourself.

By now you may be thinking that there’s nothing special about the decimal number system.

You may be thinking that you can generalise the representation of the amount of something

using any symbols you like. And you can. And further to this, why use a fancy name for a

number system? Why not use the number of symbols available as the name? So for decimal,

we’d call it a ‘base ten’ number system. For binary (which has two symbols), we’d call it

a base two number system. And to take this all the way home, let’s apply our weighted column

system to the binary number system and see where that takes us.

In the base ten (decimal) number system, the exponent used to calculate the value of each

column is the number base itself. So it’s ten in decimal. In binary, the exponent is two.

So our new generalised way of looking at a weighted column amount representation scheme

is:

there, so it can be either zero or one. The column to the left of the rightmost column has

2 X 2^1 applied to it. This simply means that a numeral of zero appearing here will give

the column a value of zero, but a numeral of one appearing here will give the column a value

of two. This pattern continues, with the value of each left moving column increasing by

a factor of a power of two.

If you thought this was magic, wait until part two when I show you how to take this theory

and use it to create a machine that can add numbers! Yes. We’ll build a machine that can

dumbly take two binary numbers and come up with their sum, completely unaided by us. Is

that magic? Well it’s certainly yellow!

we begin, as this is an experimental journey; one that travels through uncharted and scary

territory. It’s a journey from uninterested layperson, to enlightened computer LOVER. You’ll

wonder how you never felt about the machine you call a ‘box’.

Like magicians protecting the tricks of the trade, the uber nerds don’t want you to know

about this place! Well, maybe they don’t care, but it sounds dramatic, right? And it’s

damned dramatic. You’ll touch on parts of your mind that’ll have you linking the Universe

to bunnies and hair ties. You’ll scratch your left butt cheek as your knowing grin spreads

with the realisation that you know more about computers than 99% of Earths population.

Yes. I’m selling tickets for a bus ride. A bus ride through the very heart of a computer

brain. I mean, the brain of a computer, stopping off at the heart on the way. Or, was that

bypass the heart, then blow by the lungs as we circumnavigate the brain? It’s not important.

What you should know before we leave the depot is this: What you are about to learn will

make you an uber nerd. You will, from now and ever after be hated by everyone you meet.

Not through jealousy at your broad knowledge, not through disdain at not being able to keep

up with your dinner table banter… Oh no. It’s just that you’ll bore the crap out of everyone

you meet! Once you know the secret of the computer, you’ll be consumed. You’ll want to build

your own CPU, just like I have. And that’s a good thing.

Oh yeah… Uber nerds stay out! You already know all this stuff, so I ask that you give up

your seat for a lesser, pimplier nerd. Thank you. Are we ready, set, primed? Good, let’s

begin.

**First Stop - Information:**You are standing in a dusty room. It’s in an arid outback location. Two people are talking

to the desk clerk about a journey to the summit of the nearby mountain. It’s named, Mt Uberknowledge.

It’s a pretty big mountain, lucky we’re taking my bus to the top!

Our aim, by the end of this article, is to get intimate with the workings of an electronic

computer. Our aim, by the end of this article, is to know what it is to compute. The computers

we’ll be studying are built and designed by me. They are not real! They are software simulations

of my designs. The first computer is primitive and simplistic, but it works. We will begin

our journey with a look at some of the items required in order to begin computing.

First off, what is a goal of designing a computer? It needs to process data. Apart from how

we interpret that data, everything a computer does is just processing data. You put something

in, and expect the right output. OK, that’s pretty bog standard knowledge. We all know

that. What we don’t all know is, how simple it really is inside the computer.

It’s simple, but there’s a lot of simple, which ultimately makes it complex… Please don’t

get the wrong idea about my computer designs that we’ll be using for this article. They

are not up to scratch by any modern or 1950s standard. What they are though, is a perfect

example of what a computer does. They can play games, process words and balance your budget

(we’ll get to those things). Clever folk come along and make the basic design quicker and

cheaper to build, but the concept remains the same. So onwards we go!

We process data, but what is data? To a computer, data is an electronic signal. Well that’s

what you’ll hear all the time. We call it a signal, but it’s nothing more than a voltage,

or not a voltage at some point in a circuit. We place our own meanings on what the value

of those ‘signals’ might be. How can this allow a machine to process human information?

This is the question that has driven my simple brain to learn what I now know. This is

the magic part of computers, and more importantly, the magic part of humans. Computers are

human things, they came from human minds. They are tools that work with our minds, like

a PCI card for our minds.

Have you ever stood at the end of a passage way that has a light switch at both ends, for

the same light? It’s so you can turn it on, walk to the other end, then switch it off;

all without being attacked by a monster. The passage light is something I find very useful

as your first example of digital electronics. The light is wired to the two switches in

such a way that they have a relation ship to it. The light can be turned on by different

combinations of the switch. Let’s see. If one switch is turned on, the light will be lit.

If both are on, the light will be lit. But you need at least one switch to be on before

you’ll light the light. This is a logical arrangement. And it has a special name within

the world of digital electronics, it’s called an ‘OR’ gate. Digital what the??? Digital

electronics is just a fancy name for circuits that work based on levels being above or below

a certain threshold. For instance, anything above 5volts DC will be considered an ‘on’ signal.

Anything below, will be considered an ‘off’ signal. But we’ll see more of this as we progress.

Back to the ‘OR’ gate. These ‘gates’ (no relation to Bill) are just switches. If you placed

five volts at one end of a wire, you’d get five volts at the other end. Unless you broke

the wire, then you’d have two pieces of wire. Not a bad deal really, except that the two

new pieces are not as long as the original. But let’s see a video!

*Here is a generalisation of an ‘OR’ gate:*http://youtube.com/watch?v=L2fKHesYYNY

In a computer, there are a lot of these things, although they don’t look like that! The switches

are made using ‘semi-conductors’ and they are microscopic switches that rely on electricity

to switch them on or off. But the idea is simple. The ‘OR’ gate/switch has two input signals

and one output signal. It needs at least one input signal in order to output a signal. Two

input signals is fine and will yield the same output as one input signal. It should be noted

that the ‘OR’ gate may have many inputs, but it only ever has one output.

What you have seen is simply amazing. That simple switch arrangement is a major piece of

the computer puzzle. There are only two other pieces. Close you mouth…! I didn’t mention

that the computer puzzle uses the same three pieces over and over and over and over… Did

I?

Here is the second piece, it’s called the ‘AND’ gate. I’ll show you the video first, then

an explanation. Those at the front of the bus should already be onto this!

http://youtube.com/watch?v=gBQ23T4Ss6Y

The inputs aren’t so clear for this gate, but once again, they are the switches. See how

the light only comes one if switch one AND switch two are closed? As with the ‘OR’ gate,

the ‘AND’ gate can have multiple inputs. It can have one million inputs if you want, but

only one output. And for there to be an output, every input must bear a signal.

Step back! Signals, volts, gates? Yeah, I’m talking pretty generally, as it serves no purpose

to get down as far as the electronics behind these things. We can assume that five volts

means ‘a’ signal and anything less means no signal. This ‘signal’ is not really travelling

along. It’s more like either present on a wire or not. But we’ll see this in more detail

when I show you the design of my first computer. Hehehe..

There is one final gate that I can show you. It’s the only other gate used in computer circuits.

It’s the ‘NOT’ gate. Not that it’s not a gate, it’s name is the ‘NOT’ gate. It is a gate.

Not, not a gate.

http://youtube.com/watch?v=Eq8xAYmOy08

Simplicity itself. Any input is reversed. A signal going in results in nothing coming out

and verse vice. There is no end to how useful this gate is when applied to digital circuits.

And you’ll certainly see this when we look at the microcode for my computer designs.

These pretty animations are pretty, right? We all agree on that. What you may be wondering

though, is how do electronic ‘gates’ form a machine that can process data? A machine that

can beat you at chess? A machine that can connect to another machine, via the utilisation

of yet more machines, to a machine across the globe? This is why you’re strapped to your

seat. You will certainly try to leave the bus during this next section. Whatever magic was

there, will be stifled and possibly murdered by the boredom that is about to follow. Your

eyes will glaze over. Your brain will ask you “what have I ever done to you???”. You’ll

want to scream, just to liven things up a little. But relax. I strapped you down for a reason.

For it’s the simple things in life that are often the best. And when it comes to binary

logic, there is nothing more beautiful and succinct. Argue with me now, and later, you’ll

agree. Certainly, later, you’ll agree.

Binary logic is the paper work that makes electronic computers possible. Their operations

are designed using this form of mathematics, largely credited to George Boole who lived

in the mid part of the 19th century.

Binary logic is the description of what results from the application of operations on logic

states. Or, what happens when you try to find the truth of adding two false things together.

You’ll see this terminology crop up often. True, false, on, off, one and zero. They all

mean the same thing though. The same thing in the circuit of a computer. Either there is

a voltage, or there is not. Generally, a voltage is mapped to true, on, 1. A lack of voltage

is mapped to false, off or zero.

We combine gates in order to perform operations on data. That’s it. You can go home now!

Oh, you want to know ‘how’ we combine those gates? Well read on. The number system we use

has ten symbols, ranging from the symbol ‘zero’ to the symbol ‘9’., right? There’s nothing

special about it. It’s boring and silly and I want a new one. But that’s not important right

now. Back to the decimal number system…

The decimal number system has like some kind of ‘add in’ functionality that may be applied

to any number system with any amount of symbols. This functionality is the how the columnar

positions of a numeral lend weight to that numeral. The rightmost numeral has a value of

the numeral, multiplied by (10 to the power of 0). Anything to the power of zero is always

one. So this first column is just one, multiplied by whatever numeral is there. If it’s

a three, the value of the rightmost column is three.

Moving to the column left of the rightmost column, we have a different imposed ‘weight’ over

whatever numeral resides there. This time, the column multiples it’s numeral by 10 to the

power of 1. In effect, we just multiply everything in the second from the right column by

ten. Pretty straight forward. There is a generalisation for how this weighted column system

applies to the decimal system:

Code: [Select]

`ColumnValue EQUALS ColumnNumeral X 10^ColumnNumber`

Note that the column number is a zero based count from the right(the rightmost column is numbered zero) to left for ‘n’ number of columns. And forgetting all that garbage, we can

see that columns moving to the left apply powers of ten increasing by a factor of ten per

left column move. When you see a number written, like say 666, you are really seeing this

system in play. Let’s go thr…

*INTERJECTION: This is brain numbing boring crap, I agree, but please bear with me,*

as this turns into something beautiful. And it’s all yellow.as this turns into something beautiful. And it’s all yellow.

…ough this number. The leftmost three is in column number ‘2’, if we count from the right

and start our count with zero. That means, that we multiply the numeral in this column by

10^2, or 100. Giving us, 600. The column to the right of the leftmost column contains the

numeral ‘6’. This column is number one, so it’s power will be 10^1. We need to multiply

the numeral in this column by ten. OK, we have a total of 660 so far. I’ll let you guess

what happens for the rightmost column. It has something to do with multiplying the numeral

there by 10^0, which is ‘1’.

The magic of numbers and computers and toast starts to come into play, RIGHT NOW. We have

just generalised all of number symbols. You’ve just seen how flimsy our decimal system is,

and how we can generalise how we show amounts, any way we like. The fact that we grew up

with decimal means we ‘think’ it’s a great way to work with numbers. And I can’t see any

problem with it, but computer manufacturers could. As you may recall from earlier on in

this essay, I mentioned that logic gates are electronic circuits, on a microscopic sc…

**INTERJECTION:***Why all this talk of numbers and columns and crap?? Listen punk! It’s*

all part of it, OK? We’re learning about how the output of an electronic circuit can be

mapped to something a person need to know, OK??all part of it, OK? We’re learning about how the output of an electronic circuit can be

mapped to something a person need to know, OK??

…ale. They aren’t microscopic for the fun of it. It has to do with productivity and competition.

Computer manufacturers need to work to a supply and demand basis like all companies. This

means efficiency, and simplicity in a mind numbingly complex field. When you hear someone

mention that computers can only work with binary numbers, tell them they are wrong. Explain

to them that any number base is possible, binary just happens to translate to cheaper circuits!

Cheaper, for many reasons, as we’ll see.

Binary? That is the focus of the last part of this first essay(there‘ll be more!). Try to

forget for a moment, decimal. Try to think of it as an arbitrary system for arranging symbols

to represent an amount of something. We use ten unique symbols in the decimal system. Binary

uses but two. The numeral one and the numeral zero. How do you show the number zero in the

binary number system? I think you all know the answer to this. How about this then… How

would represent one of something, using the binary number system? Yes, the numeral one!

Easy as wetting yourself.

By now you may be thinking that there’s nothing special about the decimal number system.

You may be thinking that you can generalise the representation of the amount of something

using any symbols you like. And you can. And further to this, why use a fancy name for a

number system? Why not use the number of symbols available as the name? So for decimal,

we’d call it a ‘base ten’ number system. For binary (which has two symbols), we’d call it

a base two number system. And to take this all the way home, let’s apply our weighted column

system to the binary number system and see where that takes us.

In the base ten (decimal) number system, the exponent used to calculate the value of each

column is the number base itself. So it’s ten in decimal. In binary, the exponent is two.

So our new generalised way of looking at a weighted column amount representation scheme

is:

Code: [Select]

`ColumnValue EQUALS ColumnNumeral X 2^ColumnNumber`

…for binary numbers. The rightmost column represents a direct amount based on the numeral there, so it can be either zero or one. The column to the left of the rightmost column has

2 X 2^1 applied to it. This simply means that a numeral of zero appearing here will give

the column a value of zero, but a numeral of one appearing here will give the column a value

of two. This pattern continues, with the value of each left moving column increasing by

a factor of a power of two.

If you thought this was magic, wait until part two when I show you how to take this theory

and use it to create a machine that can add numbers! Yes. We’ll build a machine that can

dumbly take two binary numbers and come up with their sum, completely unaided by us. Is

that magic? Well it’s certainly yellow!