You will need to know..

text This topic explores the inner workings of a computer system which are very involved with brain of your computer the CPU, the Control Unit, buses and many registers (small fast storage spots) all working together to complete an operation. text

Structure and function of the Central Processing Unit (CPU)

Inside the CPU you will find:

The ALU performs simple addition, subtraction, multiplication, division, and logic operations, such as OR and AND. The memory stores the program's instructions and data.

The Control Unit directs the flow of data between the CPU and all other devices:

  • Accepts the next instruction
  • Decodes it into steps.
  • Manages execution.
  • Stores results back into memory or registers.
  • Sends memory read and writerequests to main memory on the control bus .
  • It sends other control requests e.g. bus requests, interrupt requests.
  • It coordinates and communicates with all parts of the CPU.

Registers are small piece of memory used to store data within the processor. There are many general purpose registers and some special registers:

  • The Program Counter - holds the memory location address of the next instruction to be executed. The address is copied into the Memory Address Register at the start of each Fetch-Decode-Execute cycle.
  • The Memory Address Register holds the address of the memory location from which a data/instruction needs to be fetched or written. The address is sent down the address bus.
  • The Current Instruction Register holds the instruction being executed (divided into opcode and operand).
  • The Accumulator - gathers together the result of the currently running instruction (this can be several special purpose registers).
  • The Memory Data Register holds data temporarily (also known as the memory buffer register or gateway to the processor because all data must pass through it).

Buses are the wires on a mother board connecting two or more components. There are three buses which connect the processor to main memory: the address bus, the data bus and the control bus.

  • When the CPU needs data from a memory location (from main memory or an IO device) it sends the address to memory along the address bus. The address bus is uni-directional as addresses are always sent from the CPU. Memory is divided into fixed sized chunks called word , each with their own memory address. These become the operand part of an instruction.
  • The data at the location specified by the address bus is returned along the data bus. The data bus is also bi-directional and moves data and instructions between components.
  • The control bus is bi-directional is used to control access to the data and address bus, because they are shared by all system components. Each device must wait for its turn to transmit. The control lines include:
    • Bus request (a device wants access) and Bus Grant (CPU gives access).
    • Memory Write (data is written from the data bus to the address location) and Memory Read (placed from address location onto data bus).
    • Interrupt (a device needs access to the CPU).
    • Clock (synchronisation of operations).

These buses are known collectively as the system bus. Watch the video below and read TeachICT website or BBCBitesize to find out more.


The Fetch-Decode-Execute Cycle

text Fundamentally a computer is a device takes input, it then processes the data and produces an output. Click here for more information. There are two main components: Memory and the CPU which carries out instructions. From the moment you boot up your computer until it shuts down the CPU uses the Fetch-Decode-Execute cycle to process instructions.

FETCH

  • The program counter holds the address of the next instruction to be executed. This is copied to the Memory Address Register.
  • The contents at that address are copied to the Memory Data Register.
  • At the same time the Program Counter is incremental to hold the next instruction.
  • The contents of the Memory Data Register are copied to the Current Instruction Register.

DECODE

  • The contents of the Current Instruction Register are split into OPCODE (what do I do) and OPERAND (what do I do it to?)
  • If the operand is the address of data needed, then the operand is copied to the Memory Address Register.
  • If it’s actual data to be used it’s copied to the Memory Data Register and may be passed on to the ALU or accumulator.

EXECUTE

  • The OpCode instruction is carried out on the operand. text

Little Man Computer

This was created to teach students about assembly language. An assembly language is a type of language which is almost exactly like the machine code that a computer can understand, except that it uses words in place of numbers. Assembly-language allows programmer to create a mnemonic code (e.g. MOV) which matches the machine instructions that a specific processor can perform. This is easier to remember than the binary machine-code instructions. Watch the two videos below to find out more about Little Man Computer. Click here for the LMC simulator to try it out.


Little Man Computer - Instruction Set

Here is the instruction set of commands recognised by the Little Man Computer. You will need to memorise this for your exam. The mnemonic maps directly to binary. text

Know your Mnemonics

  • LDA - LOAD
    • Load the contents of the given mailbox onto the accumulator (calculator). Note: the contents of the mailbox are not changed.
  • STA - STORE
    • Store the contents of the accumulator (calculator) to the mailbox of the given address. Note: the contents of the accumulator are not changed.
  • ADD
    • Add the contents of the given mailbox onto the accumulator (calculator). Note: the contents of the mailbox are not changed, and the actions of the accumulator are not defined for add instructions that cause sums larger than 3 digits.
  • SUB - SUBTRACT
    • Subtract the contents of the given mailbox from the accumulator (calculator). Note: the contents of the mailbox are not changed, and the actions of the accumulator are not defined for subtract instructions that cause negative results -- however, a negative flag will be set so that BRP can be used properly (see below).
  • INP - INPUT
    • Copy the value from the "in box" onto the accumulator (calculator).
  • OUT - OUTPUT
    • Copy the value from the accumulator (calculator) to the "out box". Note: the contents of the accumulator are not changed.
  • HLT - END
    • numerical/machine code - 000Causes the Little Man Computer to stop executing your program.
  • BRZ - BRANCH IF ZERO
    • If the contents of the accumulator (calculator) are 000, the PC (program counter) will be set to the given address. Note: since the program is stored in memory, data and program instructions all have the same address/location format.
  • BRP - BRANCH IF ZERO OR POSITIVE
    • If the contents of the accumulator (calculator) are 000 or positive (i.e. the negative flag is not set), the PC (program counter) will be set to the given address. Note: since the program is stored in memory, data and program instructions all have the same address/location format.
  • BRA - BRANCH ALWAYS
    • Set the contents of the accumulator (calculator) to the given address. Note: since the program is stored in memory, data and program instructions all have the same address/location format.
  • DAT - DATA LOCATION
    • When compiled, a program converts each instruction into a three-digit code. These codes are placed in sequential mailboxes. Instead of a program component, this instruction will reserve the next mailbox for data storage.

The Performance of the CPU

There are three main factors affecting the performance of the CPU:

  1. Clock Speed - The number of instruction cycles per second typically billions. All processor activities begin on a clock pulse (some may take more than one pulse to complete). Clock speed is measured in hertz. Gigahertz means 1 billion instructions per second. Processors are typically 2 or 4 GHz.
  2. Number of Cores - a core is a complete copy of the CPU (registers, ALU etc. as described above). The more cores the more programs which can be run at the same time. However,, software has to been written in a way which utilize each core, and cores need to communicate with each other. Both these factors affect performance. A modern quad core processor has four linked processors.
  3. Cache - this is a temporary small local and fast and expensive storage of instructions and data. This is quicker than storing in main memory (RAM). Cache exists at different levels from fastest and smallest to slightly slower but bigger.

Pipelining

Pipelining allows for multiple instructions to be handled concurrently (at the same time). While one core fetches, another decodes the previously fetched instruction. Whole another decodes the previously decoded instruction. Pipelining can improve efficiency because the CPU is not left idle and all parts of the processor can be utiised. However it doesn't always work as instructions can already be carried out before we find out that they were not required (if a program branches). So we end up needing to flush the pipe.


The Architecture of Processors

From the 1940s there are two main architectures: Vonn Neumann architecture:

  • shares memory space for both instructions and data.
  • Has a single Control Unit and a Single ALU
  • Uses the same bus for data and instructions
  • It follows the Fetch Decode Execute cycle, which means that it can only fetch either data or instructions at one time. text The Harvard architecture instructions and data are stored in separate memory units. text

Contemporary architectures

text Contemporary architectures may have faster methods to cope with higher needs such as graphics. For example SIMD (single instruction, multiple data) as the name suggests carries out a single instruction on multiple data items. Or MIMD (multiple instructions on multiple data sets). There is also distributed computing where processes are shared between multiple computers. Watch the video below to find out more.


Types of Processor: CISC vs RISC

The instruction set is a list of all instructions that a CPU can recognise and execute. It is written in machine code. There are two main categories: text CISC is the complex instruction set computer. CISC aims to complete the task in as few lines of assembly code as possible by using adapted hardware circuitry which is more complex and thus more expensive than RISC. So one mnemonic in CISC may be multiple mnemonics in RISC. CISC instructions resemble high level languages. Because the hardware is adapted it takes less effort to translate them into machine code, so the compiler can be simpler. For example the instruction MULT A, B is the equivalent of a = a * b.

CISC instructions can take longer to execute (multiple clock cycles) so pipelining isn’t possible. Because they are complex some CISC instructions rarely get used at all.

CISC used to be common in desktop computers and laptop in the 80s and 90s. These days it’s common for processors to have billions of transistors so these days CISC is less common, text RISC which is the reduced instruction set computer. RISC aims to use simple instructions which only take one clock cycle. So RISC can use pipelining. RISC requires multiple mnemonics (lines of assembly code), so the compiler needs to do more work to translate to assembly code.

Example: the CISC instruction MULT A, B would be broken down into:

  • LDA instructions to load A then B.
  • MULT to carry out the multiplication
  • STO to store the results. RISC is a little like the Little Man Computer.

Because instructions are simple, RISC instructions are frequently used. But they require a more complex compiler than CISC.

This means more RAM is required to store assembly instructions. However, because they are quick they require fewer transistors and less hardware (and lower energy).. which means more room for fast memory to speed performance like general purpose registers and cache. RISC is used in low power and portable devices, so about 90% of modern processors! text

  • Some instructions in CISC will rarely get used …
  • … In RISC instructions are used regularly
  • In assembly for CISC, a statement that takes one mnemonic …
  • … (may) take multiple mnemonics in RISC
  • Compilers for RISC need to be more complex …
  • … than compilers for CISC
  • CISC architecture has complex circuitry and is therefore more expensive to manufacture…
  • …RISC architecture has simple circuitry minimising manufacture cost.

GPUs

If you have a CPU, why do you need a GPU? A GPU is a specilist processor which will handle graphics faster than a CPU. It wont, however, be able to handle the general tasks that a CPU can handle. It consists of thousands of smaller more efficient cores which can handle multiple tasks at the same time. A GPU could be a graphics card or embedded into the motherboard.

Non Graphical Uses for a GPU

GPU scan also perform calculations on vectors etc. it can process multiple data at the same time. They can be used for calculating bills, modelling risk, insurance pricing.


Multi-Core Processors

A multi core processor is a single chip which holds more than one processing unit. This means that the chip can process many instructions independently and at the same time.

Parallel Processing

In general, parallel processing means that at least two microprocessors handle parts of an overall task. The concept is pretty simple: A computer scientist divides a complex problem into component parts using special software specifically designed for the task. He or she then assigns each component part to a dedicated processor. Each processor solves its part of the overall computational problem. The software reassembles the data to reach the end conclusion of the original complex problem. It's a high-tech way of saying that it's easier to get work done if you can share the load. computer.howstuffworks.com/parallel-processing.htm text These improve performance because they distribute workload across multiple CPU cores. The Japanese supercomputer Fugaku can process up to 537 Petaflops.

Input, output and storage

Input Devices text An input device is any hardware device that sends data to a computer, allowing you to interact with and control it. text Output Devices An output device is any piece of computer hardware equipment which converts information into a human-readable form. This could be text, graphics, sound, an actuator for a motor etc. text


Storage: SSD / Flash Memory vs Magnetic Hard Drive

Flash or SSD memory is very popular these days. It has the advantage of having no moving parts so it less likely to break when transported. It is also likely to be smaller than other storage mediums. Click here to find out more about flash memory. text You can see from the image below that magnetic storage has moving parts which can be damaged when in movement. For example the head could bump into the platter. Magnetic storage devices are also likely to be larger than SSD to make space for the moving parts. Click here to find out more about magnetic hard drives. text


RAM and ROM memory

Random Access Memory (RAM) is used to store the programs and data being used by the CPU in real-time. The data on the random access memory can be read, written, and erased any number of times. RAM is a hardware element where the data being currently used is stored. It is a volatile memory. Types of RAM:

  1. Static RAM, or (SRAM) which stores a bit of data using the state of a six transistor memory cell.
  2. Dynamic RAM, or (DRAM) which stores a bit data using a pair of transistor and capacitor which constitute a DRAM memory cell.

Read Only Memory (ROM) is a type of memory where the data has been prerecorded. Data stored in ROM is retained even after the computer is turned off i.e., non-volatile. It is also quick to start up e.g. BIOS.

www.geeksforgeeks.org/difference-between-ram-and-rom/

Virtual Storage

Virtual storage gives the user the impression that they have more storage space by

  • Virtual memory or virtual storage is a feature of an operating system that enables a computer to be able to compensate shortages of physical memory by transferring pages of data from random access memory to disk storage.
  • Virtual storage is also a feature of cloud computing and is available usually in the form of online storage or backup. It has the advantage of being available anywhere. But you need access to the internet. You also have to hand over control of your data to the hosting company.
  • Virtual storage can often appear as a drive so that it is not obvious to the user that the storage is virtual rather than secondary storage on their computer.