The Von Neumann Machine

John Von Neumann was an important figure in the history of computing.

../_images/JohnVonNeumann.jpg

His contributions to that history really began when he authored this document in 1945:

World War II

Back in 1945 – World War II was still going on – John Von Neumann was thinking about the whole business of computing. He published his paper as part of work to build an electronic computing machine, and started the world on a whole new track.

Von Neumann explained to the world (in 1945) how an electrical device with a Stored Program could process information. Although he did not come up with these ideas alone (he was working with a team of scientists and engineers building this first machine), Von Neumann was the first to write everything down in a way that was clear and easy to understand. We call the architecture he described, a “Von Neumann Architecture” but major features of the architecture should be properly attributed to others, like Eckert and Mauchly who built the first stored program machine at the University of Pennsylvania in 1943 (ENIAC). Today, Alan Turing (whose story was told in the popular movie, Imitation Game) is credited with having come up with some of the basic principles that led to the development of the computer as well.

Von Neumann’s computing mechanism consisted of four fundamental parts:

  • A Central Arithmetic Unit (CA) to do the number crunching
  • A Control Unit (CU) to manage the machine
  • A Memory Unit (M) to store programs and data
  • An Input/Output Unit (IO) to get things into and out of the machine

How the parts are organized

../_images/VonNeuman.png

As obvious as this might seem today, back when Von Neumann was doing his work, few people really had any idea what an automatic calculating device should look like, so this paper was hugely important to those people who set out to build one. The first machines to come out were huge, used immense amounts of electricity, broke often, but they worked!

A computer is really just a fancy electronic device that does very simple things. There is nothing magic about this. A human could act as the Control Unit, a piece of paper could function as the Memory, a calculator as the Central Arithmetic Unit, and the keys and display of the calculator as the Input/Output device.

To this day, most computers follow this basic architecture. This course focuses on creating programs for the most fundamental part of the modern computer - the Control Unit, or the Central Processor Unit (CPU). In today’s computer systems, the control unit and the arithmetic-logic-unit are packaged in a single integrated circuit. We will concentrate on one of the most popular of these chips - the CPU of most IBM-PC class of computers. Specifically, we will look at the Intel Pentium processor, and later at two much different chips - called microcontrollers.

Von Neumann’s Machine

The first electronic computing machine was actually constructed in England. It was called EDVAC. The first such machine in the US was Eniac, built at Penn State. There is some debate, even today, over which machine came first, but Von Neumann’s place in history was assured by his paper, which was widely circulated and became a handbook for further development of electronic computers.

../_images/edvac.jpg

EDVAC

This beast weighed in in tons, and was huge in all its glory. It was also fragile! About 300 of the tubes in this thing burned out each day and had to be replaced!

Computers Today

The basic hardware you find today, in a modern computer, still fit into one of Von Neumann’s basic structure:

Memory

We actually have several kinds of memory in a modern system

Internal Memory

This is also called RAM (Random Access Memory). This is where data are kept (and program code) while a computer works.

You want lots of this so you do not forget stuff, right? Actually, the primary memory in your computer forgets everything when the power goes away, so we need another place to store things between times when we process it. We use disk drives, and other devices like then, to do that.

External Memory

There are several kinds of storage devices around these days, all designed to store programs and data between (or even while) a program runs:

  • Hard Disk Drives (big and reasonable cheap, much slower than memory)
  • Solid-State Drives (not so big, expensive, and much faster than disk drives)
  • Flash Drives (USB Thumb Drives, cheap and easy to lose!)
  • DVD Drives (normally only for input, or movies/music)

All of these devices connect to the machine through the input/output component.

Control and Math

The heart of the modern machine lives in a single integrated circuit, that packs all 19,000 of those tubes in Edvac into a package about a half-inch square. (Actually, the modern chip has over a billion switches in it - Wow!) Amazing!

What is in that chip is everything needed to pull data in from external storage, move it around in memory, and transform data according to the instructions YOU provide.

They actually are simple devices. What happens inside that chip is pretty amazing. I teach an entire course on just that topic (COSC2325 - Computer Organization and Machine Language). It is a pretty cool course!

Input/Output

There are tons of other gadgets we can attach to a computer. All of these hook up to the computer either on an input connection, or an output connection (sometimes both).

For our work, the most important input device will be the keyboard. Using that you will be able to enter certain kinds of data. For the most part, that will be limited to numbers, letters, and short words. The program you write will convert the actual keys you type into those data items for you. (How is a more advanced course).

The most common output device we will use is your screen. We will make a few graphical things happen in this course, but often the output is just more numbers and words printed across the screen in a simple (boring) window called a “console”. That term dates back to the 1960s. Before that computers printed output on paper. Boy, did we kill a lot of trees when computing first started!)

Input and Output devices are the primary way we move from the human world to the computer’s internal world. The computer actually understands nothing about our world. It is up to us to figure out a way to transform anything in our world into something the computer can process.

As an example of that, let’s consider music.

Computing with Music

The computer cannot hear anything, but we have invented devices that react to sound. We call those things microphones.

../_images/microphone.png

When a microphone hears a particular sound it converts that into a varying signal (called an analog signal) that represents the sound it heard.

../_images/MicrophoneWave.png

That pile of wiggles is just a plot of the tones in the sound as they change over time. If we “sample” that signal really fast, we can convert it into a sequence of numbers. Each number represents the “tone” in that signal at that one tiny instant in time. If we were to play back that tone (over an output gadget called a “speaker”), our ear would hear the same tone.

../_images/speaker.jpg

Computers just do all of this so fast, your ear is unaware that it all got transformed in some cool ways. Since that music was converted into a bunch of numbers, it is easy to process the music and do cool things with it, like adjust all the tones, or “filter” out some tones we do not want to hear. (I wish I had a really good filter I could use any time I see a politician on TV - HA!)

Creatively thinking about things in our world has led to all kinds of interesting input and output devices. In my classes, we play with robotic devices that can make things move, detect motion, figure out how bright the light is in the area, or read a GPS signal from a satellite to see where we are.

Even 10 years ago, a lot of this was unthinkable, Shoot, I bet those folks traveling around the globe on sail driven ships would just about faint at the idea of GPS to help them figure out where they are. Of course, before Columbus, the idea of a satellite would bring up thoughts of demons, I bet! Today, many folks listen to “Mrs. Garmin” to get instructions as they drive around hunting down some restaurant!)

How Does the Computer Work?

Once we have a basic idea abou tthe parts in the machine, we can take a simle look at how the machine actually works. It just does a simple “dance”:

../_images/georgestrait.jpg

We live in Texas, so you all know how to two-step, right? I am not a native Texan, so I do not actually ever do the two step, but I have danced a time or two - usually at weddings. As humans, we all have some sense of rhythm. (Actually that may not be true, some folks cannot keep a beat to save their souls. We will ignore that fact.)

Keeping the beat

In order to dance, we need to have a sense of the beat. What is that anyway? It probably dates back to when ancient humans pounding on trees with a stick. Eventually they moved from the tree to a hollow tube with some form of skin stretched across it - what we call a drum today. That is one way to keep the beat, pound on a drum.

Another way might involve switching a light on and off. Just go stand in the front of the room and flip the switch in a pattern. The humans in the room will learn to track the on and off sequence and that forms a beat of a sort. Hmmm.

Moving with the beat

Once we have a beat to work with, we can start moving to the beat. Dancing involves moving through a sequence of basic steps in time to the beat. Here is the two-step:

../_images/TwoStep.jpg

When you learn how to dance, you find yourself counting steps:

  • “1,2,1,2,3,1,2,1,2,3,1,2,1,2,3”

You do something different on each count, and you do this over and over. Real dancing involves adjusting how you move a bit so you do not crash into the walls, but you basically keep on doing that basic thing until the music stops.

Note

Yeah, I know “real” dancers do a lot more than that, but you get the picture!

What does all this have to do with computers?

A long time ago, it occurred to people wanting to build machines that could “crunch” numbers, that about everything humans do could be reduced to a pattern similar to dancing. We learn a simple sequence of steps, and do them in time to the “music”. Hmmm, is that really true. Let’s see! How do I start a car:

  1. Get out the car keys
  2. Open the car door
  3. Sit in the driver’s seat
  4. Put the keys in the ignition
  5. Turn the key until the engine starts

I do this automatically every time I walk up to my car, and I do not even think about it. But the pattern is there, I just usually do not have any music to use to keep the beat. I still do it in about the same amount of time - practice makes perfect!

Can a machine do this?

It turns out to be pretty easy to build an electronic circuit that can keep a beat. We create electronic gizmos that operate at some voltage, like 110 volts for things you plug into the wall, or 3 volts for toys you give to a kid. Computers tend to run at 5 volts, so we build a simple circuit that can toggle between 0 volts and 5 volts in a simple pattern. It works just like you going up to the wall and flipping a light switch on and off in time to real music!

If I hook up a special device called an oscilloscope which shows me the voltage in a circuit over time, I might see this:

../_images/SquareWave.jpg

When the line is high, the voltage is 5 volts, when it is low, the voltage is zero volts.

Note

If you know nothing about electronics, think of voltage like water pressure. The higher the pressure (voltage) the more electrons we can move through a pipe (wire). Unfortunately, higher voltages can hurt you. Come to think of it, do not stand in front of a fire hose for the same reason!

Notice the funny stuff around the corners where the voltage changes. Real electronic signals do this kind of thing and it makes designing electronic gadgets hard. We will ignore that for this course. Someone already handled that stuff when they built the computers.

The computer clock

Computers are simple devices that have an internal “beat” kept by a signal of this kind. We call the device that generates this signal the system clock. All the stuff inside the computer does work in time to the beat of this clock. Now, as a human trying to generate the beat for a bunch of dancers, you could get cute and speed up the signal by flipping the light switch on and off faster. It might be fun to watch folks try to dance in time to the beat as this happened, but eventually people would fall down and come after you, so don’t do that!

Now computers do not really care about the signal going faster. They will just work faster. There is some upper bound on how fast you can flip the clock, but that is something involving how fast electrons move through wire. Unfortunately, as we try to make the computer work faster another problem comes up - it gets HOT. So we end up compromising and run the clock at some insanely high speed, like 2.6 billion “ticks” per second. Yikes!

Does a computer really dance?

Of course not! Really? Well I think it does, but it does so in a little different way.

Pretend you have a bunch of cards in your hand when the music starts. Each card shows you what you are to do during one small set of “steps” (Like those shown in the two-step diagram above). What you will do now, is pick a card off the top of the deck and when the music starts do exactly the sequence of steps on that card. When you run out, pick up the next card and work through those steps. I have no idea what this will look like, but it sounds kind of cool. Let’s see one chunk of two-step, followed by one chunk of waltz, followed by one chunk of rumba. Man that will be wild to see. (Dancing with the crazy stars, anyone?)

Now, let’s call each card an instruction, and the sequence of individual moves on that card we will call a “micro-instruction”

Guess what! You are looking at exactly what the Pentium processor does in your PC as it runs. Each “instruction” is a task (trick) the Pentium knows how to do. The “micro-instructions” guide the internal components of the processor in doing that task. As a programmer, you need to assemble a sequence of “instructions” to cause a higher-level task to happen. Our crazy dancers might need to move around the room in a square pattern. You stack up cards that cause that to happen. Obviously, you need to know what each card makes the dancer do, and what that means in terms of moving them across the floor. Once you know that, you could stack up a set of cards that makes them move as you wish. Cool, that is what programmers do!

Programming sounds hard!

It is not exactly hard, but it requires a level of attention to detail that is hard to do when you start. If you stack the cards wrong, the dancers crash into the walls. Not good! We deal with these problems, by improving our understanding of how the instructions work, and we try a different arrangement of the cards. Sooner or later, we end up with something that works as we want.

You can learn this

Think about it. In your day to day life, you know how to do tons of things. Each one of those things you had to learn how to do. You practiced until you did not even think about it, you just do the task and move on. Eventually, programming will get like that. You will know what each construct does, and you will stack them together in the right order and - boom - magic happens, the computer does your bidding.

I do not know why this fascinated me so much when I first started programming, but it changed my life!

What comes next

OK, we have a basic idea about how computers work, and what programs are. This is only the start. We will try to build up your internal image of what is happening as you create these program things!

I am a visual kind of person. I grew up very much into art as much as engineering, and it helps me to visualize things I do in the computer world. You work in a different way. I hope examples like this will help you construct your own internal picture of that is going on in your programs. Let me know if you have better ideas for something that works for you!