Wiki : learning:machines
 

Machine architecture

Introduction

The simplest type of machine is the Turing Machine which in it's simplest form is a tape with slots where you can read and write binary values, go forth and back on the tape depending (or not) on the tape's values. A Turing Machine is proven to solve many logic problems and all computer we use today can solve the same problems or just a subset of them, but not more.

Processor

Today's machines are much more complex than a Turing Machine and work using logic gates. A logic gate receive one or more values as its input and produces the output based on simple logic rules.

The basic logic gates are:

  • AND: Test if two values are the same
  • OR: Test if any of the values is true
  • NOT: Inverts the value (true become false and vice-versa)

All other logic gates are derived from those three (in fact AND is derived from OR and NOT, but don't worry about it now). Each logic gate have a table of possible values due to its input that's called the truth table:

  • AND: Those gates return true only when both values are true
A B AND
false false false
false true false
true false false
true true true
  • OR: This gate return true when at least one of the values is true
A B OR
false false false
false true true
true false true
true true true
  • NOT: This gate only invert the value, whatever it is
A NOT
true false
false true

All this gates are for binary values but the same logic could be applied to any value if you apply it for each bit on each value.

There are some other important gates heavily used on hardware and low-level software:

  • XOR: Returns true only if the values differ
A B XOR
false false false
false true true
true false true
true true false
  • NOR: It's a NOT right after an OR
A B NOR
false false true
false true false
true false false
true true false
  • NAND: It's a NOT right after an AND
A B NAND
false false true
false true true
true false true
true true false

Storage

To enable the processor to compute data it first needs to be stored somewhere and also the result needs to be stored somewhere else.

There are two main types of storage:

  • volatile (main memory, cache, registers)
  • non-volatile (hard disks, flash, optical media)

Volatile memory

A volatile type of memory is the one that will disappear as soon as you turn the computer off. Some volatile memory types (dynamic RAM for instance), forgets its own value in less than a second so the computer must keep reminding the value of all memory positions, all the time. This is achieved by a very smart device:

A very simple AND logic gate, with two inputs: 1 (an electric pulse) and the current value of the memory. If the value is 1, the result is 1, if the value is 0, the result is 0. This logic gate receives the “1” input lots of times in a second, keeping the value on that particular memory while the machine is turned on. As soon as you stop providing the “1” (ie. turn off the computer), the memory will forget everything.

One might think it's a complete waste of time but the main reason of their existence is that reading from such memories is extremely fast. They are more expensive than hard-disks but much cheaper than static RAMs (even faster).

Cache

The processor is always orders of magnitude faster than most storage, so reading the data to faster memories are definitely an advantage. This is called caching, when you read a small chunk of data from a slow device and store it on a much faster (but smaller) device. If you access the data continuously (quite often) you can achieve very high speeds, even using several layers of cache. As the speed of memory increases its price also increases (exponentially) so it must be smaller in capacity. Therefore, caching data usually means storing a subset of the data that I'm accessing now.

Whenever the data you want to access is not in the cache you have a cache miss which forces the processor to read from the slower media again and store a good portion of it in cache for future reads. Nowadays, processors have two (or three) layers of cache, usually a few kilobytes of inner cache and a few megabytes of outer cache. The main memory is also considered a cache for non-volatile medias such as hard-disks and optical media.

Non-Volatile memory

A non-volatile memory is exactly the opposite, it keeps the information even without energy supply. Its technology is not based in logic gates so it doesn't need energy to keep the information. Most common technologies are (historical order):

  • mechanical, where physical changes in the material (like punches and holes) were than read by reading brushes. Example: punched cards
  • magnetic, where a writing head changes the magnetic orientation of some molecules in the surface of the media and the reading head understands it. Examples: hard-disks, floppy, tapes
  • optic, where the head burns a portion of some plastic and than the reading head interpret the reflection of that portion. Examples: CD, DVD, MiniDisk
  • flash, similar to volatile, but the charge applied to the cells are stored for a very long time. Examples: USB cards and all electronic appliances today

Non-volatile media are used primarily to store large quantities of data, like pictures, documents, programs, etc. for a long time (years). Because of its lower prices the size of disks have been growing exponentially for the last years.

Some non-volatile memories are faster than others so caching information between them is also a common practice. The most used is to cache CD information on hard disks, and the new trend is to use flash cards as cache for hard drives' most accessed files.

Swap

Although hard disks are slower than the main memory most systems today have a large area on disk called swap that is an extension of the main memory in disk. It may seem useless to use a media that is thousands of times slower for memory operations but in case of memory shortage it's preferable to slow down the computer than to break all programs at once (that will happen if swap is not available).

Swap is the opposite of cache. When you need to use a portion of data you cache it, when you don't need it anymore you swap it. Although the name is normally associated with hard-drives (as swap for main memory) this process can occur between any two layers of storage.

Peripherals

Everything that is not the computer's core is called a peripheral. The computer core is essentially the processor and the main memory (and its associated caches). This core communicates with the outside world through an electronic board called main board.

The main board (sometimes called mother board) is what glues together all components of the computer: processor, main memory, hard drives and CDs, keyboard and mouse, monitor, additional boards like sound and network. Everything is connected to the main board, directly or indirectly.

In the beginning, the processor took care of all input/output operations, dealing with the communication of all peripherals with the processor and between themselves. Because the peripherals are much slower than the processor, it was a waste of time to wait for an answer while programs were waiting their time to execute and that made the computer slower than it should be.

Later, main board began to have simpler processors just to deal with I/O. Newer main boards have one processor to deal with each kind of peripheral and some have a processor that only deals with the communication between the main processor and the main memory. The most important of such processors are the NorthBridge, between the processor(s) and the main memory and the SouthBridge, connecting those two (via NorthBridge) to the other boards via the pipelines.

Pipelines

At first, the communication was wired: every internal component had its own channel with the core. But soon enough the hardware engineers figured out that it'd be impossible to keep a separated channel of communication between the core and every single peripheral in existence, than the design of a common pipeline was a must. Since the first pipeline, several technologies came and went, always giving place to a better, wider and faster pipeline technology.

Common pipelines you may have heard are:

  • PCI: connects to extension boards (network, sound, modem, video etc.).
  • USB & FireWire: connects to slow hardware (keyboard, mouse, webcams etc.), external storage (flash drives) and communication (bluetooth, wi-fi etc).
  • AGP & PCIe: Newer pipelines, much faster than PCI and used primarily for video cards designed for the high demand computer games.

On-board

Nowadays, most peripherals that once were added as a bonus feature to your computer, are now on-board. It means that the main board now is not only the connector between all peripherals, it's also the peripherals themselves. 7.1 sound, high-end video, fast-ethernet among others are now bundled together with the main board.



 
learning/machines.txt · Last modified: 05 09 2007 19:15 (external edit)
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki