# A-level Computing/AQA/Paper 2/Fundamentals of computer organisation and architecture/Internal hardware components of a computer

Modern computing (arguably) started in 1822 when Charles Babbage, a British Mathematician, proposed 'the difference engine'. This was a mechanical machine that could calculate numbers from given inputs. Unfortunately Babbage never got enough funding to realise his plans and there was no Victorian Computing Revolution, however, you can see a completed modern version in the Science Museum in London (along with half of Babbage's brain!).
Since Babbage there have been several different designs of computers, and the one we are going to focus on here is called the 3-Box Model, or Von Neumann machine. In this machine:
* All data and instructions are stored in the Main Memory
* Instructions are sent to the Processor along the System Bus to be executed
* Any input and output (such as printing and entering instruction) is performed by I/O devices with the data travelling from the I/O devices to the Processor and Main Memory by means of the System Bus:
Consider a program stored on a DVD, to get the machine to run it, you will have to input the data from the DVD to the memory using the system bus. Once the program is loaded into memory the instructions it will be sent to the CPU line by line using the system bus and executed there. Any things to be printed or shown on a screen will be sent to the Output box.
An alternative method of building chips is the Harvard architecture. The key difference between this and von Neumann is that separate buses are used for data and instructions both of which address different parts of memory. So rather than storing data and instructions in the same memory and then passing them through the same bus, there are two separate buses addressing two different memories.
A program running on Harvard architecture can be executed faster and more efficiently, due to the fact it has two separate buses. Harvard architecture is widely used on embedded computer systems such as mobile phones, burglar alarms etc. where there is a specific use, rather than being used within general purpose PCs.
We'll now look in more detail at the components a processor:

## Processor

The processor (or Central Processor Unit - CPU) is one of the most complex parts of any computer system, it is made up of a thin slice of silicon approximately 2 cm square. Using microscopic manufacturing techniques, the silicon is implanted with millions of transistors together. The processor executes programs and supervises the operation of the rest of the system. Single chip processors are otherwise known as microprocessors. Gordon E Moore theorized that the number of transistors that could be integrated onto the chip would double every 18–24 months, most modern processors will contain billions of transistors. Multicore microprocessors are now very popular, where the processor will have several cores allowing for multiple programs or threads to be run at once.

## Main Memory

Main memory is used to store program instruction and data, using the System Bus to communicate with CPU. Main memory is often created using Random Access Memory (or RAM) or Read Only Memory (ROM). Modern computers will have gigabytes of RAM, meaning that large programs can run and multiple programs can run at once. The more main memory that you have the larger the number of programs you can run at once.
Main memory consists of data stored in addresses, in general, the more main memory you have the more addresses you'll have and vice versa.
    AddressContents 1024Cabbage 1025Celery 1026Courgette 1027Carrot 1028Cucumber 1029Chard
In the above example if we were to perform the following assembly code instruction:
    LDA 1026 ;LOAD memory location 1026
This would return the word: "Courgette"
If we were to perform the following assembly code instruction:
    STO "Beetroot", 1025 ;STORE data given into memory location 1025
This would change the value stored in memory location 1025 from "Celery" to "Beetroot"

### ROM and RAM

The two main types of main memory are ROM and RAM. Whilst RAM might be several gigabytes in size, ROM will often be a few kilobytes. As ROM is read only memory, it tends to store core software instructions such as the code needed to load the Operating System into RAM (known as bootstrapping) or change the bios. RAM is much much larger and stores the code to run the operating system and programs that you run on your computer. When you load a disc into a games console, the code won't do anything until it has loaded from the disc into the system RAM, that's why you see a loading screen.
* Exercise: Central Processing Unit
* Give a definition for main memory:
* Answer:
* Main memory is a data store that can be directly addressed by the CPU
* What is the difference between ROM and RAM?
* Answer:
* ROM is Read Only Memory, RAM is random access memory. This means that ROM cannot be written to, it can only be read from. RAM can be both read from and written to.
* Name the four components of Von Neumann Architecture
* Answer:
* Processor
* Main memory
* I/O devices
* System bus

## System Bus

A Bus is a connection between different devices. This connection will normally consist of multiple wires along which signals, instructions and data will be carried. In Von Neumann Architecture there is a single bus to manage the connection between the three main components. The System Bus consists of 3 separate buses, each with a specific task that you need to know. This three bus model is an expansion of the Von Neumann architecture showing greater detail.

### Address Bus

A single-directional bus that carries address signals from the CPU to Main Memory and I/O devices. This might involve the CPU requesting some data from Main Memory, sending the address of the data to Main Memory, then Main Memory returning the data along the data bus. Let's take a look at some code:
This code is asking to load the data from memory address 23 into the CPU, the address bus does not send addresses to the processor, but only sends them from the processor. To do this the CPU would send 23 along the Address Bus, and the value from memory location 23 would be sent along the Data Bus back to the CPU. The size of the Address Bus can dictate how much Main Memory you can have in your system. For example, if you had an Address Bus of 3 bits, then:
This would mean that your Main Memory could only have 8 different addressable blocks. Modern computers have much larger address buses, for example 16bits, which would be able to address $2^{16}=65536$ different addresses, from 0 to 65535.
* Extension: Modern Architecture
* The information above will serve you well for the exam; however, the way many modern processors work may break the definitions you have just learnt:
* Since modern CPUs now have internal memory(cache) and I/O devices have the ability to access memory without the need for the CPU(DMA), the address bus has to be bi-directional. However, the model used in the exam treats it as being uni-directional.
* Some modern systems combine address and data buses since they are used at different parts of the fetch decode execute cycle.
* What is now called ROM is nowadays just hard to write Flash memory requiring special equipment, voltages or processes. It isn't truly Read Only as you can change it with some difficulty. You may have upgraded the BIOS on your computer for example.
* Modern chip designs have evolved either towards integrating more logic onto the CPU chip (memory controllers, Ethernet interfaces, serial ports etc.) for embedded applications (driven originally by the design of printers and photocopiers and called SOC - System On a Chip) or towards a single fast bus towards a second chip that has multiple buses for various types of device (see Northbridge for more information).
Exercise: Central Processing Unit
Complete the following table:
NameDirectionDescription
Address Bus
Data Bus
Control Bus
Answer:
NameDirectionDescription
Address Busuni-directionalCarries addresses from the CPU to main memory or other devices
Data Busbi-directionalTransports data and instructions
Control Busbi-directionalTransports control signals
What is the largest number the following width data buses can carry at one time:
width 4 wires
Answer:
$1111=2^{4}-1=15$
width 6 wires
Answer:
$111111=2^{6}-1=63$
width 10 wires
Answer:
$1111111111=2^{10}-1=1023$
How many addresses can the following width addresses buses address:
width 4 wires
Answer:
$1111=2^{4}=16$
width 5 wires
Answer:
$11111=2^{5}=32$
width 8 wires
Answer:
$11111111=2^{8}=256$
An address bus that can address a maximum of 2GB memory is 31 wires in width. How many wires would it need if it were to address a maximum of 4GB of memory?
Answer:
32 as $2^{32}=4294967296$ bytes or 4GB of memory
But you don't have to be really good at maths to answer this. 4GB is twice 2GB and we know that 2^x is half the size of 2^x+1. :

## Peripherals

Input/Output devices are used by the system to get information in and out, as they are not internal but are connected to the CPU, we refer to them as peripherals (your hands are peripheral to your torso). We'll cover the specific ones you need to learn a little later, but for the moment you need to know the fundamental difference:
* Input Devices - used to get information into the system. E.g. Keyboard
* Output Devices - used to send information out of the system. E.g. Visual Display Unit (VDU)
If you look at the Von Neumann Architecture notice that it doesn't mention Keyboard or display, this is a very smart move as you don't want to force every computer to have a keyboard (think about a games console, there is no keyboard on that) or a VDU (some computers such as an MP3 players don't have a screen). However, some computer architecture does include specific Input Output controllers:

### I/O controllers

Controllers consist of their own circuitry that handles data flowing between the processor and the device. Every device will have its own controller which allows new devices to be connected to the processor at any time. A key feature of an I/O controller is that it will translate signals from the device into the format required by the processor. There are many different devices and many different types of processor and it is the I/O controller that provides the flexibility to add new devices without having to redesign the processor.
Another important feature is that the I/O devices themselves respond relatively slowly compared to the speed at which a processor can work. Therefore the I/O controller is used to buffer data being sent between the processor and the device, so that the processor does not have to wait for the individual device to respond.
Examples would include:
* keyboard controller, attached to a keyboard
* disk controller for a Hard Disk (Hard Disks are not main memory!)
* video display controller, attaching a video display unit (monitor)

### I/O ports

I/O ports is a complementary method of performing input/output between the CPU and peripheral devices in a computer. This allows I/O devices to be connected to the CPU without having to have specialist hardware for each one. Think about the USB port on your computer, you can connect Keyboards, Mice, Game pads, Cameras, Phones, etc. and they all connect using the same port.

## Secondary storage

Main memory can be very expensive and you often require storing data that you won't use constantly. Think about a computer game that you haven't played for a couple of months. The last thing you want to do is to store this code in main memory taking up all that precious and expensive space. To get past this issue we use secondary storage. This is normally inexpensive data storage sitting external to the CPU, connected through an I/O controller, that we can use as and when we need. Secondary Storage will store data permanently, without the need for the electricity to remain always on (Think about a USB key, it doesn't need to be plugged in to keep its data). So taking the game example again, we only load the game into main memory (maybe from a DVD or hard disk), as and when we need it. Examples of secondary storage include:
* Hard Disk drive
* USB thumb drives
* CD-ROM / DVD / Blu-ray
* Tape drives
* Exercise: I/O and Peripherals
* Name 2 input peripherals:
* Answer:
* Keyboard
* Mouse
* Scanner
* Camera
* Microphone
* Games pad
* Name 2 output peripherals:
* Answer:
* Speakers
* Printer
* Visual Display Unit
* Name two ways to connect peripherals to a CPU:
* Answer:
* I/O controller
* I/O ports
* Name 2 secondary storage devices:
* Answer:
* Hard Disk
* USB thumb stick
* CD-ROM / DVD / Blu-Ray
* Name 2 I/O controllers
* Answer:
* Hard Disk controller
* Keyboard controller
* Visual Display Unit Controller

## Addressable memory

A computer must be able to access main memory for reading and writing, they do this by using addressable memory. Main memory is a little like a set of school lockers, each with a different number. Each locker contains a block of data and if you fill up one locker you can use the next locker to expand into.
Looking at the example above you can see locker '0' contains '8975', whilst lockers 1 to 6 contain the sentence "The Cat sat on the dog!". Locker '7' is empty, locker '8' contains a boolean value and locker '9' contains the number 48. As you can see if we only used one character for the locker number then we could only ever have 10 lockers. If you limit the number of addresses you can use then you limit the amount of memory you can talk to. If you have a small address bus then you won't be able to have much main memory.
The way that data is stored in a computer is very similar:

## Summary

* The processor handles and processes instructions from the hardware and software.
* Processors can handle millions of instructions every second.
* Memory is made up of millions of addressable cells.
* Data and instructions are fetched, decoded and executed.
* There are two main types of main memory, RAM and ROM.
* The processor is connected to main memory and data and instructions are passed around circuitry known as buses.
* In von Neumann architecture, instructions and data are stored together in memory.
* In Harvard architecture, separate memory is used for data and instructions.
* Exercises
* The figure below shows how components of a computer system can be connected.
* Write in the corresponding space below, the correct name for each of A, B, C and D from the figure above using only the following:
* Processor
* Address Bus
* Data Bus
* Main Memory
* Keyboard
* Visual Display Unit
* A = ___________________________
* B = ___________________________
* C = ___________________________
* D = ___________________________
* Answer:
* A = Visual display unit
* B = Processor
* C = Main memory
* D = Keyboard
* Explain the role of the address bus, data bus and main memory.
* Answer:
* Address bus - used to specify a physical address in memory so that the data bus can access it.
* Data bus - transfers data between the processor and main memory.
* Main memory - stores data and instructions that will be used by the processor.
* Computer system exam q 2
* The figure below is a diagram of some of the components of a computer system.
* Match the component names to the numbers show in the figure above by completing the tables below. Some of the numbers have already been written in for you.