Overview of the Computer’s Architecture

Let’s take a look at how computers are put together, the architecture of the machine. Do not get too worried about all of this - it is background for now. Part of this is history, and part is designed to help you understand what is inside these beasts!

The Von Neuman Computer

WAY back in 1945 – World War II was still going on – a very intelligent fellow named John Von Neuman was thinking about the whole business of computing. He published a paper titled First Draft of a Report on EDVAC that started the world on a whole new track.

Von Neuman explained to the world how a mechanical device with a Stored Program could process information.

His Computing Mechanism consisted of four fundamental parts:

  • Central Arithmetic Unit (CA)
  • Control Unit (CU)
  • Memory Unit (M)
  • Input/Output Unit (IO)

Von Neuman’s Original Computer Design showed these four components assembled in this fashion:

                        ____________
                       |            |
                       |     M      |
                       |____________|
                             ^
 ___________________________ | _________
|   ___________         _____v______    |    ____________         ____________
|  |           |       |            |   |   |            |       |            |
|  |    CA     |  <->  |     CC     |  <->  |    I/O     |  <->  |    nerd    |
|  |___________|       |____________|   |   |____________|       |____________|
|_______________________________________|

(OK, so nerd was not a term they used back then! They thought of this block as a computer user.)

We defined a computer as an Electronic Device earlier. However, there is nothing magic about this. It could be mechanical, or a human could act as the Control Unit, a piece of paper could function as the Memory Unit, a calculator as the Central Arithmetic Unit, and the keys and display of the calculator as the Input/Output unit.

To this day, most computers follow this basic architecture. This course focuses on creating programs for the most fundamental part of the computer - 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 - inside the Pentium processor in your home computer, for example.

Before we start off, let’s take a closer look at the components we use to build computers today - the basic hardware!

Hardware Parts

The hardware of computers is a bunch of very complex electronic pieces and parts. Hardware is what you can see and touch. It includes transistors, capacitors, resistors – all the normal components used to build electronics for Televisions, Radios, Microwaves, etc!

Designing the Hardware for a computer involves figuring out how to make electrons flow through various electronic components in some logical manner.

Discovering a Fundamental Fact!

When I was first studying computers in detail, I discovered that knowledge of electronics was not that important. While it is very important that someone knows how to build the electrical stuff, you do not need to know a lot about electronics to build computers.

Computers are mostly Logical devices. I constructed a number of computer systems by connecting fairly simple components (bought at places like Radio Shack) using logical rules! If I followed these rules correctly, I ended up with a working computer. Neat!

A Brief look at the parts

It is interesting to see how the fundamental parts work, at least in a crude way. In the following discussion what is really happening is not totally explained, but the description is accurate enough to get a sense of the actual operation of these parts. We saw some of these parts in the last lecture, so some of this is not new.

Here is a transistor:

../../_images/image002.png

Well, actually, that was the first one. There are three wires that control the transistor. One is the point where incoming electrons enter the device, one is the point where those electrons leave the device, and the last is a kind of gate control that regulates how many electrons flow through the device. Phew!

Note

If you know nothing about electronics, a simple analogy might help. You all know something about plumbing, right? Water flows through pipes as you open and close faucets. Water has a pressure and you have probably played around enough to understand that you cannot push a lot of water through a skinny pipe, but you can if the pipe is large enough. Now, when we talk about electrons moving through wires, thing of water moving through a pipe. We actually call the flow a current. When we talk about the voltage in an electronic circuit, think about water pressure. And when we talk about a switch, think faucet. That should be enough for what follows.

Now, a transistor works like this:

If a small number of electrons flow into the control, the transistor can control a large number of electrons flowing through the device. Just like you turning a knob on a faucet with a small amount of force to control a large amount of water flowing through your pipes into the bathtub!

Modern transistors are tiny and we draw simple symbol to represent them. What researchers discovered, was that when we combine a few of these devices, we could come up with circuits that performed logical or arithmetic functions - and the rest is history!

Here is a drawing of a circuit for a device we call an AND gate. Electrons will flow out of this device only if there are electrons flowing into input A AND input B:

../../_images/image003.png

The funny squiggles are called resistors and they help limit the number of electrons that flow - too many and we fry the device!

Now, we computer folks do not care about all this silly circuitry, so we typically draw this circuit in a very easy to use way:

../../_images/image004.png

This is the common symbol used to represent an AND gate. We also do not worry about electrons moving. Instead we simply measure the voltage at our inputs and outputs (this is always done by connecting a voltmeter between the input and a ground point in the circuit.) If the voltage is about 5 volts, we say the logical value is a 1, if the voltage is zero, we say the logical value is zero. Bingo! True and False, 0 and 1. Binary stuff!

../../_images/image005.png

This device is called a NOT gate. It inverts the signal, turning a 1 at the input into a 0 at the output - and vice versa! We can combine components like this to form more complicated devices: Here is a combination of parts:

../../_images/image006.png

Which gives us ‘’‘A AND NOT B’‘’.

What will the output be here for any possible input? One simple way to describe how the device works is to build a truth table showing all possible inputs and the associated inputs. Here is the truth table for the NOT gate

Input A Output B
0 1
1 0

Here is one for the AND gate:

Input A Input B Output C
0 0 0
1 0 0
0 1 0
1 1 1

And, here is the table for our combined circuit:

Input A Input B Output C
0 0 0
1 0 1
0 1 0
1 1 0

(See if you can figure this one out!)

Modern computers are clocked.

That is, there is an oscillator, usually controlled by a crystal much like those found inside modern watches, that generates a signal at a very fast rate. The hardware of a computer is designed in such a way that electrons flow from point to point only when the clock signal lets them. This is sort of like a traffic cop causing traffic to stop every once in a while. Every time the clock signal comes along, we might cause certain gates to change configuration thereby causing electrons to flow in different directions from component to component. The controls we use to alter this flow are called programs!

Since the movement of electrons through the circuit is sort of like water moving through pipes, another way to view all of this is to imagine an army of plumbing control engineers sitting near a bunch of valves that control where water might flow. Every time the clock ticks, the engineers consult their book of instructions and see which valves should be turned on, and which should be turned off. They do not care what is happening, but they are obediently following their book of instructions.

When the clock signal comes by certain kinds of devices, we can grab and hold the current state of a signal and hold it for a longer period of time. We say the signal has been latched into these devices. We can cause these devices to change state only be sending them a special signal called write. We are free to check these devices at any time and see what signal level has been latched. This is called reading the signal. Sounds like something useful, doesn’t it? We call a large collection of these devices memory!

When we look inside the modern computer chip we see millions of these basic electronic components furiously churning away according to the beat of the clock inside the system. The modern Pentium clock runs at 2.6 billion ticks per second - a pretty good rate!. What the computer can actually do during each tick of the clock is move a bunch of electrons from place to place and change the setting of a bunch of gates inside the chip - nothing very smart at all. The power comes from setting up a series of very simple steps to accomplish something much more useful to us.

My favorite saying is this:

Computers are as dumb as stumps - they are just dumb so fast they
look smart!

Now you know why!

Now we are ready to peek inside a modern computer - the Personal Computer. We start by looking at memory - one of the most important resources we will need to manage!

../../_images/PentiumInterior.png

How is Memory Organized?

We begin this study by considering how memory is organized from the perspective of the Intel Pentium processor which is the computer chip inside many PC’s.

In the Pentium, memory is organized as bytes

The term byte referrs to a container that can hold eight 0’s or 1’s. A bit is a single switch. Think of memory as a series of these bytes numbered from zero to some upper bound. Each number we assign to a memory byte container is called the address of that memory container.

In the first generation Intel 8086 processor, there were 20 bits available to generate a memory address. That means we could represent an address for any location in the memory the 8086 can reach using a 20 bit binary number.

So, the addresses start at address 0, and end at about a million. We called that amount of memory a megabyte of memory - more than enough - or so Bill Gates is reported to have said once (Dumb, Bill, dumb!)

The processor can either read bytes from memory or write bytes to memory. When the processor reads or writes to memory, it must generate an address for the location it wants to use. That address is used to select exactly one memory container and the processor manipulates that container. (Actually, it can work on chunks of memory that take up two or four bytes as well.)

Later CPUs increased the number of address bits to 32 so we can address much more memory (we had to to keep up with Microsoft’s bigger and bigger software packages!) Now we can access 4 gigabytes of memory. More than enough, right Bill? HA! Just wait until Vista shows up. Terabytes of memory, anyone?

Storing Data

So we have a bunch of physical memory in our computers and the CPU can reach any location by generating an appropriate address to refer to a single storage location. Storing bytes is easy, one memory location can hold one byte of data. But how do we handle bigger chunks of data?

Storing Words

Two bytes of data (16 bits) is called a word. (Why is a historical thing.) We have two ways to store words in memory. We can place the low 8 bits in the first memory location, and the high 8 bits in the next memory location, or we can do the reverse. Intel has chosen the first scheme. This is called Little Endian in the literature. Other processors use the opposite scheme. Fortunately, we do not care about this unless we move a pile of bits from one machine to another by some method.

The Processor knows that this is how words are stored and will fetch words from memory in the correct manner. You need to place data in the right locations if you load memory with words yourself. (Fortunately, the processor will do most of this for you!)

Storing bigger chunks of data follows this same pattern. Four bytes is called a Double Word or DWORD. Eight bytes is a Quadword or QWORD. The CPU can manipulate all of these kinds of chunks and can figure out how to fetch or store such beasts in memory.

Storing Bits

If all we need is a bit or two to encode our information, we have a slight problem. We must use at least one byte to do this. That means we waste a few bits. The computer does not like dealing with information that is spread randomly across byte boundaries. Every piece of information should start in a nice location, even if it means we skip a few bits in the process. Oh well, I am glad I have a few billion bits available to take care of this problem!

Kinds of Memory in our Computers

There are several classes of memory available to us in modern computer systems.

Primary Memory

The most common memory is made up of chips storing large numbers of bytes. These chips make up the primary memory of our computer. This memory is directly connected to the CPU by a bus, which is nothing more than a bunch of wires making up the lines that set an address and the lines that pass data back and forth. The addresses are set by the processor using the address scheme we just discussed.

There are two types of chips in common use:

  • Read/Write (Random Access) - RAM
  • Read Only (Random Access) - ROM

The only real difference in these two classes of memory is that once something has been recorded in ROM (usually done with special programmers) those bits cannot be changed by the processor! These bits remain in the memory even if the power is removed. Normal RAM can be modified by the processor, and the data stored there disappears when the power is removed from the memory chip!

Secondary Memory

Most computers also have secondary memory, usually in the form of hard disks where very large numbers of bytes can be stored. It takes programs to copy the data from secondary memory into the primary memory and visa versa. .

How does the Microprocessor work?

In the Von Neuman Computer, some of the information we place in memory is interpreted by the hardware as instructions that control what the hardware is to do. Every machine has a unique (and different) set of instructions that it knows. These instructions are called the ‘’Machine Language’’ of the computer.

We already know that the processor is attached to memory and input/output devices and that information flows through the bus lines as it moves through the system. But how, exactly, does this work. To understand this, we need to look closer at the clock

The Internal Clock

As we discussed earlier, every processor has a clock circuit that ticks away at an incredible rate. The processor uses this clock to trigger various events as it runs. The most basic event sequence the processor engages in is known as the ‘’Fetch, Decode, Execute’’ instruction cycle.

Fetch, Decode, Execute

Here is how it goes. When the processor is ready to execute an instruction it waits for the next clock tick. It places an address on the address bus that identifies where in memory the instruction is. Once the address is stable (it takes a while for all the signals to get set right), the processor sends a read signal to the memory. The memory controller then sets up to deliver the data in that memory location on the data bus, and once again, we need to wait a bit. Finally, the memory controller signals the CPU that the memory is ready to be read and the data is entered into the processor. Most of the time, things wait for the next clock tick before they take place, but not always.

Phew! All of that just to Fetch and instruction. Now what?

The data read into the processor is all or part of an instruction for the processor (we hope!). The processor must decode that instruction and set up its internal structure to actually do the work required. Often this involves triggering the ALU (another term used for the Central Processing Unit) to do some manipulation of data. Other times, it may just involve setting a signal line. If the instruction needs more data from memory (and many do) then the processor must go through another (maybe several) fetch cycle to get that data.

Once all the information is in the chip ready to go, another clock starts the actual execution of the instruction.

Finally, the processor places any results generated by the instruction back into memory or to an internal location inside the chip for use later. Guess what, more Fetch - like cycles to access memory.

One instruction thus can take anywhere from one clock tick to over 50 or more depending on how complicated the instruction is.

Although this sound pretty complicated, it is actually so simple it is amazing that computers seem as powerful as we think they are.

There is a lot of complexity in the moderm computer. Fortunately, we do not need to worry about it unless you really want to program this computer at it most basic level - in machine language! (Actually we would use something called Assembly Language here, because a lot of 0’s and 1’s tend to hurt your head as a programmer!)