Slides badge

Computer Structure

Learning Intentions

  • Describe the structure of a computer system

  • Understand how computer languages are run on a computer system

Success Criteria

  • I can describe the structure of a computer system
  • I can describe the terms compiler and interpreter and explain the difference between them and the need for them

How does a computer system work?

  • A computer system consists of several key parts:
    • The central processing unit (CPU)
    • The memory
    • The backing storage
    • Some kind of board to connect everything together (motherboard)

Computer Architecture

The CPU

  • The CPU or central processing unit handles instructions it is given and communicates with other hardware.
  • It also ensures that the hardware and software responds correctly to the user

Memory locations

The CPU

Control Bus

The cpu

  • The CPU consists of several different key parts:
    • The ALU (Arithmetic and Logic Unit)
    • The Control Unit
    • The registers

ALU

  • The ALU or Arithmetic and Logic Unit performs all the calculations in a computer system.
  • It also makes decisions based on logic.

if (true AND false) OR (false AND true) OR NOT(false AND true) AND (true and true) OR (true OR false)

Registers

  • Registers are very small memory locations found inside a CPU. They are temporary locations.
  • They store memory locations (addresses) from the main memory that are needed to execute an instruction
  • They also store data that is to be written to memory whilst the CPU is working on it
  • The registers of a CPU are very small (often just a few kilobytes)

A program is written that calculates the sum of two numbers.

 

  1. Which part of the computer system would store the two numbers?
  2. Which part of the CPU would store the result?
  3. Which part of the CPU performs the calculation that would get the result?

Review questions

Main Memory

  • The main memory is a part of a computer system that stores data whilst a program is running. 
  • Much like the registers, the data is cleared once the program stops.
  • The type of main memory used today is Random Access Memory.
  • When a computer is shut down, the data stored in the RAM is lost.
  • Another type of main memory is Read Only Memory (ROM)

Memory locations

  • A memory location is a location in the RAM. Each memory location has a unique address.
  • The more RAM a computer system has, the more programs (or Chrome tabs) can be open at the one time.
  • Today most PCs have around 8GB to 16GB.

Buses

  • A bus is a part of a computer system that allows different parts of it to communicate.
  • Buses are wires between different parts.
  • For example, the RAM and the CPU communicate through the data bus.
  • There are three buses you need to know about for National 5:
    • The data bus
    • The address bus
    • The control bus

Address Bus

  • The address bus carries memory address information from the processor and main memory or other devices.
  • It is a one-way bus, making it a uni-directional bus.
  • By sending a memory address, the device can obtain the data from the memory using the data bus.

Data bus

  • The data bus is another bus that is used for obtaining actual data from the main memory or putting data in the main memory
  • Since the data bus can be used to get or put data in the main memory, it is a bi-directional bus.

Control bus

  • The control bus is the final bus in a computer system
  • The control bus is made up of many wires, each with its own purpose. For example, there is one wire called the interrupt wire (IRQ) which is designed to communicate with external devices and another called the reset wire which forces the computer to restart.
A small part of a program is shown below:
 
Line 22 IF availableSpaces ≥1 THEN
Line 23 members = members + 1
Line 24 END IF

 

Name the part of the computer system that will carry out each of the following tasks during the execution of the code.

  1. Carries the location of members in the main memory.
  2. Transfers the value of members from the main memory to the processor.
  3. Calculates the new value of members.

Review questions

Computer programs

  • A computer follows instructions that tell it what to do. For example, this computer is following instructions that display this presentation.
  • A computer program is a series of instructions. Programs are written in computer languages.

Machine code

  • Machine code is a computers own language.
  • Machine code consists of 1s and 0s in sequence (binary numbers) that represent instructions and data.
  • Machine code is difficult for humans to understand
  • Machine code only works on one type of processor architecture (x86, x86-64, ARM-7 etc) and is therefore not portable.

Machine code

  • But humans don't have to write machine code.
  • We write code in programming languages such as Python or Visual Basic.
  • Python and Visual Basic are easy to understand compared with machine code and are therefore called high-level languages.

High-level languages

  • A high-level language is a computer language that uses everyday language such as if, for, set, let, get, while etc.
  • What language is this code written in?
function main()

  //Loops 10 times
  for($i = 0; $i < 10; $i++)
    print($i)
  end for

end function

High-level languages

  • This program can be changed from the original language into a code that a computer can understand as shown below (these numbers would then be converted to machine code)
12 3 18 19 3 18 8 19 4 3 16 3 18 19 3 18 8 77 4 3 19 32 18 4 3 16 5 69 4 3 36 5 69 4 3 47 19 3 18 4 3 19 17 32 17 12 

High-level languages

  • This program can be changed from the original language into a code that a computer can understand as shown below (these numbers would then be converted to machine code)
1100 0011 10010 10011 0011 10010 1000 10011 0100 0011 1110 0011 10010 10011 0011 

Answer either high-level language or machine code for each of these:

  1. Is easier to write
  2. Can only run on the processor architecture it was made for
  3. Computers understand it without translation
  4. Contains everyday words like if and for
  5. Is portable
  6. Consists of 1s and 0s

Review questions

Computers don't understand our language!

  • Given that computers can only understand machine code that is specific to them, they don't have any idea what high-level languages such as Python or Java mean!
  • Computer processors only understand machine code!

Translator programs

  • A translator program is a special program that is designed to convert code from one language to another. In most cases, this is converting from a high-level language such as Python to machine code.
  • This is a necessary step to ensure that the processor of the computer can understand it.
  • The two types of translator programs we look at are:
    • Compilers
    • Interpreters

Compilers

  • A compiler is a program that can translate a high-level language into machine code in a single operation.
  • The original high-level program is called source code.
  • The compiled program is called object code.
  • Once the code has been compiled the compiler is no longer needed (for example, it might be compiled to a Windows .exe file)

Interpreters

  • An interpreter is another type of translator program.
  • Unlike a compiler, an interpreter reads and translates each line of code individually and then runs it immediately after translating it. 
  • After that it moves to the next line of code and performs the same thing
  • If there is an error on the line, the program stops reading the lines. This also makes finding errors in code much easier.
  • Unlike a compiler, the computer interpreting the code will require an interpreter program every time to run it.

Interpreters vs compilers

Interpreted programs Compiled programs
Report errors immediately Report all errors after compilation
Are slow Are fast
Are translated line by line Are translated into machine code in one step
Require an interpreter to run the program every time Can be run independently of the compiler after compilation

Example

for i in range(0, 100):
  print(i)

How many lines will be translated with:

 

A compiler?

An interpreter?

Answer the following questions:

  1. Which programs runs faster, an interpreted program or a compiled program?
  2. Why do we need translator programs to translate from high-level code to machine code?
  3. Why is it easier to detect errors with an interpreter than a compiler?
  4. Why are compiled programs often not portable?

Review questions

Plenary

Whiteboards task!

 

For each of the following answer using the keyword from the lesson!

Plenary

The place where large amounts of data is stored in the computer system whilst it is running.

Random Access Memory

Reveal

Plenary

Where small amount of data are stored in the CPU when a computer is running

The registers

Reveal

Plenary

What ALU stands for

Arithmetic Logic Unit

Reveal

Plenary

The bus where you might expect to find a memory location being transferred

Address Bus

Reveal

Plenary

The computer program used to turn source code into object code in one go

A compiler

Reveal

Plenary

A computer language that uses keywords from the English language

A high-level language

Reveal

Past Paper Questions

Sam is creating a program to calculate and display the total cost of laying new flooring. Flooring is charged at £15 per square meter and skirting boards are charged at £60 per room.

 

The total cost is calculated by multiplying the total floor area by 15, then adding the number of rooms requiring skirting multiplied by 60.

 

  1. State the part of the processor that will perform the calculation once the program is implemented. 1 mark
  2. State the part of the processor used to temporarily store the result of the calculation. 1 mark

 

2022 Q10 b)

Presentation Overview
Close
JB
Computer Structure
© 2020 - 2024 J Balfour
20:53 | 03-12-2024
Join Live Session
Go Live
Start Remote
Save Progress
Slideshow Outline
Presenter Mode
Generate Quiz
Generate Lesson Plan
Widget Screen
Canvas Controls
Fullscreen
Random Selector
Timer
Volume Meter
Binary Converter
Python Editor
Show Knox 90
Provide Feedback
Help
!
Keywords
    DragonDocs Management
    Random selector
    Sections
      Binary conversion
      Denary to binary conversion
      Binary to denary conversion
      Feedback 👍
      Accessibility

      Apply a filter:

      ×
      Loading
      All slideshow files