How a Computer Works: Processors

In a previous the Components of a Computer system. This includes a description of various types of memory, as well as the overall architecture of a computer.

Here I discuss in more detail precisely how various processing units work.


System on a Chip (SoC)

A System on a Chip puts many pieces of functionality onto one chip that used to be on separate chips. The most important are the central processing unit (CPU) and the graphics processing unit (GPU). Both of these are processors in that they run “programs,” but they are quite different.

Central Processing Unit – CPU

The CPU is designed for running general computer applications, everything from your file system to a word processor, a database to graphics and scientific programs. Its design is general purpose, and it is optimized for that.

The CPU follows the following steps:

  1. read in one instruction from the program area of memory
  2. execute the instruction
  3. read next instruction…

The instructions are pretty simplistic:

    • load a value from memory to an internal data register
    • move a value from one register to another
    • write a value from a register to memory
    • perform one arithmetic operation on values in two registers
    • perform one logical operation on values in 1 or 2 registers
    • test and branch

From these basic operations (and more complex variants of them)  programs are built.

It is the test and branch operations that give the CPU its power. For example. Suppose you want to do something to some data 10 times. you would have something like this:

Do: set counter = 0
  Do: set counter = counter + 1  {increment the value of variable "counter"}
  Do: step 1
  Do: step 2
  Do: step n
  Test: if counter < 10 Then Branch back to "repeat"

{If you get here then you have done 10 times }
{Continue with rest of program }
Do: next thing 1

So the CPU just keeps reading in program instructions, executing them, and going to the next. The diagram below is of the Intel 4004 chip, one of the very first microprocessors. The red ALU is the Arithmetic Logic Unit. It performs the operations after the instruction has been decoded. [Source: Wikipedia]

Intel 4-bit 4004 CPU microprocessor diagram

Intel 4-bit 4004 CPU microprocessor diagram

Of course it is all a lot more complicated than that – but these are the basic principles. Every step is so simple, but a modern CPU can do literally billions of instructions each second.

—- Our Sponsor: ——————————

Elegant, Handcrafted, Genuine Leather

iPhone Holster



Modern CPUs have multiple cores, each one a bit like a separate CPU. Each core in turn, may have more than one thread so that it can be processing either multiple data lines or multiple programs at one time.

Intel Core i5

Intel Core i5

[Source: Aph Networks]

Graphics Processing Unit – GPU

 But graphic images have several properties that make them special:

  1. They are made up of millions of little picture elements or pixels,
  2. Operations performed on them are typically mathematical, and
  3. Frequently the operations are performed on all the pixels repeatedly.

To illustrate pixels, here is a zoom in on the dot on the “í” in Quindífrom the second illustration bellow. The little squares are the pixels.

Pixels in an image

Pixels in an image

So let’s say you have an image and you want to darken it, as in the second illustration. What you need to do is darken each pixel by the appropriate amount, let’s say 20%. So what we need to do is multiply the Red, Green and Blue values for each of the 1.3 million pixels in the left hand image by 0.8. [Real graphics engineers please forgive the oversimplification]

delQuindio_productpic_estuches-15358-b copy

In other words, you must perform the same operation millions of times. The CPU is happy to do this for you – and does do this in simpler systems – but why not build a different compute engine that specializes in the these repetitive tasks.

The GPU implements a pipeline for data that goes through the identical operation in a stream. More importantly, it does so in parallel, with many streams running at the same time, each one working on a small portion of the overall image data. This way, a lot of data can get processed very quickly and efficiently, but its bag of tricks of what it can do are a bit more limited than the CPU.

A GPU is rated on how many Floating Point Operations per Second – or a FLOPS –it can perform. Modern ones are rated in giga-FLOPS, or 1 billion operations per second.

How it works

GPUs work by having multiple compute units. They consist of multiple cores, each core containing many threads. But the GPU works on the SIMD model – Single Instruction – Multiple Data..


Wikipedia states:

Single instruction, multiple data (SIMD), is a class of parallel computers in Flynn’s taxonomy. It describes computers with multiple processing elements that perform the same operation on multiple data points simultaneously. Thus, such machines exploit data level parallelism.

Unlike the CPU threads, in any given core, all the threads are performing exactly the same operation at the same time, but on different data. As noted above, we need to process all the data similarly. In a given time slice, each thread is performing a given set of instructions on one piece of data, then spiting out the return value. All the threads are doing this in lockstep, so the pipeline flow is simple.

It should be noted that a GPU will also have hardware specifically for coding/decoding common video formats, so this will also be optimized.

So GPUs look something like this:

GeForce_GPU Diagrams



If you appreciate this work

Then please check out my short fiction anthologies.

(Both available in both Amazon and iBooks stores.)

50 Cent Flash v1

50 Cent Flash v1
View on Amazon

50 Cent Flash v2 Buy iBook

50 Cent Flash v2
View iBooks Store

Your comments are appreciated.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s